Better g++ theme & localization
The g++ theme now check the locale to use unicode quotation mark if necessary. Start of error paragraphs are highlighted in green. Colout now use python3 for a simpler unicode support.
This commit is contained in:
parent
465ce93393
commit
fa76dcdf76
2 changed files with 29 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#encoding: utf-8
|
||||
|
||||
# Color Up Arbitrary Command Ouput
|
||||
|
|
|
|||
|
|
@ -1,16 +1,28 @@
|
|||
#encoding: utf-8
|
||||
|
||||
def theme():
|
||||
import gettext
|
||||
import os
|
||||
import gettext
|
||||
import locale
|
||||
|
||||
# get g++ version
|
||||
gv = os.popen("g++ -dumpversion").read().strip()
|
||||
|
||||
# get the current translations of gcc
|
||||
t = gettext.translation("gcc-"+gv)
|
||||
_ = t.ugettext
|
||||
_ = t.gettext
|
||||
# _("msg") will return the given message, translated
|
||||
|
||||
# if the locale is unicode
|
||||
enc = locale.getpreferredencoding()
|
||||
if "UTF" in enc:
|
||||
# gcc will use unicode quotes
|
||||
qo = "‘"
|
||||
qc = "’"
|
||||
else:
|
||||
# rather than ascii ones
|
||||
qo = "'"
|
||||
qc = "'"
|
||||
|
||||
return [
|
||||
[ _("error: "), "red", "bold" ],
|
||||
|
|
@ -18,11 +30,20 @@ def theme():
|
|||
[ _("note: "), "blue", "bold" ],
|
||||
# [-Wflag]
|
||||
[ "\[-W.*\]", "magenta"],
|
||||
# Filename:line number
|
||||
[ "(/.*?)/([^/]+\.)(h|cp*):([0-9]+):*([0-9]*)(.*)",
|
||||
"white,white,white,yellow,yellow,none",
|
||||
"normal,bold,bold,bold,normal" ],
|
||||
|
||||
# Highlight message start:
|
||||
# path file ext : line : col …
|
||||
[ "(/.*?)/([^/:]+): (In .*)"+qo,
|
||||
"green",
|
||||
"normal,normal,bold" ],
|
||||
|
||||
# Highlight locations:
|
||||
# path file ext : line : col …
|
||||
[ "(/.*?)/([^/:]+):([0-9]+):*([0-9]*)(.*)",
|
||||
"none,white,yellow,none,none",
|
||||
"normal,normal,normal,normal" ],
|
||||
|
||||
# source code in single quotes
|
||||
[ "'(.*?)'", "Cpp", "monokai" ]
|
||||
[ qo+"(.*?)"+qc, "Cpp", "monokai" ]
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue