diff options
Diffstat (limited to 'src-qt5/desktop-utils')
4 files changed, 183 insertions, 0 deletions
diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/html.syntax b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/html.syntax new file mode 100644 index 00000000..86909dcb --- /dev/null +++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/html.syntax @@ -0,0 +1,75 @@ +# Syntax support file for the Lumina Text Editor +# =================================== +# XML language support rules +# Written by Ken Moore <ken@ixsystems.com> +# Released under the 2-clause BSD license +# =================================== + +{ + "meta": { + "name": "HTML", + "file_suffix": ["html", "htm"] + }, + "format": { + "line_wrap": false, + "highlight_whitespace_eol" : true, + "columns_per_line" : 70, + "font_type" : "monospace", + "tab_width": 8 + }, + "rules": [{ + "name": "8 spaces rather than a tab", + "regex": "([ ]{8})+", + "background": "colors/bracket-missing" + }, + { + "name": "tabs after spaces", + "regex": "( )+\\t", + "background": "colors/bracket-missing" + }, + { + "name" : "odd number of spaces within indentation", + "regex": "(^|\\t)([ ]{2})*[ ](?=\\<)", + "background": "colors/bracket-missing" + }, + { + "name" : "ID of a tag", + "regex": "<[^> ]+[>]?", + "font_weight" : "bold", + "foreground" : "colors/function" + }, + { + "name" : "tag modifiers", + "regex" : "\\s[^\\= ]+(?=\\=)", + "foreground" : "colors/class" + }, + { + "name" : "strings inside a tag", + "regex": "\\\"[^\\\"]*\\\"", + "foreground" : "colors/text" + }, + { + "name" : "comment", + "regex_start" : "<!DOCTYPE", + "regex_end" : "[/]?>", + "foreground" : "colors/comment" + }, + { + "name" : "comment", + "regex_start" : "<!--", + "regex_end" : "-->", + "foreground" : "colors/comment" + }, + { + "name" : "escapes", + "regex" : "&[^;]*;", + "foreground" : "colors/preprocessor" + }, + { + "name" : "HTML preprocessor", + "regex_start" : "\\<\\?html ", + "regex_end" : "\\?>", + "foreground" : "colors/preprocessor" + } + ] +} diff --git a/src-qt5/desktop-utils/lumina-textedit/syntax_rules/javascript.syntax b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/javascript.syntax new file mode 100644 index 00000000..a10045d7 --- /dev/null +++ b/src-qt5/desktop-utils/lumina-textedit/syntax_rules/javascript.syntax @@ -0,0 +1,43 @@ +# Syntax support file for the Lumina Text Editor +# =================================== +# JSON language support rules +# Written by Ken Moore <ken@ixsystems.com> +# Released under the 2-clause BSD license +# =================================== + +{ + "meta": { + "name": "Javascript", + "file_suffix": ["js"] + }, + "format": { + "line_wrap": false, + "highlight_whitespace_eol" : false + }, + "rules": [{ + "name": "keywords", + "words": ["export","function", "import", "from", "let", "if", "return", "for", "while"], + "foreground": "colors/keyword" + }, + { + "name": "single-line comment", + "regex": "//[^\n]*", + "foreground": "colors/comment" + }, + { + "name": "numbers", + "regex": "\\b([0-9]+[\\.]?[0-9]?)+\\b", + "foreground": "colors/altkeyword" + }, + { + "name": "function names", + "regex": "\\b[A-Za-z0-9_]+(?=\\()|(?:\\.)[a-z]+", + "foreground": "colors/function" + }, + { + "name" : "text", + "regex": "\"[^\"\\\\]*(\\\\(.|\\n)[^\"\\\\]*)*\"|'[^'\\\\]*(\\\\(.|\\n)[^'\\\\]*)*'", + "foreground" : "colors/text" + } + ] +} diff --git a/src-qt5/desktop-utils/lumina-textedit/tests/test.html b/src-qt5/desktop-utils/lumina-textedit/tests/test.html new file mode 100644 index 00000000..a83618bc --- /dev/null +++ b/src-qt5/desktop-utils/lumina-textedit/tests/test.html @@ -0,0 +1,20 @@ +<!DOCTYPE html> + +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <title>Spoon-Knife</title> + <LINK href="styles.css" rel="stylesheet" type="text/css"> +</head> + +<body> + +<img src="forkit.gif" id="octocat" alt="" /> + +<!-- Feel free to change this text here --> +<p> + Fork me? Fork you, @octocat! +</p> + +</body> +</html> diff --git a/src-qt5/desktop-utils/lumina-textedit/tests/test.js b/src-qt5/desktop-utils/lumina-textedit/tests/test.js new file mode 100644 index 00000000..81361577 --- /dev/null +++ b/src-qt5/desktop-utils/lumina-textedit/tests/test.js @@ -0,0 +1,45 @@ +import { distance } from "./math.js"; +import { polygonCentroid } from "d3-polygon"; + +export default function(start, end) { + let distances = start.map(p1 => end.map(p2 => squaredDistance(p1, p2))), + order = bestOrder(start, end, distances); + + // Don't permute huge array + if (start.length > 8) { + return start.map((d, i) => i); + } + return bestOrder(start, end, distances); +} + +export function bestOrder(start, end, distances) { + let min = Infinity, + best = start.map((d, i) => i); + + function permute(arr, order = [], sum = 0) { + for (let i = 0; i < arr.length; i++) { + let cur = arr.splice(i, 1), + dist = distances[cur[0]][order.length]; + if (sum + dist < min) { + if (arr.length) { + permute(arr.slice(), order.concat(cur), sum + dist); + } else { + min = sum + dist; + best = order.concat(cur); + } + } + if (arr.length) { + arr.splice(i, 0, cur[0]); + } + } + } + + permute(best); + return best; +} + +function squaredDistance(p1, p2) { + let d = distance(polygonCentroid(p1), polygonCentroid(p2)); + return d * d; +} +(?:[a-z]+[\.])([a-z])+ |