fixed logging/shortcuts on os x

This commit is contained in:
Felix Angell 2018-05-07 09:17:25 +01:00
parent 791b847926
commit 7e56f9af56
2 changed files with 18 additions and 9 deletions

View File

@ -360,9 +360,11 @@ func (b *Buffer) processTextInput(r rune) bool {
}
}
mainSuper := CONTROL_DOWN
mainSuper, shortcutName := CONTROL_DOWN, "ctrl"
source := cfg.Shortcuts.Controls
if runtime.GOOS == "darwin" {
mainSuper = SUPER_DOWN
mainSuper, shortcutName = SUPER_DOWN, "super"
source = cfg.Shortcuts.Supers
}
if mainSuper {
@ -381,13 +383,13 @@ func (b *Buffer) processTextInput(r rune) bool {
key = string(unicode.ToLower(r))
}
actionName, actionExists := cfg.Shortcuts.Supers[key]
actionName, actionExists := source[key]
if actionExists {
if action, ok := actions[actionName]; ok {
return action.proc(b.parent, []string{})
}
} else {
log.Println("warning, unimplemented shortcut ctrl+", unicode.ToLower(r), actionName)
log.Println("warning, unimplemented shortcut", shortcutName, "+", unicode.ToLower(r), "#", int(r), actionName)
}
}

View File

@ -1,12 +1,13 @@
package gui
import (
"github.com/felixangell/phi/cfg"
"github.com/felixangell/strife"
"github.com/veandco/go-sdl2/sdl"
"log"
"runtime"
"unicode"
"github.com/felixangell/phi/cfg"
"github.com/felixangell/strife"
"github.com/veandco/go-sdl2/sdl"
)
// View is an array of buffers basically.
@ -136,9 +137,15 @@ func (n *View) OnUpdate() bool {
CONTROL_DOWN = strife.KeyPressed(sdl.K_LCTRL) || strife.KeyPressed(sdl.K_RCTRL)
SUPER_DOWN = strife.KeyPressed(sdl.K_LGUI) || strife.KeyPressed(sdl.K_RGUI)
shortcutName := "ctl"
mainSuper := CONTROL_DOWN
source := cfg.Shortcuts.Controls
// FIXME
if runtime.GOOS == "darwin" {
mainSuper = SUPER_DOWN
shortcutName = "super"
source = cfg.Shortcuts.Supers
}
if mainSuper && strife.PollKeys() {
@ -159,14 +166,14 @@ func (n *View) OnUpdate() bool {
key = string(unicode.ToLower(r))
}
actionName, actionExists := cfg.Shortcuts.Controls[key]
actionName, actionExists := source[key]
if actionExists {
if action, ok := actions[actionName]; ok {
log.Println("Executing action '" + actionName + "'")
return action.proc(n, []string{})
}
} else {
log.Println("warning, unimplemented shortcut ctrl +", string(unicode.ToLower(r)), " #", int(r), actionName, key)
log.Println("view: unimplemented shortcut", shortcutName, "+", string(unicode.ToLower(r)), "#", int(r), actionName, key)
}
}