remote control: add /STATE/OPEN and /STATE/SAVE commands; ignore unsaved changes when loading a session with /SESSION/OPEN

This commit is contained in:
bordun 2020-10-21 10:31:24 +02:00
parent 9b21cd4865
commit 69831e9719
5 changed files with 45 additions and 3 deletions

View file

@ -1,5 +1,11 @@
# Changelog
## 1.5.4
- remote control
- add `/STATE/OPEN` and `/STATE/SAVE` commands
- ignore unsaved changes when loading a session with `/SESSION/OPEN`
## 1.5.3
- bug fixes

View file

@ -115,6 +115,11 @@ Replies `/GET address preArg1 preArg2 ... value`
Same as `/GET` but uses the widget's address instead of `/GET` to reply.
----
#### `/NOTIFY message`
Sends a notification message to the client.
----
@ -172,6 +177,18 @@ Reload saved state from the temporary slot.
----
#### `/STATE/OPEN path.state`
Open state file `path.state`.
----
#### `/STATE/SAVE path.state`
Save state session to `path.state`. If `path.state` is omitted, current session's path is used.
----
#### `/SESSION/OPEN path.json`
Open session file `path.json`.

View file

@ -133,7 +133,6 @@ var SessionManager = class SessionManager {
requestOpen(path) {
if (editor.unsavedSession && !confirm(locales('session_unsaved'))) return
ipc.send('sessionOpen', {path: path})
}
@ -145,7 +144,7 @@ var SessionManager = class SessionManager {
uiFilebrowser({extension: 'json', directory: this.lastDir}, (path)=>{
if (editor.unsavedSession && !confirm(locales('session_unsaved'))) return
this.lastDir = path[0]
ipc.send('sessionOpen',{path:path})
this.requestOpen(path)
})
}

View file

@ -112,11 +112,17 @@ var StateManager = class StateManager {
}
requestOpen(path) {
ipc.send('stateOpen', {path: path})
}
browse() {
uiFilebrowser({extension: 'state', directory: this.lastDir}, (path)=>{
this.lastDir = path[0]
ipc.send('stateOpen',{path: path})
this.requestOpen(path)
})
}

View file

@ -222,6 +222,20 @@ var callbacks = {
stateManager.quickLoad()
},
'/STATE/OPEN': function(args) {
if (!Array.isArray(args)) args = [args]
stateManager.requestOpen(args[0])
},
'/STATE/SAVE': function(args) {
if (!Array.isArray(args)) args = [args]
stateManager.save(args[0])
},
'/NOTIFY': function(args) {