Improved controls

This commit is contained in:
neauoire
2020-03-25 19:30:33 +09:00
parent 2387542efc
commit 12bba32b5d
4 changed files with 93 additions and 41 deletions

View File

@@ -47,7 +47,7 @@ function Client () {
this.acels.set('File', 'New', 'CmdOrCtrl+N', () => { this.source.new(); this.surface.clear(); this.commander.clear() })
this.acels.set('File', 'Save', 'CmdOrCtrl+S', () => { this.source.write('ronin', 'lisp', this.commander._input.value, 'text/plain') })
this.acels.set('File', 'Export Image', 'CmdOrCtrl+E', () => { this.source.write('ronin', 'png', this.surface.el.toDataURL('image/png', 1.0), 'image/png') })
this.acels.set('File', 'Open', 'CmdOrCtrl+O', () => { this.source.open('lisp', this.whenOpen) })
this.acels.set('File', 'Open', 'CmdOrCtrl+U', () => { this.source.open('lisp', this.whenOpen) })
this.acels.add('Edit', 'undo')
this.acels.add('Edit', 'redo')

View File

@@ -5,7 +5,6 @@
function Library (client) {
// IO
this.open = async (name, scale = 1) => { // Import a graphic and scale canvas to fit.
const img = client.cache.get(name)
if (!img) { client.log('No data for ' + name); return }
@@ -544,32 +543,6 @@ function Library (client) {
[-1, -1, -1]]
}
// File System
this.dir = (path = this.dirpath()) => { // Returns the content of a directory.
// return fs.existsSync(path) ? fs.readdirSync(path) : []
}
this.file = (path = this.filepath()) => { // Returns the content of a file.
// return fs.existsSync(path) ? fs.readFileSync(path, 'utf8') : ''
}
this.dirpath = (path = this.filepath()) => { // Returns the path of a directory.
// return require('path').dirname(path)
}
this.filepath = (path = client.source.path) => { // Returns the path of a file.
// return path
}
this.dirname = (path = this.filepath()) => { // Returns the name of a folder.
// return require('path').basename(require('path').dirname(path))
}
this.filename = (path = this.filepath()) => { // Returns the name of a file.
// return require('path').parse(path).name
}
this.offset = (a, b) => { // Offsets pos a with pos b, returns a.
a.x += b.x
a.y += b.y
@@ -580,6 +553,11 @@ function Library (client) {
return Math.sqrt(((a.x - b.x) * (a.x - b.x)) + ((a.y - b.y) * (a.y - b.y)))
}
this.print = (value) => {
client.source.write('ronin-print', 'txt', value, 'text/plain')
return value
}
this.echo = (...args) => { // Print arguments to interface.
client.log(args)
return args