From acf053b39efb2baca96849254824bd31feec2185 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Wed, 22 Mar 2023 16:33:48 +0100 Subject: [PATCH] TTCN theme --- website/src/js/handlers.ts | 2 ++ website/src/js/ttcn-theme.ts | 52 ++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 website/src/js/ttcn-theme.ts diff --git a/website/src/js/handlers.ts b/website/src/js/handlers.ts index 84d3b9bfa5..e279fdc992 100644 --- a/website/src/js/handlers.ts +++ b/website/src/js/handlers.ts @@ -8,6 +8,7 @@ import {defaultKeymap, history, historyKeymap, indentWithTab} from '@codemirror/ import {closeBrackets, closeBracketsKeymap} from '@codemirror/autocomplete' import {php} from '@codemirror/lang-php' import { PHPStanError } from './PHPStanError'; +import { ttcn } from './ttcn-theme'; const buildErrorLines = (doc: Text, lines: number[]) => { const errorLineDecoration = Decoration.line({class: 'bg-red-200/50 hover:bg-red-300/50'}); @@ -140,6 +141,7 @@ ko.bindingHandlers.codeMirror = { }), errorLines, hover, + ttcn, ], }) diff --git a/website/src/js/ttcn-theme.ts b/website/src/js/ttcn-theme.ts new file mode 100644 index 0000000000..83ab49b541 --- /dev/null +++ b/website/src/js/ttcn-theme.ts @@ -0,0 +1,52 @@ +import {HighlightStyle, syntaxHighlighting} from '@codemirror/language' +import {tags as t} from '@lezer/highlight' + +export const ttcnHighlightStyle = HighlightStyle.define([ + {tag: t.quote, + color: '#090'}, + {tag: t.deleted, + color: '#d44'}, + {tag: t.inserted, + color: '#292'}, + {tag: t.strong, + fontWeight: 'bold'}, + {tag: t.emphasis, + fontStyle: 'italic'}, + {tag: t.link, + color: '#00c', + textDecoration: 'underline'}, + {tag: t.strikethrough, + textDecoration: 'line-through'}, + {tag: t.heading, + fontWeight: 'bold', + color: '#00f'}, + + {tag: t.atom, + color: '#219'}, + {tag: t.attributeName, + color: '#00c'}, + {tag: t.comment, + color: '#333'}, + {tag: [t.definition(t.variableName), t.className], + color: '#00f'}, + {tag: t.invalid, + color: '#f00'}, + {tag: t.keyword, + fontWeight: 'bold'}, + {tag: t.meta, + color: '#555'}, + {tag: t.string, + color: '#060'}, + {tag: [t.special(t.string), t.escape, t.character], + color: '#f50'}, + {tag: t.tagName, + color: '#170'}, + {tag: t.variableName, + color: '#05a'}, + {tag: [t.function(t.variableName), t.special(t.variableName), t.local(t.variableName), t.typeName], + color: '#8b2252'}, + {tag: [t.self, t.labelName], + color: '#085'} +]) + +export const ttcn = syntaxHighlighting(ttcnHighlightStyle);