mirror of
https://github.com/felixangell/phi.git
synced 2024-09-11 15:55:25 +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 {
|
func (b *Buffer) processTextInput(r rune) bool {
|
||||||
if CAPS_LOCK {
|
if CAPS_LOCK {
|
||||||
if unicode.IsLetter(r) {
|
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 SHIFT_DOWN {
|
||||||
// if it's a letter convert to uppercase
|
// if it's a letter convert to uppercase
|
||||||
if unicode.IsLetter(r) {
|
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
|
// delete so we're at the end
|
||||||
// of the previous line
|
// of the previous line
|
||||||
if b.curs.x == 0 {
|
if b.curs.x == 0 {
|
||||||
@ -256,7 +267,7 @@ func (b *Buffer) processActionKey(key int) bool {
|
|||||||
return true
|
return true
|
||||||
case sdl.K_BACKSPACE:
|
case sdl.K_BACKSPACE:
|
||||||
if SUPER_DOWN {
|
if SUPER_DOWN {
|
||||||
b.deleteLine()
|
b.deleteBeforeCursor()
|
||||||
} else {
|
} else {
|
||||||
b.deletePrev()
|
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