forked from BurntSushi/wingo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_hacks.go
41 lines (35 loc) · 907 Bytes
/
cmd_hacks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"fmt"
"github.com/alexanderkyte/wingo/commands"
"github.com/alexanderkyte/wingo/wm"
)
func newHacks() wm.CommandHacks {
return wm.CommandHacks{
MouseResizeDirection: mouseResizeDirection,
CycleClientRunWithKeyStr: cycleClientRunWithKeyStr,
}
}
func mouseResizeDirection(cmdStr string) (string, error) {
cmd, err := commands.Env.Command(cmdStr)
if err != nil {
return "", err
}
return cmd.(*commands.MouseResize).Direction, nil
}
func cycleClientRunWithKeyStr(keyStr, cmdStr string) (func(), error) {
var run func() = nil
cmd, err := commands.Env.Command(cmdStr)
if err != nil {
return nil, err
}
switch t := cmd.(type) {
case *commands.CycleClientNext:
run = func() { t.RunWithKeyStr(keyStr) }
case *commands.CycleClientPrev:
run = func() { t.RunWithKeyStr(keyStr) }
default:
panic(fmt.Sprintf("bug: unknown type %T", t))
}
return run, nil
}