mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-04-01 17:57:31 +02:00
use new relative arguments for screen switching instead of computing it on FE
This commit is contained in:
parent
e75765ee11
commit
c3d3647111
37
src/model.ts
37
src/model.ts
@ -463,30 +463,6 @@ class Session {
|
||||
dispose() : void {
|
||||
}
|
||||
|
||||
getRelativeScreenId(rel : number) : string {
|
||||
if (!rel) {
|
||||
return this.activeScreenId.get();
|
||||
}
|
||||
if (this.screens.length == 0) {
|
||||
return null;
|
||||
}
|
||||
if (this.screens.length == 1) {
|
||||
return this.screens[0].screenId;
|
||||
}
|
||||
let foundIdx = 0;
|
||||
for (let i=0; i<this.screens.length; i++) {
|
||||
if (this.screens[i].screenId == this.activeScreenId.get()) {
|
||||
foundIdx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let relIdx = (foundIdx + rel) % this.screens.length;
|
||||
if (relIdx < 0) {
|
||||
relIdx += this.screens.length;
|
||||
}
|
||||
return this.screens[relIdx].screenId;
|
||||
}
|
||||
|
||||
// session updates only contain screens (no windows)
|
||||
mergeData(sdata : SessionDataType) {
|
||||
if (sdata.sessionid != this.sessionId) {
|
||||
@ -941,20 +917,15 @@ class Model {
|
||||
}
|
||||
|
||||
onBracketCmd(e : any, arg : {relative: number}, mods : KeyModsType) {
|
||||
console.log("switch screen (bracket)", arg, mods);
|
||||
let activeSession = this.getActiveSession();
|
||||
if (activeSession == null) {
|
||||
return;
|
||||
if (arg.relative == 1) {
|
||||
GlobalInput.switchScreen("+");
|
||||
}
|
||||
let newScreenId = activeSession.getRelativeScreenId(arg.relative);
|
||||
if (newScreenId == null) {
|
||||
return;
|
||||
else if (arg.relative == -1) {
|
||||
GlobalInput.switchScreen("-");
|
||||
}
|
||||
GlobalInput.switchScreen(newScreenId);
|
||||
}
|
||||
|
||||
onDigitCmd(e : any, arg : {digit: number}, mods : KeyModsType) {
|
||||
console.log("switch screen (digit)", arg, mods);
|
||||
GlobalInput.switchScreen(String(arg.digit));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user