mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-24 01:08:10 +02:00
Reset keyboard state when resetting text
This commit is contained in:
@@ -203,6 +203,7 @@ func (self *Readline) ResetText() {
|
|||||||
self.cursor = Position{}
|
self.cursor = Position{}
|
||||||
self.cursor_y = 0
|
self.cursor_y = 0
|
||||||
self.last_action = ActionNil
|
self.last_action = ActionNil
|
||||||
|
self.keyboard_state = KeyboardState{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Readline) ChangeLoopAndResetText(lp *loop.Loop) {
|
func (self *Readline) ChangeLoopAndResetText(lp *loop.Loop) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ type ShortcutMap struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type KeyboardState struct {
|
type KeyboardState struct {
|
||||||
shortcut_maps []*ShortcutMap
|
active_shortcut_maps []*ShortcutMap
|
||||||
current_pending_keys []string
|
current_pending_keys []string
|
||||||
current_numeric_argument string
|
current_numeric_argument string
|
||||||
}
|
}
|
||||||
@@ -164,13 +164,13 @@ func (self *Readline) dispatch_key_action(ac Action) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *Readline) handle_key_event(event *loop.KeyEvent) error {
|
func (self *Readline) handle_key_event(event *loop.KeyEvent) error {
|
||||||
if len(self.keyboard_state.shortcut_maps) == 0 {
|
|
||||||
self.keyboard_state.shortcut_maps = []*ShortcutMap{default_shortcuts()}
|
|
||||||
}
|
|
||||||
if event.Text != "" {
|
if event.Text != "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
sm := self.keyboard_state.shortcut_maps[len(self.keyboard_state.shortcut_maps)-1]
|
sm := default_shortcuts()
|
||||||
|
if len(self.keyboard_state.active_shortcut_maps) > 0 {
|
||||||
|
sm = self.keyboard_state.active_shortcut_maps[len(self.keyboard_state.active_shortcut_maps)-1]
|
||||||
|
}
|
||||||
for _, pk := range self.keyboard_state.current_pending_keys {
|
for _, pk := range self.keyboard_state.current_pending_keys {
|
||||||
sm = sm.children[pk]
|
sm = sm.children[pk]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user