mirror of
https://github.com/felixangell/phi.git
synced 2024-08-16 19:20:21 +03:00
added little shortcut hooking system thing
This commit is contained in:
parent
8832ff8a8f
commit
3d49b5ecee
@ -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
11
gui/shortcuts.go
Normal file
@ -0,0 +1,11 @@
|
||||
package gui
|
||||
|
||||
func Save(b *Buffer) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func DeleteLine(b *Buffer) bool {
|
||||
panic("unimplemented! :(")
|
||||
return true
|
||||
}
|
Loading…
Reference in New Issue
Block a user