This commit is contained in:
Kovid Goyal 2023-03-17 11:00:00 +05:30
parent 509a45b579
commit bf773351ed
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 17 additions and 15 deletions

View File

@ -134,30 +134,21 @@ func NoAlternateScreen(self *Loop) {
}
func (self *Loop) OnlyDisambiguateKeys() *Loop {
self.terminal_options.kitty_keyboard_mode = 0b1
self.terminal_options.kitty_keyboard_mode = DISAMBIGUATE_KEYS
return self
}
func OnlyDisambiguateKeys(self *Loop) {
self.terminal_options.kitty_keyboard_mode = 0b1
self.terminal_options.kitty_keyboard_mode = DISAMBIGUATE_KEYS
}
func (self *Loop) FullKeyboardProtocol() *Loop {
self.terminal_options.kitty_keyboard_mode = 0b11111
self.terminal_options.kitty_keyboard_mode = FULL_KEYBOARD_PROTOCOL
return self
}
func FullKeyboardProtocol(self *Loop) {
self.terminal_options.kitty_keyboard_mode = 0b11111
}
func (self *Loop) FullKeyboardProtocolWithoutReleaseEvents() *Loop {
self.terminal_options.kitty_keyboard_mode = 0b11101
return self
}
func FullKeyboardProtocolWithoutReleaseEvents(self *Loop) {
self.terminal_options.kitty_keyboard_mode = 0b11101
self.terminal_options.kitty_keyboard_mode = FULL_KEYBOARD_PROTOCOL
}
func (self *Loop) MouseTrackingMode(mt MouseTracking) *Loop {

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 = 0b11101 // full protocol without release and repeat events
l.terminal_options.kitty_keyboard_mode = DISAMBIGUATE_KEYS | REPORT_ALTERNATE_KEYS | REPORT_ALL_KEYS_AS_ESCAPE_CODES | REPORT_TEXT_WITH_KEYS
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

@ -9,6 +9,17 @@ import (
"kitty"
)
type KeyboardStateBits uint8
const (
DISAMBIGUATE_KEYS KeyboardStateBits = 1 << iota
REPORT_KEY_EVENT_TYPES
REPORT_ALTERNATE_KEYS
REPORT_ALL_KEYS_AS_ESCAPE_CODES
REPORT_TEXT_WITH_KEYS
FULL_KEYBOARD_PROTOCOL = DISAMBIGUATE_KEYS | REPORT_ALTERNATE_KEYS | REPORT_ALL_KEYS_AS_ESCAPE_CODES | REPORT_TEXT_WITH_KEYS | REPORT_KEY_EVENT_TYPES
)
const (
SAVE_CURSOR = "\0337"
RESTORE_CURSOR = "\0338"
@ -86,7 +97,7 @@ const (
type TerminalStateOptions struct {
alternate_screen, restore_colors bool
mouse_tracking MouseTracking
kitty_keyboard_mode int
kitty_keyboard_mode KeyboardStateBits
}
func set_modes(sb *strings.Builder, modes ...Mode) {