diff options
author | Ken Moore <ken@ixsystems.com> | 2017-06-09 22:30:00 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-06-09 22:30:00 -0400 |
commit | 47d278d6f45c0e82ec2efe7abc9ccc71b356e9df (patch) | |
tree | 3c7cd69dc97e3f158e0be802d68aa5923b7546ca /src-qt5 | |
parent | Merge branch 'master' of github.com:trueos/lumina (diff) | |
download | lumina-47d278d6f45c0e82ec2efe7abc9ccc71b356e9df.tar.gz lumina-47d278d6f45c0e82ec2efe7abc9ccc71b356e9df.tar.bz2 lumina-47d278d6f45c0e82ec2efe7abc9ccc71b356e9df.zip |
Get the new syntax rule system all setup and on-par (or better) than we had previously. Now we are all set for new rule sets to just be dropped in without worry about recompiling or anything.
Diffstat (limited to 'src-qt5')
8 files changed, 203 insertions, 5 deletions
diff --git a/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.desktop b/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.desktop index 6e806323..471f4985 100644 --- a/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.desktop +++ b/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.desktop @@ -5,6 +5,6 @@ Terminal=false Type=Application StartupNotify=true Categories=Utility; -MimeType=text/plain;text/x-log; +MimeType=text/plain;text/x-log;text/*; Name=Lumina Text Editor Comment=Plaintext editor with syntax highlighting diff --git a/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.pro b/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.pro index b2c4c4a4..9dfd8fea 100644 --- a/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.pro +++ b/src-qt5/desktop-utils/lumina-textedit/lumina-textedit.pro @@ -98,7 +98,10 @@ desktop.path=$${L_SHAREDIR}/applications/ link.path=$${L_BINDIR} link.extra=ln -sf lumina-textedit $(INSTALL_ROOT)$${L_BINDIR}/lte -INSTALLS += target desktop link +syntax.path=$${L_SHAREDIR}/lumina-desktop/syntax_rules +syntax.files=syntax_rules/* + +INSTALLS += target desktop link syntax WITH_I18N{ INSTALLS += dotrans diff --git a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp index 46ca056b..87592e6c 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp +++ b/src-qt5/desktop-utils/lumina-textedit/syntaxSupport.cpp @@ -118,12 +118,15 @@ bool SyntaxFile::LoadFile(QString file, QSettings *settings){ //Now load the appearance logic if(rule.contains("foreground")){ tmp.format.setForeground( colorFromOption(rule.value("foreground").toString(), settings) ); } if(rule.contains("background")){ tmp.format.setBackground( colorFromOption(rule.value("background").toString(), settings) ); } - if(rule.contains("font-weight")){ - QString wgt = rule.value("font-weight").toString(); + if(rule.contains("font_weight")){ + QString wgt = rule.value("font_weight").toString(); if(wgt =="bold"){ tmp.format.setFontWeight(QFont::Bold); } if(wgt =="light"){ tmp.format.setFontWeight(QFont::Light); } else{ tmp.format.setFontWeight(QFont::Normal); } } + if(rule.contains("font_style")){ + if(rule.value("font_style").toString()=="italic"){ tmp.format.setFontItalic(true); } + } //Now save the rule(s) to the list if(rule.contains("words")){ //special logic - this generates a bunch of rules all at once (one per word) diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/README.md b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/README.md index 0bd0616b..c2629e7c 100644 --- a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/README.md +++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/README.md @@ -25,7 +25,8 @@ A small comment section may be placed at the top of the file where every line st 3. At least **one** of the following fields should also be supplied: 1. "foreground" : Font color of the matching text (see the Colors section for additional information) 2. "background" : Highlighting color of the matching text (see the Colors section for additional information) - 3. "font-weight" : One of the following ["bold","normal", "light"]. Changes the thickness of the font for the matching text + 3. "font_weight" : One of the following ["bold","normal", "light"]. Changes the thickness of the font for the matching text + 4. "font_style" : One of the following ["italic", "normal"]. Change the style of the font fo the matching text. # Colors There are a number of built-in colors which may be defined by the user, and these can be used by passing in the following: diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/python.syntax b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/python.syntax new file mode 100644 index 00000000..f6d2223d --- /dev/null +++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/python.syntax @@ -0,0 +1,50 @@ +# Syntax support file for the Lumina Text Editor +# =================================== +# Python language support rules +# Written by Ken Moore <ken@ixsystems.com> +# Released under the 2-clause BSD license +# =================================== + +{ + "meta": { + "name": "Python (Experimental)", + "file_suffix": ["py", "pyc"] + }, + "format": { + "line_wrap": false, + "highlight_whitespace_eol": true + }, + "rules": [{ + "name": "single-line comment", + "regex": "#[^\n]*", + "foreground": "colors/comment" + }, + { + "name": "keywords", + "words": ["and" , "as" , "assert" , "break" , "class" , "continue" , "def" , "del" , "elif" , "else" , "except" , "exec" , "finally" , "for" , "from" , "global" , "if" , "import" , "in" , "is" , "lambda" , "not" , "or" , "pass" , "print" , "raise" , "return" , "try" , "while" , "with" , "yield"], + "foreground": "colors/keyword", + "font_weight": "bold" + }, + { + "name": "class names", + "regex": "\\bQ[A-Za-z]+\\b", + "foreground": "colors/class", + "font_weight": "bold" + }, + { + "name": "function names", + "regex": "\\b[A-Za-z0-9_]+(?=\\()", + "foreground": "colors/function" + }, + { + "name": "text", + "regex": "\"[^\"\\\\]*(\\\\(.|\\n)[^\"\\\\]*)*\"|'[^'\\\\]*(\\\\(.|\\n)[^'\\\\]*)*'", + "foreground": "colors/text" + }, + { + "name": "preprocessor", + "regex": "^[\\s]*#[^\n]*", + "foreground": "colors/preprocessor" + } + ] +} diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/rst.syntax b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/rst.syntax new file mode 100644 index 00000000..c8dfcca5 --- /dev/null +++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/rst.syntax @@ -0,0 +1,78 @@ +# Syntax support file for the Lumina Text Editor +# =================================== +# ReStructured Text language support rules +# Written by Ken Moore <ken@ixsystems.com> +# Released under the 2-clause BSD license +# =================================== + +{ + "meta": { + "name": "ReST", + "file_suffix": ["rst"] + }, + "format": { + "line_wrap": false, + "highlight_whitespace_eol" : true, + "columns_per_line" : 72, + "font_type" : "monospace" + }, + "rules": [{ + "name": "directives", + "regex": "(\\s|^):[a-zA-Z0-9 ]*:`[^`]*`", + "foreground": "colors/class", + "font_weight": "bold" + }, + { + "name": "hyperlinks", + "regex": "`[^\\<]*\\<[^\\>]*\\>`_", + "foreground": "colors/class", + "font_style": "italic" + }, + { + "name": "code sample", + "regex": "\\b`{2}.*`{2}\\b", + "font_weight": "light" + }, + { + "regex": "^\\.\\.\\sTODO\\b", + "font_weight" : "bold" + }, + { + "regex": "^(\\s*)\\.\\.(\\s*)([a-zA-Z0-9]+)::", + "font_weight" : "bold" + }, + { + "name" : "functions", + "regex" : "^(\\s*)\\.\\.(\\s*)\\b_[a-zA-Z0-9 ]*:(\\s|$)", + "foreground" : "colors/function" + }, + { + "name" : "figures", + "regex" : "^(\\s*)\\.\\.\\sfigure::\\s", + "foreground" : "colors/keyword" + }, + { + "name" : "properties", + "regex" : "^( ){3}:(.)*: ", + "foreground" : "colors/altkeyword" + }, + { + "name" : "code block type 1", + "regex_start" : "\\:\\:$", + "regex_end" : "^(?=[^\\s])", + "foreground" : "colors/text" + }, + { + "name" : "code block type 2", + "regex_start" : "^(\\s*)\\.\\.\\scode-block::\\s", + "regex_end" : "^(?=[^\\s])", + "foreground" : "colors/text" + }, + { + "name" : "comment", + "regex_start" : "^(\\s*)\\.\\.\\s[^_](?![\\w-_\\.]+::(\\s|$))", + "regex_end" : "^(?=([^\\s]|$))", + "foreground" : "colors/comment" + } + ] +} diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/sh.syntax b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/sh.syntax new file mode 100644 index 00000000..5f38cadc --- /dev/null +++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/sh.syntax @@ -0,0 +1,62 @@ +# Syntax support file for the Lumina Text Editor +# =================================== +# Bourne Shell language support rules +# Written by Ken Moore <ken@ixsystems.com> +# Released under the 2-clause BSD license +# =================================== + +{ + "meta": { + "name": "Shell", + "file_suffix": ["sh"] + }, + "format": { + "line_wrap": false, + "highlight_whitespace_eol": false + }, + "rules": [{ + "name": "preprocessor", + "regex": "^#![^\n]*", + "foreground": "colors/preprocessor" + }, + { + "name": "single-line comment", + "regex": "#[^\n]*", + "foreground": "colors/comment" + }, + { + "name": "keywords", + "words": ["alias" , "alloc" , "bg" , "bind" , " bindkey" , "break" , "breaksw","builtins","case","cd","chdir","command","complete","continue","default" ,"dirs","do","done","echo","echotc","elif","else","end","endif","endsw","esac","eval" ,"exec","exit","export","false","fc","fg","filetest","fi","for","foreach","getopts" ,"glob","goto","hash","hashstat","history","hup","if","in","jobid","jobs","kill","limit" ,"local","log","login","logout","ls-F","nice","nohup","notify","onintr","popd" ,"printenv","printf","pushd","pwd","read","readonly","rehash","repeat","return" ,"sched","set","setenv","settc","setty","setvar","shift","source","stop","suspend" ,"switch","telltc","test","then","time","times","trap","true","type","ulimit","umask" ,"unalias","uncomplete","unhash","unlimit","unset","unsetenv","until","wait" ,"where","which","while"], + "foreground": "colors/keyword", + "font_weight": "bold" + }, + { + "name": "class names", + "regex": "\\b[A-Za-z0-9_-\\.]+(?=::)\\b", + "foreground": "colors/class", + "font_weight": "bold" + }, + { + "name": "variable expansions", + "regex": "\\$[A-Za-z0-9_-\\.]+\\b", + "foreground": "colors/altkeyword", + "font_weight": "bold" + }, + { + "name": "variable expansions", + "regex": "\\$\\{[A-Za-z0-9_-\\.]+\\}", + "foreground": "colors/altkeyword", + "font_weight": "bold" + }, + { + "name": "function names", + "regex": "\\b[A-Za-z0-9_]+(?=\\()", + "foreground": "colors/function" + }, + { + "name": "text", + "regex": "\"[^\"\\\\]*(\\\\(.|\\n)[^\"\\\\]*)*\"|'[^'\\\\]*(\\\\(.|\\n)[^'\\\\]*)*'", + "foreground": "colors/text" + } + ] +} diff --git a/src-qt5/desktop-utils/lumina-textedit/tests/test.sh b/src-qt5/desktop-utils/lumina-textedit/tests/test.sh index 8eb7450c..c831197e 100644 --- a/src-qt5/desktop-utils/lumina-textedit/tests/test.sh +++ b/src-qt5/desktop-utils/lumina-textedit/tests/test.sh @@ -8,3 +8,4 @@ done variable$variable sdfgbuj variable${variable}satoibnsoin +some$variable |