added control down/up for page down/up on mac

This commit is contained in:
Felix Angell 2018-05-12 19:18:21 +01:00
parent c610ac1a3f
commit 96cef8a0d7
4 changed files with 59 additions and 13 deletions

View File

@ -69,10 +69,10 @@ shortcut = "super+q"
shortcut = "super+s"
[commands.page_down]
shortcut = "super+down"
shortcut = "ctrl+down"
[commands.page_up]
shortcut = "super+up"
shortcut = "ctrl+up"
[commands.show_palette]
shortcut = "super+p"

View File

@ -69,9 +69,45 @@ func focusRight(v *View, commands []string) bool {
return false
}
func pageDown(v *View, commands []string) bool {
if v == nil {
return false
}
buff := v.getCurrentBuff()
if buff == nil {
return false
}
buff.scrollDown(DEFAULT_SCROLL_AMOUNT)
for i := 0; i < DEFAULT_SCROLL_AMOUNT; i++ {
buff.moveDown()
}
return false
}
func pageUp(v *View, commands []string) bool {
if v == nil {
return false
}
buff := v.getCurrentBuff()
if buff == nil {
return false
}
buff.scrollUp(DEFAULT_SCROLL_AMOUNT)
for i := 0; i < DEFAULT_SCROLL_AMOUNT; i++ {
buff.moveUp()
}
return false
}
var actions = map[string]BufferAction{
"focus_left": NewBufferAction("focus_left", focusLeft),
"focus_right": NewBufferAction("focus_right", focusRight),
"page_down": NewBufferAction("page_down", pageDown),
"page_up": NewBufferAction("page_up", pageUp),
"focus_left": NewBufferAction("focus_left", focusLeft),
"focus_right": NewBufferAction("focus_right", focusRight),
"goto": NewBufferAction("goto", GotoLine),
"new": NewBufferAction("new", NewFile),
"save": NewBufferAction("save", Save),

View File

@ -903,12 +903,12 @@ func (b *Buffer) processActionKey(key int) bool {
b.curs.move(-b.curs.x, 0)
}
// TODO remove since this is handled in the keymap!
case sdl.K_PAGEUP:
b.scrollUp(DEFAULT_SCROLL_AMOUNT)
for i := 0; i < DEFAULT_SCROLL_AMOUNT; i++ {
b.moveUp()
}
case sdl.K_PAGEDOWN:
b.scrollDown(DEFAULT_SCROLL_AMOUNT)
for i := 0; i < DEFAULT_SCROLL_AMOUNT; i++ {

View File

@ -138,17 +138,21 @@ func (n *View) OnUpdate() bool {
SUPER_DOWN = strife.KeyPressed(sdl.K_LGUI) || strife.KeyPressed(sdl.K_RGUI)
shortcutName := "ctrl"
mainSuper := CONTROL_DOWN
source := cfg.Shortcuts.Controls
// FIXME
if runtime.GOOS == "darwin" {
mainSuper = SUPER_DOWN
shortcutName = "super"
source = cfg.Shortcuts.Supers
}
if strife.PollKeys() && (SUPER_DOWN || CONTROL_DOWN) {
if runtime.GOOS == "darwin" {
if SUPER_DOWN {
source = cfg.Shortcuts.Supers
shortcutName = "super"
} else if CONTROL_DOWN {
source = cfg.Shortcuts.Controls
shortcutName = "control"
}
} else {
source = cfg.Shortcuts.Supers
}
if mainSuper && strife.PollKeys() {
r := rune(strife.PopKey())
if r == sdl.K_F12 {
@ -157,6 +161,8 @@ func (n *View) OnUpdate() bool {
left := 1073741904
right := 1073741903
up := 1073741906
down := 1073741905
// map to left/right/etc.
// FIXME
@ -166,6 +172,10 @@ func (n *View) OnUpdate() bool {
key = "left"
case right:
key = "right"
case up:
key = "up"
case down:
key = "down"
default:
key = string(unicode.ToLower(r))
}