mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-07 19:28:44 +01:00
added mainview slashcommand
This commit is contained in:
parent
dd24323296
commit
4ece667aaa
@ -42,11 +42,12 @@
|
|||||||
{
|
{
|
||||||
"command": "app:openConnectionsView",
|
"command": "app:openConnectionsView",
|
||||||
"keys": [],
|
"keys": [],
|
||||||
"commandStr": "/remote:show"
|
"commandStr": "/mainview connections"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "app:openSettingsView",
|
"command": "app:openSettingsView",
|
||||||
"keys": []
|
"keys": [],
|
||||||
|
"commandStr": "/mainview clientsettings"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "app:newTab",
|
"command": "app:newTab",
|
||||||
|
@ -240,10 +240,7 @@ class Model {
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
this.keybindManager.registerKeybinding("app", "model", "app:openConnectionsView", null);
|
this.keybindManager.registerKeybinding("app", "model", "app:openConnectionsView", null);
|
||||||
this.keybindManager.registerKeybinding("app", "model", "app:openSettingsView", (waveEvent) => {
|
this.keybindManager.registerKeybinding("app", "model", "app:openSettingsView", null);
|
||||||
this.onOpenSettingsViewPressed();
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static getInstance(): Model {
|
static getInstance(): Model {
|
||||||
@ -1005,6 +1002,12 @@ class Model {
|
|||||||
console.warn("invalid bookmarksview in update:", update.mainview);
|
console.warn("invalid bookmarksview in update:", update.mainview);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "clientsettings":
|
||||||
|
this.activeMainView.set("clientsettings");
|
||||||
|
break;
|
||||||
|
case "connections":
|
||||||
|
this.activeMainView.set("connections");
|
||||||
|
break;
|
||||||
case "plugins":
|
case "plugins":
|
||||||
this.pluginsModel.showPluginsView();
|
this.pluginsModel.showPluginsView();
|
||||||
break;
|
break;
|
||||||
|
@ -172,6 +172,8 @@ func init() {
|
|||||||
registerCmdFn("signal", SignalCommand)
|
registerCmdFn("signal", SignalCommand)
|
||||||
registerCmdFn("sync", SyncCommand)
|
registerCmdFn("sync", SyncCommand)
|
||||||
|
|
||||||
|
registerCmdFn("mainview", MainViewCommand)
|
||||||
|
|
||||||
registerCmdFn("session", SessionCommand)
|
registerCmdFn("session", SessionCommand)
|
||||||
registerCmdFn("session:open", SessionOpenCommand)
|
registerCmdFn("session:open", SessionOpenCommand)
|
||||||
registerCmdAlias("session:new", SessionOpenCommand)
|
registerCmdAlias("session:new", SessionOpenCommand)
|
||||||
@ -3560,6 +3562,28 @@ func SessionSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (s
|
|||||||
return update, nil
|
return update, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func MainViewCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus.UpdatePacket, error) {
|
||||||
|
if len(pk.Args) < 1 {
|
||||||
|
return nil, fmt.Errorf("no argument found - usage: /mainview [view]")
|
||||||
|
}
|
||||||
|
update := scbus.MakeUpdatePacket()
|
||||||
|
mainViewArg := pk.Args[0]
|
||||||
|
if mainViewArg == sstore.MainViewSession {
|
||||||
|
update.AddUpdate(&sstore.MainViewUpdate{MainView: sstore.MainViewSession})
|
||||||
|
} else if mainViewArg == sstore.MainViewConnections {
|
||||||
|
update.AddUpdate(&sstore.MainViewUpdate{MainView: sstore.MainViewConnections})
|
||||||
|
} else if mainViewArg == sstore.MainViewSettings {
|
||||||
|
update.AddUpdate(&sstore.MainViewUpdate{MainView: sstore.MainViewSettings})
|
||||||
|
} else if mainViewArg == sstore.MainViewHistory {
|
||||||
|
return nil, fmt.Errorf("use /history instead")
|
||||||
|
} else if mainViewArg == sstore.MainViewBookmarks {
|
||||||
|
return nil, fmt.Errorf("use /bookmarks instead")
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("unrecognized main view")
|
||||||
|
}
|
||||||
|
return update, nil
|
||||||
|
}
|
||||||
|
|
||||||
func SessionCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus.UpdatePacket, error) {
|
func SessionCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus.UpdatePacket, error) {
|
||||||
ids, err := resolveUiIds(ctx, pk, 0)
|
ids, err := resolveUiIds(ctx, pk, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -74,6 +74,8 @@ const (
|
|||||||
MainViewSession = "session"
|
MainViewSession = "session"
|
||||||
MainViewBookmarks = "bookmarks"
|
MainViewBookmarks = "bookmarks"
|
||||||
MainViewHistory = "history"
|
MainViewHistory = "history"
|
||||||
|
MainViewConnections = "connections"
|
||||||
|
MainViewSettings = "clientsettings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
Loading…
Reference in New Issue
Block a user