diff --git a/app/renderer/src/main/src/utils/monacoSpec/theme.ts b/app/renderer/src/main/src/utils/monacoSpec/theme.ts index 3514e94200..fe764f4f22 100644 --- a/app/renderer/src/main/src/utils/monacoSpec/theme.ts +++ b/app/renderer/src/main/src/utils/monacoSpec/theme.ts @@ -18,7 +18,7 @@ monaco.editor.defineTheme("kurior", { "token": "libFunction", }, { - "foreground": "#ff0000", "background": "#cc7c22", + "foreground": "#ff0000", "token": "fuzz.tag.inner", fontStyle: "bold underline", }, { @@ -165,6 +165,18 @@ monaco.editor.defineTheme("kurior", { "background": "#c9d4be", "token": "string.regexp" }, + { + "foreground": "#B05A3C", + "token": "string.escape" + }, + { + "foreground": "#6A5ACD", + "token": "string.inline.expr" + }, + { + "foreground": "#FF0000", + "token": "string.invalid" + }, { "foreground": "#005273", "token": "support.function" diff --git a/app/renderer/src/main/src/utils/monacoSpec/yakEditor.ts b/app/renderer/src/main/src/utils/monacoSpec/yakEditor.ts index dec354a0aa..2e93f41a30 100644 --- a/app/renderer/src/main/src/utils/monacoSpec/yakEditor.ts +++ b/app/renderer/src/main/src/utils/monacoSpec/yakEditor.ts @@ -184,9 +184,20 @@ export const setUpYaklangMonaco = () => { }, [] as Array), digits: /\d+(_+\d+)*/, symbols: /[=> { }, ], - - - // whitespace { include: '@whitespace' }, @@ -247,18 +255,47 @@ export const setUpYaklangMonaco = () => { // delimiter: after number because of .\d floats [/[;,.]/, 'delimiter'], + + // characters [/'[^\\']'/, 'string'], [/(')(@escapes)(')/, ['string', 'string.escape', 'string']], // strings [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string + [/'([^'\\]|\\.)*$/, 'string.invalid'], // non-teminated string [/"/, 'string.quoted.double.js', '@string'], [/'/, 'string.quoted.single.js', '@string2'], [/`/, 'string', '@rawstring'], [/'/, 'string.invalid'], ], + fuzz_tag: [ + [/{{/, "fuzz.tag.inner", "@fuzz_tag_second"], + [/}}/, "fuzz.tag.inner", "@pop"], + [/[\w:]+}}/, "fuzz.tag.inner", "@pop"], + [/[\w:]+\(/, "fuzz.tag.inner", "@fuzz_tag_param"], + ], + fuzz_tag_second: [ + [/{{/, "fuzz.tag.second", "@fuzz_tag"], + [/}}/, "fuzz.tag.second", "@pop"], + [/[\w:]+}}/, "fuzz.tag.second", "@pop"], + [/[\w:]+\(/, "fuzz.tag.second", "@fuzz_tag_param_second"], + ], + fuzz_tag_param: [ + [/\(/, "fuzz.tag.inner", "@fuzz_tag_param"], + [/\\\)/, "bold-keyword"], + [/\)/, "fuzz.tag.inner", "@pop"], + [/{{/, "fuzz.tag.second", "@fuzz_tag_second"], + [/./, "bold-keyword"] + ], + fuzz_tag_param_second: [ + [/\\\)/, "bold-keyword"], + [/\)/, "fuzz.tag.second", "@pop"], + [/{{/, "fuzz.tag.inner", "@fuzz_tag"], + [/./, "bold-keyword"] + ], + whitespace: [ [/[ \t\r\n]+/, ''], @@ -285,20 +322,70 @@ export const setUpYaklangMonaco = () => { [/[\/*]/, 'comment.doc'] ], - string: [ + // disable fuzztag because of monaco editor bug + xrawstring: [ + // [/{{/, "fuzz.tag.inner", "@fuzz_tag"], + [/@escapes/, 'string.escape'], + [/[^`]/, 'string'], + [/`/, 'string', '@pop'] + ], + + xstring: [ + // [/{{/, "fuzz.tag.inner", "@fuzz_tag"], + [/@escapes/, 'string.escape'], [/[^\\"]+/, 'string'], + [/\\./, 'string.escape.invalid'], + [/"/, 'string', '@pop'] + ], + + xstring2: [ + // [/{{/, "fuzz.tag.inner", "@fuzz_tag"], [/@escapes/, 'string.escape'], + [/[^\\']/, 'string'], + [/'/, 'string', '@pop'] + ], + + + frawstring: [ + [/@escapes/, 'string.escape'], + [/@inlineExpr/, 'string.inline.expr'], + [/@invalidInlineExpr/, 'string.invalid'], + [/[^`]/, 'string'], + [/`/, 'string', '@pop'] + ], + + fstring: [ + [/@escapes/, 'string.escape'], + [/@inlineExpr/, 'string.inline.expr'], + [/@invalidInlineExpr/, 'string.invalid'], + [/[^\\"]+/, 'string'], [/\\./, 'string.escape.invalid'], [/"/, 'string', '@pop'] ], - string2: [ + fstring2: [ + [/@escapes/, 'string.escape'], + [/@inlineExpr/, 'string.inline.expr'], + [/@invalidInlineExpr/, 'string.invalid'], [/[^\\']/, 'string'], + [/'/, 'string', '@pop'] + ], + + string: [ + [/@escapes/, 'string.escape'], + [/[^\\"]+/, 'string'], + [/\\./, 'string.invalid'], + [/"/, 'string', '@pop'] + ], + + string2: [ [/@escapes/, 'string.escape'], + [/[^\\']/, 'string'], [/'/, 'string', '@pop'] ], rawstring: [ + [/@escapes/, "string.escape"], [/[^`]/, 'string'], [/`/, 'string', '@pop'] ],