diff --git a/index.html b/index.html deleted file mode 100644 index 2ae48b0..0000000 --- a/index.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - diff --git a/lib/codemirror.js b/lib/codemirror.js index 03224b5..8f96532 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -1,9 +1,9 @@ import { EditorState, Compartment, Transaction, Annotation } from '@codemirror/state' -import { indentWithTab, undo, redo, history, defaultKeymap, historyKeymap } from '@codemirror/commands' +import { indentWithTab, undo, redo, history, defaultKeymap, historyKeymap, indentMore, indentLess } from '@codemirror/commands' import { EditorView, lineNumbers, highlightActiveLineGutter, highlightSpecialChars, drawSelection, dropCursor, rectangularSelection, crosshairCursor, highlightActiveLine, keymap } from '@codemirror/view' import { foldGutter, indentOnInput, syntaxHighlighting, defaultHighlightStyle, bracketMatching, foldKeymap } from '@codemirror/language' import { highlightSelectionMatches, searchKeymap } from '@codemirror/search' -import { closeBrackets, autocompletion, closeBracketsKeymap, completionKeymap } from '@codemirror/autocomplete' +import { closeBrackets, autocompletion, closeBracketsKeymap, startCompletion, closeCompletion, acceptCompletion, moveCompletionSelection } from '@codemirror/autocomplete' import { lintKeymap } from '@codemirror/lint' export default { @@ -33,11 +33,17 @@ export default { searchKeymap, historyKeymap, foldKeymap, - completionKeymap, + // completionKeymap, lintKeymap, undo, redo, Transaction, Annotation, - defaultHighlightStyle + defaultHighlightStyle, + startCompletion, + closeCompletion, + moveCompletionSelection, + acceptCompletion, + indentMore, + indentLess } diff --git a/lib/platforms/neutralino.js b/lib/platforms/neutralino.js index 08d3722..94dbff2 100644 --- a/lib/platforms/neutralino.js +++ b/lib/platforms/neutralino.js @@ -1,16 +1,15 @@ -export default { - async access(path) { - try { - await Neutralino.filesystem.getStats(path) - return - } catch(err) { - if(err.name = 'NE_FS_NOPATHE') { - return false - } else { - throw err - } - } - }, +{ + +let userHome + +const handleNeutralinoError = err => { + throw new Error(err.code + ': ' + err.message) +} + +window.Platform = { + // + // Paths + // dirname(path) { let index = path.lastIndexOf('/') @@ -28,6 +27,51 @@ export default { let filename = this.filename(path) let index = filename.lastIndexOf('.') - return index === -1 ? '' : path.slice(index + 1) - } + return index === -1 ? '' : filename.slice(index + 1) + }, + + join(...args) { + return args.join('/') + }, + + // TODO: support non-posix + absolute(path) { + return path.charAt(0) === '/' + }, + + // + // FS + // + + async access(path) { + try { + await Neutralino.filesystem.getStats(path) + return + } catch(err) { + if(err.name = 'NE_FS_NOPATHE') { + return false + } else { + throw err + } + } + }, + + writeText(path, content) { + return Neutralino.filesystem.writeFile(path, content) + .catch(handleNeutralinoError) + }, + + readText(path) { + return Neutralino.filesystem.readFile(path) + .catch(handleNeutralinoError) + }, + + // + // OS + // + async getHome() { + return userHome ?? (userHome = await Neutralino.os.getEnv('HOME')) + }, +} + } \ No newline at end of file diff --git a/neutralino.config.json b/neutralino.config.json index c6df6d8..db32470 100644 --- a/neutralino.config.json +++ b/neutralino.config.json @@ -15,6 +15,7 @@ "nativeAllowList": [ "app.*", "os.*", + "filesystem.*", "debug.log" ], "globalVariables": {}, diff --git a/src/config.js b/src/config.js index 91a64aa..673dadc 100644 --- a/src/config.js +++ b/src/config.js @@ -8,6 +8,13 @@ landingDocument: { } }, +binds: { + reload: 'Ctrl-Escape', + editPath: 'Ctrl-r', + save: 'Ctrl-s', + open: 'Ctrl-o' +}, + languages: [ { exts: [ 'js', 'mjs', 'cjs', 'ejs' ], @@ -24,9 +31,7 @@ languages: [ name: 'md', import: './lib/markdown.js', createExtension({ markdown }) { - return markdown({ - - }) + return markdown() } } ] diff --git a/src/index.html b/src/index.html index c85ccd4..ec7df4f 100644 --- a/src/index.html +++ b/src/index.html @@ -2,12 +2,15 @@ + +