Code::Blocks

User forums => Using Code::Blocks => Topic started by: Quiss on January 04, 2020, 10:49:33 am

Title: lexer_python update for f-strings
Post by: Quiss on January 04, 2020, 10:49:33 am
Default colours for f-strings are same as normal strings (single quote, double quote, triple single, triple double).
Code: [Select]
src/sdk/resources/lexers/lexer_python.xml | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/sdk/resources/lexers/lexer_python.xml b/src/sdk/resources/lexers/lexer_python.xml
index 1b006ad20..145af46c8 100644
--- a/src/sdk/resources/lexers/lexer_python.xml
+++ b/src/sdk/resources/lexers/lexer_python.xml
@@ -56,6 +56,18 @@
                 <Style name="Decorator"
                         index="15"
                         fg="0,128,128"/>
+                <Style name="Double quote f-string"
+                        index="16"
+                        fg="0,0,255"/>
+                <Style name="Single quote f-string"
+                        index="17"
+                        fg="224,160,0"/>
+                <Style name="Triple single quote f-string"
+                        index="18"
+                        fg="128,0,0"/>
+                <Style name="Triple double quote f-string"
+                        index="19"
+                        fg="128,0,128"/>
                 <Style name="Breakpoint line"
                         index="-2"
                         bg="255,160,160"/>

Code: [Select]
src/sdk/resources/lexers/lexer_python.sample | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/sdk/resources/lexers/lexer_python.sample b/src/sdk/resources/lexers/lexer_python.sample
index 1ef0f06e1..dfbafeaa8 100644
--- a/src/sdk/resources/lexers/lexer_python.sample
+++ b/src/sdk/resources/lexers/lexer_python.sample
@@ -11,6 +11,11 @@ month_names = ['Januari', 'Februari', 'Maart',      # These are the
 if len(sys.argv)!=2:
     print '''Usage: This is a 'Code::Blocks' Example'''
     print "This String goes to EOL
+    var = 5
+    print (f'Single quote f-string {var}')
+    print (f"Double quote f-string {var}")
+    print (f'''Triple single quote f-string {var}''')
+    print (f"""Triple double quote f-string {var}""")
     sys.exit(0)
 
 class ClassName:
Title: Re: lexer_python update for f-strings
Post by: oBFusCATed on January 04, 2020, 01:13:51 pm
In svn thanks.