kitten @ cmd: Dont generate key release events

We dont need them and they sometimes can spill over into the prompt if
the command is very fast.
This commit is contained in:
Kovid Goyal 2023-01-23 16:18:46 +05:30
parent cc1f0bc3fe
commit 97467acb1f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 16 additions and 6 deletions

View File

@ -26,7 +26,7 @@ func is_stream_response(serialized_response []byte) bool {
func do_chunked_io(io_data *rc_io_data) (serialized_response []byte, err error) {
serialized_response = make([]byte, 0)
lp, err := loop.New(loop.NoAlternateScreen, loop.NoRestoreColors)
lp, err := loop.New(loop.NoAlternateScreen, loop.NoRestoreColors, loop.OnlyDisambiguateKeys)
if err != nil {
return
}

View File

@ -124,6 +124,15 @@ func NoAlternateScreen(self *Loop) {
self.terminal_options.alternate_screen = false
}
func (self *Loop) OnlyDisambiguateKeys() *Loop {
self.terminal_options.kitty_keyboard_mode = 0b1
return self
}
func OnlyDisambiguateKeys(self *Loop) {
self.terminal_options.kitty_keyboard_mode = 0b1
}
func (self *Loop) MouseTrackingMode(mt MouseTracking) *Loop {
self.terminal_options.mouse_tracking = mt
return self

View File

@ -24,7 +24,7 @@ func new_loop() *Loop {
l := Loop{controlling_term: nil, timers_temp: make([]*timer, 4)}
l.terminal_options.alternate_screen = true
l.terminal_options.restore_colors = true
l.terminal_options.kitty_keyboard_mode = true
l.terminal_options.kitty_keyboard_mode = 0b11111
l.escape_code_parser.HandleCSI = l.handle_csi
l.escape_code_parser.HandleOSC = l.handle_osc
l.escape_code_parser.HandleDCS = l.handle_dcs

View File

@ -84,8 +84,9 @@ const (
)
type TerminalStateOptions struct {
alternate_screen, kitty_keyboard_mode, restore_colors bool
alternate_screen, restore_colors bool
mouse_tracking MouseTracking
kitty_keyboard_mode int
}
func set_modes(sb *strings.Builder, modes ...Mode) {
@ -120,8 +121,8 @@ func (self *TerminalStateOptions) SetStateEscapeCodes() string {
set_modes(&sb, ALTERNATE_SCREEN)
sb.WriteString(CLEAR_SCREEN)
}
if self.kitty_keyboard_mode {
sb.WriteString("\033[>31u")
if self.kitty_keyboard_mode > 0 {
sb.WriteString(fmt.Sprintf("\033[>%du", self.kitty_keyboard_mode))
} else {
sb.WriteString("\033[>u")
}