mirror of
https://github.com/kovidgoyal/kitty.git
synced 2024-11-09 18:14:27 +03:00
Dont request release events for most kittens
They are not needed and there is always a small risk that a release event could be delivered after the kitten has stopped reading from the tty, thereby leaking into the environment.
This commit is contained in:
parent
de74b93b16
commit
509a45b579
@ -63,16 +63,15 @@ type handler struct {
|
||||
opts *Options
|
||||
cached_data *CachedData
|
||||
|
||||
state State
|
||||
fetch_result chan fetch_data
|
||||
all_themes *themes.Themes
|
||||
themes_closer io.Closer
|
||||
themes_list *ThemesList
|
||||
category_filters map[string]func(*themes.Theme) bool
|
||||
colors_set_once bool
|
||||
tabs []string
|
||||
rl *readline.Readline
|
||||
quit_on_next_key_release int
|
||||
state State
|
||||
fetch_result chan fetch_data
|
||||
all_themes *themes.Themes
|
||||
themes_closer io.Closer
|
||||
themes_list *ThemesList
|
||||
category_filters map[string]func(*themes.Theme) bool
|
||||
colors_set_once bool
|
||||
tabs []string
|
||||
rl *readline.Readline
|
||||
}
|
||||
|
||||
// fetching {{{
|
||||
@ -85,7 +84,7 @@ func (self *handler) fetch_themes() {
|
||||
|
||||
func (self *handler) on_fetching_key_event(ev *loop.KeyEvent) error {
|
||||
if ev.MatchesPressOrRepeat("esc") {
|
||||
self.quit_on_next_key_release = 0
|
||||
self.lp.Quit(0)
|
||||
ev.Handled = true
|
||||
}
|
||||
return nil
|
||||
@ -118,7 +117,6 @@ func (self *handler) finalize() {
|
||||
}
|
||||
|
||||
func (self *handler) initialize() {
|
||||
self.quit_on_next_key_release = -1
|
||||
self.tabs = strings.Split("all dark light recent user", " ")
|
||||
self.rl = readline.New(self.lp, readline.RlInit{DontMarkPrompts: true, Prompt: "/"})
|
||||
self.themes_list = &ThemesList{}
|
||||
@ -203,10 +201,6 @@ func (self *handler) redraw_after_category_change() {
|
||||
}
|
||||
|
||||
func (self *handler) on_key_event(ev *loop.KeyEvent) error {
|
||||
if self.quit_on_next_key_release > -1 && ev.Type == loop.RELEASE {
|
||||
self.lp.Quit(self.quit_on_next_key_release)
|
||||
return nil
|
||||
}
|
||||
switch self.state {
|
||||
case FETCHING:
|
||||
return self.on_fetching_key_event(ev)
|
||||
@ -239,7 +233,7 @@ func (self *handler) next(delta int, allow_wrapping bool) {
|
||||
|
||||
func (self *handler) on_browsing_key_event(ev *loop.KeyEvent) error {
|
||||
if ev.MatchesPressOrRepeat("esc") || ev.MatchesPressOrRepeat("q") {
|
||||
self.quit_on_next_key_release = 0
|
||||
self.lp.Quit(0)
|
||||
ev.Handled = true
|
||||
return nil
|
||||
}
|
||||
@ -499,7 +493,7 @@ func (self *handler) draw_theme_demo() {
|
||||
func (self *handler) on_accepting_key_event(ev *loop.KeyEvent) error {
|
||||
if ev.MatchesPressOrRepeat("q") || ev.MatchesPressOrRepeat("esc") {
|
||||
ev.Handled = true
|
||||
self.quit_on_next_key_release = 0
|
||||
self.lp.Quit(0)
|
||||
return nil
|
||||
}
|
||||
if ev.MatchesPressOrRepeat("a") {
|
||||
|
@ -151,6 +151,15 @@ 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
|
||||
}
|
||||
|
||||
func (self *Loop) MouseTrackingMode(mt MouseTracking) *Loop {
|
||||
self.terminal_options.mouse_tracking = mt
|
||||
return self
|
||||
|
@ -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 = 0b11111
|
||||
l.terminal_options.kitty_keyboard_mode = 0b11101 // full protocol without release and repeat events
|
||||
l.escape_code_parser.HandleCSI = l.handle_csi
|
||||
l.escape_code_parser.HandleOSC = l.handle_osc
|
||||
l.escape_code_parser.HandleDCS = l.handle_dcs
|
||||
|
@ -21,7 +21,7 @@ func (self *KilledBySignal) Error() string { return self.Msg }
|
||||
var Canceled = errors.New("Canceled by user")
|
||||
|
||||
func ReadPassword(prompt string, kill_if_signaled bool) (password string, err error) {
|
||||
lp, err := loop.New(loop.NoAlternateScreen, loop.NoRestoreColors)
|
||||
lp, err := loop.New(loop.NoAlternateScreen, loop.NoRestoreColors, loop.FullKeyboardProtocol)
|
||||
shadow := ""
|
||||
if err != nil {
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user