This commit is contained in:
Kovid Goyal
2026-04-10 15:32:27 +05:30
parent 5e158f90a7
commit 3fe884a29a
8 changed files with 23 additions and 18 deletions

View File

@@ -27,19 +27,15 @@ 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)
// we cant do inbandresize notification as in the --no-response case the
// command can cause a resize and the loop can quit before the notification
// arrives, leading to the notification being sent to whatever is executed
// after us. Similarly no focus tracking.
lp, err := loop.New(loop.NoAlternateScreen, loop.NoRestoreColors, loop.NoInBandResizeNotifications, loop.NoFocusTracking)
lp, err := loop.NewForSimpleInteraction()
if err != nil {
return
}
if io_data.on_key_event != nil {
lp.FullKeyboardProtocol()
lp.NoRoundtripToTerminalOnExit = false
} else {
lp.NoKeyboardStateChange()
lp.NoRoundtripToTerminalOnExit = true
}
const (

View File

@@ -141,6 +141,21 @@ func New(options ...func(self *Loop)) (*Loop, error) {
return l, nil
}
// Create a loop that does not change terminal state such as keyboard mode,
// resize/focus notifications, mouse tracking, alternate screen etc. Useful
// for special purpose kittens such as icat/clipboard/@ etc.
func NewForSimpleInteraction() (*Loop, error) {
lp, err := New(
NoAlternateScreen, NoRestoreColors, NoMouseTracking, NoInBandResizeNotifications,
NoFocusTracking, NoKeyboardStateChange,
)
if err == nil {
lp.NoRoundtripToTerminalOnExit = true
lp.terminal_options.color_scheme_change_notification = false
}
return lp, err
}
func (self *Loop) AddTimer(interval time.Duration, repeats bool, callback TimerCallback) (IdType, error) {
return self.add_timer(interval, repeats, callback)
}