mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-21 16:05:02 +02:00
Map ctrl+c to abort the current line
This commit is contained in:
@@ -584,12 +584,12 @@ func (self *Readline) perform_action(ac Action, repeat_count uint) error {
|
||||
return nil
|
||||
}
|
||||
case ActionHistoryPreviousOrCursorUp:
|
||||
if self.perform_action(ActionCursorUp, repeat_count) != nil {
|
||||
if self.perform_action(ActionCursorUp, repeat_count) == ErrCouldNotPerformAction {
|
||||
return self.perform_action(ActionHistoryPrevious, repeat_count)
|
||||
}
|
||||
return nil
|
||||
case ActionHistoryNextOrCursorDown:
|
||||
if self.perform_action(ActionCursorDown, repeat_count) != nil {
|
||||
if self.perform_action(ActionCursorDown, repeat_count) == ErrCouldNotPerformAction {
|
||||
return self.perform_action(ActionHistoryNext, repeat_count)
|
||||
}
|
||||
return nil
|
||||
@@ -643,6 +643,10 @@ func (self *Readline) perform_action(ac Action, repeat_count uint) error {
|
||||
if self.yank(repeat_count, true) {
|
||||
return nil
|
||||
}
|
||||
case ActionAbortCurrentLine:
|
||||
self.loop.QueueWriteString("\r\n")
|
||||
self.ResetText()
|
||||
return nil
|
||||
}
|
||||
return ErrCouldNotPerformAction
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ const (
|
||||
ActionHistoryLast
|
||||
ActionClearScreen
|
||||
ActionAddText
|
||||
ActionAbortCurrentLine
|
||||
|
||||
ActionStartKillActions
|
||||
ActionKillToEndOfLine
|
||||
|
||||
@@ -49,10 +49,14 @@ var default_shortcuts = map[string]Action{
|
||||
"ctrl+y": ActionYank,
|
||||
"alt+y": ActionPopYank,
|
||||
|
||||
"up": ActionHistoryPreviousOrCursorUp,
|
||||
"down": ActionHistoryNextOrCursorDown,
|
||||
"ctrl+p": ActionHistoryPrevious,
|
||||
"ctrl+n": ActionHistoryNext,
|
||||
"alt+<": ActionHistoryFirst,
|
||||
"alt+>": ActionHistoryLast,
|
||||
|
||||
"ctrl+c": ActionAbortCurrentLine,
|
||||
}
|
||||
|
||||
func action_for_key_event(event *loop.KeyEvent, shortcuts map[string]Action) Action {
|
||||
|
||||
Reference in New Issue
Block a user