added little shortcut hooking system thing

This commit is contained in:
Felix Angell 2018-02-28 00:22:30 +00:00
parent 8832ff8a8f
commit 3d49b5ecee
2 changed files with 24 additions and 2 deletions

View File

@ -106,6 +106,11 @@ var shiftAlternative = map[rune]rune{
'§': '±',
}
var shortcuts = map[rune]func(*Buffer) bool{
's': Save,
'd': DeleteLine,
}
func (b *Buffer) processTextInput(r rune) bool {
if CAPS_LOCK {
if unicode.IsLetter(r) {
@ -113,6 +118,12 @@ func (b *Buffer) processTextInput(r rune) bool {
}
}
if SUPER_DOWN {
if proc, ok := shortcuts[unicode.ToLower(r)]; ok {
return proc(b)
}
}
if SHIFT_DOWN {
// if it's a letter convert to uppercase
if unicode.IsLetter(r) {
@ -191,7 +202,7 @@ func (b *Buffer) deletePrev() {
}
}
func (b *Buffer) deleteLine() {
func (b *Buffer) deleteBeforeCursor() {
// delete so we're at the end
// of the previous line
if b.curs.x == 0 {
@ -256,7 +267,7 @@ func (b *Buffer) processActionKey(key int) bool {
return true
case sdl.K_BACKSPACE:
if SUPER_DOWN {
b.deleteLine()
b.deleteBeforeCursor()
} else {
b.deletePrev()
}

11
gui/shortcuts.go Normal file
View File

@ -0,0 +1,11 @@
package gui
func Save(b *Buffer) bool {
return false
}
func DeleteLine(b *Buffer) bool {
panic("unimplemented! :(")
return true
}