-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slash Commands for keybindings #441
Changes from 3 commits
dd24323
4ece667
5c9a820
54295ff
5737425
031469b
8884d5f
3490dcb
7ee5cb5
deee5b7
db01ee9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,6 +171,9 @@ func init() { | |
registerCmdFn("reset:cwd", ResetCwdCommand) | ||
registerCmdFn("signal", SignalCommand) | ||
registerCmdFn("sync", SyncCommand) | ||
registerCmdFn("sleep", SleepCommand) | ||
|
||
registerCmdFn("mainview", MainViewCommand) | ||
|
||
registerCmdFn("session", SessionCommand) | ||
registerCmdFn("session:open", SessionOpenCommand) | ||
|
@@ -3560,6 +3563,45 @@ func SessionSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (s | |
return update, nil | ||
} | ||
|
||
func SleepCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (scbus.UpdatePacket, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about this |
||
if len(pk.Args) < 1 { | ||
return nil, fmt.Errorf("no argument found - usage: /sleep [ms]") | ||
} | ||
sleepArg := pk.Args[0] | ||
sleepArgInt, err := strconv.Atoi(sleepArg) | ||
if err != nil { | ||
return nil, fmt.Errorf("couldn't parse sleep arg: %v", err) | ||
} | ||
if sleepArgInt > 1000 { | ||
return nil, fmt.Errorf("sleep arg is too long, max value is 1000") | ||
} | ||
time.Sleep(time.Duration(sleepArgInt) * time.Millisecond) | ||
update := scbus.MakeUpdatePacket() | ||
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) { | ||
ids, err := resolveUiIds(ctx, pk, 0) | ||
if err != nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using
,
separator, whitespace or\n
is allowed and ignored