Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: syntax highlighting for jinja2 and change theme in editor #1200

Merged
merged 34 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c960131
First hacky attempt at jinja2 parsing in klipper configs
Sep 1, 2022
39155ce
jinja2 string fix
Sep 1, 2022
8de8c0b
cleaner jinja2 parsing fix, new tags / colors
Sep 1, 2022
9ac4225
added filter highlighting, some RegExp cleanup, refractoring
Sep 1, 2022
fde46e5
clean up cruft
Sep 2, 2022
985f984
clean up cruft #2
Sep 2, 2022
698fbb9
more jinja2 keywords, better regex
Sep 11, 2022
863568a
Merge branch 'mainsail-crew:develop' into th-jinja
truckershitch Sep 11, 2022
670e9f8
regex fix
Sep 11, 2022
1eda82d
SPKConfig: regex fix in klipper_config(), jinja2Element()
Sep 12, 2022
d1171f7
fix: added eatWhile() to jinja2Element()
Sep 12, 2022
b9cf926
refactored jinja2Element, reOperator tweak
Sep 13, 2022
53dd652
added space to updateOperator "peek" check array
Sep 13, 2022
5f92f90
added a comma to updateOperator "peek" check array - may need more ch…
Sep 13, 2022
ba86a4b
Amended number regex for better tagging
Sep 13, 2022
e4ab241
Refactored jinja tags (stacks) / variables / strings, other fixes
Sep 15, 2022
2cd862c
Merge branch 'mainsail-crew:develop' into th-jinja
truckershitch Sep 15, 2022
a19ef83
Merge branch 'mainsail-crew:develop' into th-jinja
truckershitch Sep 25, 2022
d7ab4b4
Fix for enquoted escaped quotes
Sep 26, 2022
3b3c020
Better fix for enquoted escaped quotes
Sep 27, 2022
de40952
Merge branch 'mainsail-crew:develop' into th-jinja
truckershitch Oct 16, 2022
51deea9
Merge branch 'mainsail-crew:develop' into th-jinja
truckershitch Nov 15, 2022
a5f2714
Merge branch 'mainsail-crew:develop' into th-jinja
truckershitch Dec 19, 2022
8f37b26
Merge branch 'mainsail-crew:develop' into th-jinja
truckershitch Feb 11, 2023
a6e10d7
Merge branch 'develop' into th-jinja
meteyou Feb 18, 2023
95d5078
style: run prettier to format code
meteyou Feb 18, 2023
6c4860c
Merge branch 'mainsail-crew:develop' into th-jinja
truckershitch Feb 19, 2023
221a563
Merge branch 'mainsail-crew:develop' into th-jinja
truckershitch Mar 13, 2023
ab58bdb
Merge branch 'develop' into th-jinja
meteyou Apr 4, 2023
a779fc5
refactor: remove unused comments/code
meteyou Apr 4, 2023
1fa03e8
feat: add new theme
meteyou Apr 4, 2023
568c127
refactor: remove unused files
meteyou Apr 4, 2023
7279d00
Merge branch 'develop' into th-jinja
meteyou May 18, 2023
74c4f51
refactor: change function to getter in Codemirror.vue to get the tabSize
meteyou May 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ temp
package-lock.json
*.local
.env
.vscode

cypress/screenshots/
cypress/videos/
Expand Down
42 changes: 42 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@sindarius/gcodeviewer": "^3.2.2",
"@types/node": "^18.0.0",
"@types/overlayscrollbars": "^1.12.1",
"@uiw/codemirror-theme-vscode": "^4.19.11",
"axios": "^0.27.0",
"codemirror": "^6.0.1",
"core-js": "^3.16.0",
Expand Down
9 changes: 5 additions & 4 deletions src/components/inputs/Codemirror.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import BaseMixin from '../mixins/base'
import { basicSetup } from 'codemirror'
import { EditorView, keymap } from '@codemirror/view'
import { EditorState } from '@codemirror/state'
import { mainsailTheme } from '@/plugins/codemirrorTheme'
import { vscodeDark } from '@uiw/codemirror-theme-vscode'
import { StreamLanguage } from '@codemirror/language'
import { klipper_config } from '@/plugins/StreamParserKlipperConfig'
import { gcode } from '@/plugins/StreamParserGcode'
Expand Down Expand Up @@ -82,9 +82,10 @@ export default class Codemirror extends Mixins(BaseMixin) {

get cmExtensions() {
const extensions = [
EditorView.theme({}, { dark: true }),
basicSetup,
mainsailTheme,
indentUnit.of(' '.repeat(this.getTabSize())),
vscodeDark,
indentUnit.of(' '.repeat(this.tabSize)),
keymap.of([indentWithTab]),
EditorView.updateListener.of((update) => {
this.content = update.state?.doc.toString()
Expand All @@ -106,7 +107,7 @@ export default class Codemirror extends Mixins(BaseMixin) {
if (isVisible) this.cminstance?.focus()
}

getTabSize() {
get tabSize() {
return this.$store.state.gui.editor.tabSize || 2
}
}
Expand Down
18 changes: 13 additions & 5 deletions src/plugins/StreamParserGcode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ export const gcode = {
/* Klipper macro attributes */
if (stream.pos > zeroPos && state.klipperMacro) {
stream.eatSpace()
if (stream.match(/^(".+"|true|false)/i)) {
if (stream.match(/^{/)) {
return 'tag'
}
// else if (stream.match(/^'|"/)) {
else if (stream.match(/^"[^{]+"/) || stream.match(/^'[^{]+'/)) {
return 'string'
} else if (stream.match(/^\d+/)) return 'number'
else if (stream.match(/^[A-Za-z\d_]+/)) return 'propertyName'
else if (zeroPos === 0 && stream.match(/^{[^%]+}/)) return 'variable'
} else if (stream.match(/^[-+]?[0-9]*\.?[0-9]+/)) {
return 'number'
} else if (stream.match(/^[A-Za-z\d_]+/)) {
return 'propertyName'
} else if (zeroPos === 0 && stream.match(/^{[^%]+}/)) {
return 'variable'
}
}

/* comments */
Expand All @@ -29,7 +37,7 @@ export const gcode = {
return 'namespace'
}

if (stream.string.substr(zeroPos).toLowerCase().startsWith('m117')) {
if (stream.string.substring(zeroPos).toLowerCase().startsWith('m117')) {
stream.skipToEnd()
return 'string'
}
Expand Down
144 changes: 0 additions & 144 deletions src/plugins/StreamParserJinja2.ts

This file was deleted.

Loading