Skip to content

Commit

Permalink
fix: set fontFamily to monospace to try fixing caret misplacement
Browse files Browse the repository at this point in the history
  • Loading branch information
kunish committed Jun 29, 2023
1 parent 5257da9 commit be95fe8
Showing 1 changed file with 103 additions and 0 deletions.
103 changes: 103 additions & 0 deletions src/constants/editor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { EditorProps } from '@monaco-editor/react'
import { languages } from 'monaco-editor'

export const EDITOR_THEME_DARK = 'vs-dark'
export const EDITOR_THEME_LIGHT = 'github'

export const EDITOR_OPTIONS: EditorProps['options'] = {
fontSize: 14,
fontWeight: 'bold',
fontFamily: 'monospace',
'semanticHighlighting.enabled': true,
lineHeight: 1.6,
minimap: {
enabled: false,
},
scrollBeyondLastLine: false,
renderWhitespace: 'selection',
cursorBlinking: 'solid',
formatOnPaste: true,
insertSpaces: true,
tabSize: 2,
lineNumbers: 'off',
padding: {
top: 8,
bottom: 8,
},
}

export const EDITOR_LANGUAGE_ROUTINGA: languages.IMonarchLanguage = {
// set defaultToken as `invalid` to turn on debug mode
// defaultToken: 'invalid',
ignoreCase: false,
keywords: [
'dip',
'direct',
'domain',
'dport',
'fallback',
'geoip',
'must_rules',
'geosite',
'ipversion',
'l4proto',
'mac',
'pname',
'qname',
'request',
'response',
'routing',
'sip',
'sport',
'tcp',
'udp',
'upstream',
],

escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,

symbols: /[->&!:,]+/,

operators: ['&&', '!'],

tokenizer: {
root: [
[/@[a-zA-Z]\w*/, 'tag'],
[/[a-zA-Z]\w*/, { cases: { '@keywords': 'keyword', '@default': 'identifier' } }],

{ include: '@whitespace' },

[/[{}()]/, '@brackets'],

[/@symbols/, { cases: { '@operators': 'operator', '@default': '' } }],

[/\d+/, 'number'],

[/[,:]/, 'delimiter'],

[/"([^"\\]|\\.)*$/, 'string.invalid'],
[/'([^'\\]|\\.)*$/, 'string.invalid'],
[/"/, 'string', '@string_double'],
[/'/, 'string', '@string_single'],
],

string_double: [
[/[^\\"]+/, 'string'],
[/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'],
[/"/, 'string', '@pop'],
],

string_single: [
[/[^\\']+/, 'string'],
[/@escapes/, 'string.escape'],
[/\\./, 'string.escape.invalid'],
[/'/, 'string', '@pop'],
],

whitespace: [
[/[ \t\r\n]+/, 'white'],
[/#.*$/, 'comment'],
],
},
}

0 comments on commit be95fe8

Please sign in to comment.