Module keywords
Syntax highlite keywords.
Add keywords to taste. Note, that we are cheating here, as the coloring sub system does not parse the file, marely does a string compare. For example ' len(' is unlikely to appear in any context but in it's intended place. Note that '=len(xx)' is not highlited but '= len(xx)' is. Add strings that match your coding style or your language. It is feasible to have a set of keywords that cover multiple languages. (like # (hash) for bash, perl, python …)
Also note that coloring too much distracts from readability, so configure this conservatively.
Expand source code
#!/usr/bin/env python
# Global keyword configuration for pyedpro.
# ------------------------------------------------------------------------
__doc__ = '''
Syntax highlite keywords.
Add keywords to taste. Note, that we are cheating here, as the
coloring sub system does not parse the file, marely does a string
compare. For example ' len(' is unlikely to appear in any context
but in it's intended place. Note that '=len(xx)' is not highlited but
'= len(xx)' is. Add strings that match your coding style or your
language. It is feasible to have a set of keywords that cover
multiple languages. (like # (hash) for bash, perl, python ...)
Also note that coloring too much distracts from readability, so
configure this conservatively.
'''
# Keywords for Python coloring (this is in effect for .sh .c ... etc):
keywords = ("def ", "import ", "from ", "for ", "while ", " len(",
"return ", "range(", "if ", "if(", "elif ", "not ", " abs(",
" any(", " all(", " min(", " max(", " map(", " print(",
" open(", " in ", " break ", "[]", "()", "{}", " pass",
"pass ", " pass ", "True", " False", "True;", "False;",
"true", "false", "global ", "else:", "continue", "None",
"<tr ", "<tr>", "</tr>", "<td ", "<td>", "</td>" )
# Keywords for class related enrties:
clwords = ("class ", " self.", "try:", "except", "except:", "finally",
"table ", "/table",)
# Keywords for summary extraction: (left side window)
basekeywords = ("(sub )|(SUB )")
basewalk = ("(sub )|(SUB )")
cwalk = "^[_a-zA-Z].*\(.*\)"
asmwalk = "^[_a-zA-Z].*:"
asmkeywords = "(^[_a-zA-Z].*:)|(\.bss)|(\.text)|(\.macro)|(\%if )|(%else)|(\%endif)"
asmkeywords2 = "(^[_a-zA-Z].*:)|(jmp )|(ret )"
pykeywords = ("class ", "def ")
pykeywords2 = "(class )|(def )|(__main__)"
pykeywords3 = "(_mac_)"
pykeywords4 = "(def )|(for )|(while )|(return )|(import )|(def )"
pywalk = "class"
sumkeywords = "class ", "def ", "TODO "
htmlkeywords = "(\{ .* \})"
ckeywords = "^[_a-zA-Z].*\(.*\)"
ckeywords2 = "(int .*)|(char .*)|(for )|(while )|(if )|(return )"
vwalk = "module"
vkeywords = "(module )|(endmodule )|(import )(always)"
vkeywords2 = "(if )|(else )|(end )|(wire )|(input )(output )"
commwords = "*.c", ".h", ".h", ".y", ".l", ".f", ".v"
'''
Keywords for auto correct. This corrects strings as we type.
Auto correct is case sensitive.
As a 'C' programmer I kept typing "else" in python ... this feature
corrects it to "else: " (the trailing colon for python)
It is contra indicatory to support bad habits, but for productivity ...
all is forgiven. Especially if one's next assignment is back to 'C'
Make sure to_str is longer than from_str (if shorter ... why correct?)
Ctrl-m to toggle autocorrect (default: off)
Syntax: (from_str, to_str), ....
'''
auto_corr_table = \
[ ( "else", "else: " ),
( "whi", "while " ),
( "Tr", "True " ),
( "Fa", "False " ),
( "bre", "break" ),
( "short", "sh " ),
# One can do unconventional things here:
( "Fn", "def funcname(): " ),
( "If", "if val: action else: action2 " ),
# No control chars, text only
#( "Bad", "if val: \n " ),
]
# These files are colored by default (add extension if needed)
color_files = (".py", ".c", ".cpp", ".sh", ".pl", ".h", ".hpp",
".js", ".php", ".f", ".y", ".pc", ".asm",
".inc", ".asm", ".bas", ".s", ".html",
".v", ".ino")
# These files are considered 'c' like (for basic syntax highlites)
c_like_exts = ( ".js", ".c", ".h", ".php", ".ino", ".sh")
# EOF
Global variables
var commwords-
Keywords for auto correct. This corrects strings as we type. Auto correct is case sensitive. As a 'C' programmer I kept typing "else" in python … this feature corrects it to "else: " (the trailing colon for python) It is contra indicatory to support bad habits, but for productivity … all is forgiven. Especially if one's next assignment is back to 'C'
Make sure to_str is longer than from_str (if shorter … why correct?) Ctrl-m to toggle autocorrect (default: off)
Syntax: (from_str, to_str), ....