Workspaces / document saving/opening
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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'))
|
||||
},
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user