Skip to content

Commit

Permalink
[tools] Add line number format in LaTeX styles.
Browse files Browse the repository at this point in the history
close #686

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Jul 5, 2017
1 parent 0933b00 commit a5f4775
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 41 deletions.
5 changes: 4 additions & 1 deletion formatting-styles/latex/sarl-beamer-listing.sty
Expand Up @@ -22,7 +22,7 @@
% limitations under the License.
%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sarl-beamer-listing}[2017/05/30]
\ProvidesPackage{sarl-beamer-listing}[2017/07/05]
\newif\ifusesarlcolors\usesarlcolorstrue
\DeclareOption{sarlcolors}{\global\usesarlcolorstrue}
\DeclareOption{nosarlcolors}{\global\usesarlcolorsfalse}
Expand All @@ -43,6 +43,7 @@
\colorlet{SARLstring}{SARLmagenta}
\colorlet{SARLkeyword}{SARLblue}
\colorlet{SARLidentifier}{SARLdarkgray}
\colorlet{SARLlinenumber}{SARLblue}
\lstdefinelanguage{SARL}{%
morecomment=[l]{//},
morecomment=[s]{/*}{*/},
Expand Down Expand Up @@ -70,6 +71,8 @@
tabsize=2, % sets default tabsize to 2 spaces
title=\lstname, % show the filename of files included with \lstinputlisting; also try caption instead of title
frameround=fttt, % If framed, use this rounded corner style
xleftmargin=20pt,
numberstyle=\color{SARLlinenumber}\tiny,
}
\newcommand{\code}[1]{\ifmmode\text{\lstinline[basicstyle=\usebeamertemplate{code inline style}]{#1}}\else\lstinline[basicstyle=\usebeamertemplate{code inline style}]{#1}\fi}
\newcommand{\sarl}{\mbox{SARL}\xspace}
Expand Down
5 changes: 4 additions & 1 deletion formatting-styles/latex/sarl-colorized-listing.sty
Expand Up @@ -22,7 +22,7 @@
% limitations under the License.
%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sarl-colorized-listing}[2017/05/30]
\ProvidesPackage{sarl-colorized-listing}[2017/07/05]
\newif\ifusesarlcolors\usesarlcolorstrue
\DeclareOption{sarlcolors}{\global\usesarlcolorstrue}
\DeclareOption{nosarlcolors}{\global\usesarlcolorsfalse}
Expand All @@ -44,6 +44,7 @@
\colorlet{SARLstring}{SARLmagenta}
\colorlet{SARLkeyword}{SARLblue}
\colorlet{SARLidentifier}{SARLdarkgray}
\colorlet{SARLlinenumber}{SARLblue}
\lstdefinelanguage{SARL}{%
morecomment=[l]{//},
morecomment=[s]{/*}{*/},
Expand Down Expand Up @@ -75,6 +76,8 @@
tabsize=2, % sets default tabsize to 2 spaces
title=\lstname, % show the filename of files included with \lstinputlisting; also try caption instead of title
frameround=fttt, % If framed, use this rounded corner style
xleftmargin=20pt,
numberstyle=\color{SARLlinenumber}\tiny,
}
\newcommand{\code}[1]{\ifmmode\text{\lstinline[basicstyle=\normalcolor]{#1}}\else\lstinline[basicstyle=\normalcolor]{#1}\fi}
\newcommand{\sarl}{\mbox{SARL}\xspace}
Expand Down
4 changes: 3 additions & 1 deletion formatting-styles/latex/sarl-listing.sty
Expand Up @@ -22,7 +22,7 @@
% limitations under the License.
%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{sarl-listing}[2017/05/30]
\ProvidesPackage{sarl-listing}[2017/07/05]
\newif\ifusesarlcolors\usesarlcolorstrue
\DeclareOption{sarlcolors}{\global\usesarlcolorstrue}
\DeclareOption{nosarlcolors}{\global\usesarlcolorsfalse}
Expand Down Expand Up @@ -62,6 +62,8 @@
tabsize=2, % sets default tabsize to 2 spaces
title=\lstname, % show the filename of files included with \lstinputlisting; also try caption instead of title
frameround=fttt, % If framed, use this rounded corner style
xleftmargin=20pt,
numberstyle=\color{SARLlinenumber}\tiny,
}
\newcommand{\code}[1]{\ifmmode\text{\lstinline[basicstyle=\normalcolor]{#1}}\else\lstinline[basicstyle=\normalcolor]{#1}\fi}
\newcommand{\sarl}{\mbox{SARL}\xspace}
Expand Down
1 change: 1 addition & 0 deletions main/coreplugins/io.sarl.lang.mwe2/GenerateSARL2.mwe2
Expand Up @@ -290,6 +290,7 @@ Workflow {
stringColor = "SARLmagenta"
keywordColor = "SARLblue"
identifierColor = "SARLdarkgray"
lineNumberColor = "SARLblue"
}
}
}
Expand Down
Expand Up @@ -382,6 +382,8 @@ public static class ColorConfig {

private String identifierColor;

private String lineNumberColor;

/** Set a color.
*
* @param color the color.
Expand Down Expand Up @@ -476,6 +478,25 @@ public String getIdentifierColor() {
return this.identifierColor;
}

/** Set the color of the line numbers.
*
* @param name the name of the color to use.
*/
public void setLineNumberColor(String name) {
this.lineNumberColor = name;
}

/** Replies the color of the line numbers.
*
* @return the name of the color to use.
*/
public String getLineNumberColor() {
if (Strings.isEmpty(this.lineNumberColor)) {
return DEFAULT_COLOR;
}
return this.lineNumberColor;
}

}

}
Expand Down
Expand Up @@ -308,6 +308,7 @@ protected void generate(IStyleAppendable it, Set<String> literals, Set<String> e
it.appendNl("\\colorlet'{'SARLstring'}{'{0}'}'", colors.getStringColor()); //$NON-NLS-1$
it.appendNl("\\colorlet'{'SARLkeyword'}{'{0}'}'", colors.getKeywordColor()); //$NON-NLS-1$
it.appendNl("\\colorlet'{'SARLidentifier'}{'{0}'}'", colors.getIdentifierColor()); //$NON-NLS-1$
it.appendNl("\\colorlet'{'SARLlinenumber'}{'{0}'}'", colors.getLineNumberColor()); //$NON-NLS-1$
}

final String langName = getLanguageSimpleName().toUpperCase();
Expand Down Expand Up @@ -385,6 +386,8 @@ protected void generate(IStyleAppendable it, Set<String> literals, Set<String> e
it.append(" title=\\lstname, % show the filename of files included with "); //$NON-NLS-1$
it.appendNl("\\lstinputlisting; also try caption instead of title"); //$NON-NLS-1$
it.appendNl(" frameround=fttt, % If framed, use this rounded corner style"); //$NON-NLS-1$
it.appendNl(" xleftmargin=20pt,"); //$NON-NLS-1$
it.appendNl(" numberstyle=\\color{SARLlinenumber}\\tiny,"); //$NON-NLS-1$
it.appendNl("}"); //$NON-NLS-1$

String inlineBasicStyle = this.inlineBasicStyle;
Expand Down
Binary file modified main/coreplugins/io.sarl.lang/src-gen/io/sarl/lang/SARL.xtextbin
Binary file not shown.
Expand Up @@ -304,7 +304,7 @@ public class TypeElements extends AbstractParserRuleElementFinder {
private final RuleCall cMembersAnnotationFieldParserRuleCall_2_10_5_0 = (RuleCall)cMembersAssignment_2_10_5.eContents().get(0);
private final Keyword cRightCurlyBracketKeyword_2_10_6 = (Keyword)cGroup_2_10.eContents().get(6);

//Type xtend::XtendTypeDeclaration:
//@ Override Type xtend::XtendTypeDeclaration:
// {xtend::XtendTypeDeclaration} annotations+=XAnnotation* ({SarlEvent.annotationInfo=current} modifiers+=CommonModifier*
// 'event' name=ValidID ('extends' extends=JvmParameterizedTypeReference)? ('{' members+=EventMember* '}')?
// | {SarlCapacity.annotationInfo=current} modifiers+=CommonModifier*
Expand Down Expand Up @@ -3211,8 +3211,7 @@ public class MemberElements extends AbstractParserRuleElementFinder {
private final RuleCall cMembersAnnotationFieldParserRuleCall_2_6_5_0 = (RuleCall)cMembersAssignment_2_6_5.eContents().get(0);
private final Keyword cRightCurlyBracketKeyword_2_6_6 = (Keyword)cGroup_2_6.eContents().get(6);

//// Members for the object-oriented types
//Member xtend::XtendMember:
//@ Override Member xtend::XtendMember:
// {xtend::XtendMember} annotations+=XAnnotation* ({SarlField.annotationInfo=current} modifiers+=CommonModifier*
// (modifiers+='extension' (modifiers+=FieldModifier | modifiers+=CommonModifier)*
// name=ValidID ':' type=JvmTypeReference
Expand Down Expand Up @@ -4184,7 +4183,7 @@ public class AnnotationFieldElements extends AbstractParserRuleElementFinder {
private final RuleCall cMembersAnnotationFieldParserRuleCall_2_4_5_0 = (RuleCall)cMembersAssignment_2_4_5.eContents().get(0);
private final Keyword cRightCurlyBracketKeyword_2_4_6 = (Keyword)cGroup_2_4.eContents().get(6);

//AnnotationField xtend::XtendMember:
//@ Override AnnotationField xtend::XtendMember:
// {xtend::XtendMember} annotations+=XAnnotation* ({SarlField.annotationInfo=current} modifiers+=CommonModifier*
// modifiers+=FieldModifier
// modifiers+=CommonModifier*
Expand Down Expand Up @@ -4599,7 +4598,7 @@ public class ParameterElements extends AbstractParserRuleElementFinder {
private final Assignment cDefaultValueAssignment_6_1_1 = (Assignment)cGroup_6_1.eContents().get(1);
private final RuleCall cDefaultValueXExpressionParserRuleCall_6_1_1_0 = (RuleCall)cDefaultValueAssignment_6_1_1.eContents().get(0);

//Parameter xtend::XtendParameter:
//@ Override Parameter xtend::XtendParameter:
// {SarlFormalParameter} annotations+=XAnnotation* (extension?='extension' annotations+=XAnnotation*)?
// name=ValidID ':' parameterType=JvmTypeReference (varArg?='*' | '=' defaultValue=XExpression)?;
@Override public ParserRule getRule() { return rule; }
Expand Down Expand Up @@ -4675,7 +4674,7 @@ public class XtendEnumLiteralElements extends AbstractParserRuleElementFinder {
private final Assignment cNameAssignment_1 = (Assignment)cGroup.eContents().get(1);
private final RuleCall cNameValidIDParserRuleCall_1_0 = (RuleCall)cNameAssignment_1.eContents().get(0);

//XtendEnumLiteral xtend::XtendEnumLiteral:
//@ Override XtendEnumLiteral xtend::XtendEnumLiteral:
// {SarlEnumLiteral} name=ValidID;
@Override public ParserRule getRule() { return rule; }

Expand Down Expand Up @@ -4731,10 +4730,7 @@ public class XPrimaryExpressionElements extends AbstractParserRuleElementFinder
private final RuleCall cXParenthesizedExpressionParserRuleCall_14 = (RuleCall)cAlternatives.eContents().get(14);
private final RuleCall cBreakExpressionParserRuleCall_15 = (RuleCall)cAlternatives.eContents().get(15);

////-----------------------------------------------
//// BELOW THIS POINT, THE RULES FROM XTEXT ARE OVERLOADED
//// Variable declaration according to the SARL syntax (not the Xtext/Xtend)
//XPrimaryExpression xbase::XExpression:
//@ Override XPrimaryExpression xbase::XExpression:
// XConstructorCall | XBlockExpression | XSwitchExpression | XSynchronizedExpression | XFeatureCall | XLiteral |
// XIfExpression | XForLoopExpression | XBasicForLoopExpression | XWhileExpression | XDoWhileExpression |
// XThrowExpression | XReturnExpression | XTryCatchFinallyExpression | XParenthesizedExpression | BreakExpression;
Expand Down Expand Up @@ -4826,7 +4822,7 @@ public class XVariableDeclarationElements extends AbstractParserRuleElementFinde
private final Assignment cRightAssignment_3_1 = (Assignment)cGroup_3.eContents().get(1);
private final RuleCall cRightXExpressionParserRuleCall_3_1_0 = (RuleCall)cRightAssignment_3_1.eContents().get(0);

//XVariableDeclaration xbase::XExpression:
//@ Override XVariableDeclaration xbase::XExpression:
// => ({xtend::XtendVariableDeclaration} ((writeable?='var' | 'val') extension?='extension'?
// | extension?='extension' (writeable?='var' | 'val'))) name=ValidID (':' type=JvmTypeReference)? ('='
// right=XExpression)?;
Expand Down Expand Up @@ -4934,8 +4930,7 @@ public class JvmFormalParameterElements extends AbstractParserRuleElementFinder
private final Assignment cParameterTypeAssignment_2_1 = (Assignment)cGroup_2.eContents().get(1);
private final RuleCall cParameterTypeJvmTypeReferenceParserRuleCall_2_1_0 = (RuleCall)cParameterTypeAssignment_2_1.eContents().get(0);

//// Formal parameter declaration according to the SARL syntax (not the Xtext/Xtend)
//JvmFormalParameter xtend::XtendFormalParameter:
//@ Override JvmFormalParameter xtend::XtendFormalParameter:
// extension?='extension'? name=ValidID (=> ':' parameterType=JvmTypeReference)?;
@Override public ParserRule getRule() { return rule; }

Expand Down Expand Up @@ -4977,8 +4972,7 @@ public class FullJvmFormalParameterElements extends AbstractParserRuleElementFin
private final Assignment cParameterTypeAssignment_3 = (Assignment)cGroup.eContents().get(3);
private final RuleCall cParameterTypeJvmTypeReferenceParserRuleCall_3_0 = (RuleCall)cParameterTypeAssignment_3.eContents().get(0);

//// Formal parameter declaration according to the SARL syntax (not the Xtext/Xtend)
//FullJvmFormalParameter xtend::XtendFormalParameter:
//@ Override FullJvmFormalParameter xtend::XtendFormalParameter:
// extension?='extension'? name=ValidID ':' parameterType=JvmTypeReference;
@Override public ParserRule getRule() { return rule; }

Expand Down Expand Up @@ -5025,8 +5019,7 @@ public class XForLoopExpressionElements extends AbstractParserRuleElementFinder
private final RuleCall cEachExpressionXExpressionParserRuleCall_3_0_0 = (RuleCall)cEachExpressionAssignment_3_0.eContents().get(0);
private final Keyword cSemicolonKeyword_3_1 = (Keyword)cAlternatives_3.eContents().get(1);

//// The type of the for-loop's variable is following the SARL syntax (not the Xtext/Xtend)
//XForLoopExpression xbase::XExpression:
//@ Override XForLoopExpression xbase::XExpression:
// => ({xbase::XForLoopExpression}
// 'for' '(' declaredParam=SarlXLoopFormalParameter ':') forExpression=XExpression ')' (eachExpression=XExpression |
// ';');
Expand Down Expand Up @@ -5164,8 +5157,7 @@ public class XSwitchExpressionElements extends AbstractParserRuleElementFinder {
private final RuleCall cDefaultXExpressionParserRuleCall_5_2_0 = (RuleCall)cDefaultAssignment_5_2.eContents().get(0);
private final Keyword cRightCurlyBracketKeyword_6 = (Keyword)cGroup.eContents().get(6);

//// The type of the switch's variable is following the SARL syntax (not the Xtext/Xtend)
//XSwitchExpression xbase::XExpression:
//@ Override XSwitchExpression xbase::XExpression:
// {xbase::XSwitchExpression}
// 'switch' (=> ('(' declaredParam=JvmFormalParameter '=') switch=XExpression ')'
// | => (declaredParam=JvmFormalParameter '=')? switch=XExpression) '{'
Expand Down Expand Up @@ -5380,7 +5372,7 @@ public ParserRule getSarlScriptRule() {
return getSarlScriptAccess().getRule();
}

//Type xtend::XtendTypeDeclaration:
//@ Override Type xtend::XtendTypeDeclaration:
// {xtend::XtendTypeDeclaration} annotations+=XAnnotation* ({SarlEvent.annotationInfo=current} modifiers+=CommonModifier*
// 'event' name=ValidID ('extends' extends=JvmParameterizedTypeReference)? ('{' members+=EventMember* '}')?
// | {SarlCapacity.annotationInfo=current} modifiers+=CommonModifier*
Expand Down Expand Up @@ -5515,8 +5507,7 @@ public ParserRule getAOPMemberRule() {
return getAOPMemberAccess().getRule();
}

//// Members for the object-oriented types
//Member xtend::XtendMember:
//@ Override Member xtend::XtendMember:
// {xtend::XtendMember} annotations+=XAnnotation* ({SarlField.annotationInfo=current} modifiers+=CommonModifier*
// (modifiers+='extension' (modifiers+=FieldModifier | modifiers+=CommonModifier)*
// name=ValidID ':' type=JvmTypeReference
Expand Down Expand Up @@ -5561,7 +5552,7 @@ public ParserRule getMemberRule() {
return getMemberAccess().getRule();
}

//AnnotationField xtend::XtendMember:
//@ Override AnnotationField xtend::XtendMember:
// {xtend::XtendMember} annotations+=XAnnotation* ({SarlField.annotationInfo=current} modifiers+=CommonModifier*
// modifiers+=FieldModifier
// modifiers+=CommonModifier*
Expand Down Expand Up @@ -5589,7 +5580,7 @@ public ParserRule getAnnotationFieldRule() {
return getAnnotationFieldAccess().getRule();
}

//Parameter xtend::XtendParameter:
//@ Override Parameter xtend::XtendParameter:
// {SarlFormalParameter} annotations+=XAnnotation* (extension?='extension' annotations+=XAnnotation*)?
// name=ValidID ':' parameterType=JvmTypeReference (varArg?='*' | '=' defaultValue=XExpression)?;
public ParameterElements getParameterAccess() {
Expand All @@ -5600,7 +5591,7 @@ public ParserRule getParameterRule() {
return getParameterAccess().getRule();
}

//XtendEnumLiteral xtend::XtendEnumLiteral:
//@ Override XtendEnumLiteral xtend::XtendEnumLiteral:
// {SarlEnumLiteral} name=ValidID;
public XtendEnumLiteralElements getXtendEnumLiteralAccess() {
return pXtendEnumLiteral;
Expand All @@ -5621,10 +5612,7 @@ public ParserRule getBreakExpressionRule() {
return getBreakExpressionAccess().getRule();
}

////-----------------------------------------------
//// BELOW THIS POINT, THE RULES FROM XTEXT ARE OVERLOADED
//// Variable declaration according to the SARL syntax (not the Xtext/Xtend)
//XPrimaryExpression xbase::XExpression:
//@ Override XPrimaryExpression xbase::XExpression:
// XConstructorCall | XBlockExpression | XSwitchExpression | XSynchronizedExpression | XFeatureCall | XLiteral |
// XIfExpression | XForLoopExpression | XBasicForLoopExpression | XWhileExpression | XDoWhileExpression |
// XThrowExpression | XReturnExpression | XTryCatchFinallyExpression | XParenthesizedExpression | BreakExpression;
Expand All @@ -5636,7 +5624,7 @@ public ParserRule getXPrimaryExpressionRule() {
return getXPrimaryExpressionAccess().getRule();
}

//XVariableDeclaration xbase::XExpression:
//@ Override XVariableDeclaration xbase::XExpression:
// => ({xtend::XtendVariableDeclaration} ((writeable?='var' | 'val') extension?='extension'?
// | extension?='extension' (writeable?='var' | 'val'))) name=ValidID (':' type=JvmTypeReference)? ('='
// right=XExpression)?;
Expand All @@ -5648,8 +5636,7 @@ public ParserRule getXVariableDeclarationRule() {
return getXVariableDeclarationAccess().getRule();
}

//// Formal parameter declaration according to the SARL syntax (not the Xtext/Xtend)
//JvmFormalParameter xtend::XtendFormalParameter:
//@ Override JvmFormalParameter xtend::XtendFormalParameter:
// extension?='extension'? name=ValidID (=> ':' parameterType=JvmTypeReference)?;
public JvmFormalParameterElements getJvmFormalParameterAccess() {
return pJvmFormalParameter;
Expand All @@ -5659,8 +5646,7 @@ public ParserRule getJvmFormalParameterRule() {
return getJvmFormalParameterAccess().getRule();
}

//// Formal parameter declaration according to the SARL syntax (not the Xtext/Xtend)
//FullJvmFormalParameter xtend::XtendFormalParameter:
//@ Override FullJvmFormalParameter xtend::XtendFormalParameter:
// extension?='extension'? name=ValidID ':' parameterType=JvmTypeReference;
public FullJvmFormalParameterElements getFullJvmFormalParameterAccess() {
return pFullJvmFormalParameter;
Expand All @@ -5670,8 +5656,7 @@ public ParserRule getFullJvmFormalParameterRule() {
return getFullJvmFormalParameterAccess().getRule();
}

//// The type of the for-loop's variable is following the SARL syntax (not the Xtext/Xtend)
//XForLoopExpression xbase::XExpression:
//@ Override XForLoopExpression xbase::XExpression:
// => ({xbase::XForLoopExpression}
// 'for' '(' declaredParam=SarlXLoopFormalParameter ':') forExpression=XExpression ')' (eachExpression=XExpression |
// ';');
Expand All @@ -5695,8 +5680,7 @@ public ParserRule getSarlXLoopFormalParameterRule() {
return getSarlXLoopFormalParameterAccess().getRule();
}

//// The type of the switch's variable is following the SARL syntax (not the Xtext/Xtend)
//XSwitchExpression xbase::XExpression:
//@ Override XSwitchExpression xbase::XExpression:
// {xbase::XSwitchExpression}
// 'switch' (=> ('(' declaredParam=JvmFormalParameter '=') switch=XExpression ')'
// | => (declaredParam=JvmFormalParameter '=')? switch=XExpression) '{'
Expand Down

0 comments on commit a5f4775

Please sign in to comment.