Implement clear screen c-l binding
This commit is contained in:
parent
19bf07abd9
commit
b7816d26be
@ -252,6 +252,10 @@ func (self *Loop) AllowLineWrapping(allow bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *Loop) ClearScreen() {
|
||||||
|
self.QueueWriteString("\x1b[H\x1b[2J")
|
||||||
|
}
|
||||||
|
|
||||||
func (self *Loop) Quit(exit_code int) {
|
func (self *Loop) Quit(exit_code int) {
|
||||||
self.exit_code = exit_code
|
self.exit_code = exit_code
|
||||||
self.keep_going = false
|
self.keep_going = false
|
||||||
|
|||||||
@ -429,7 +429,12 @@ func (self *Readline) perform_action(ac Action, repeat_count uint) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self.perform_action(ActionCursorDown, repeat_count)
|
return self.perform_action(ActionCursorDown, repeat_count)
|
||||||
|
case ActionClearScreen:
|
||||||
|
self.loop.StartAtomicUpdate()
|
||||||
|
self.loop.ClearScreen()
|
||||||
|
self.RedrawNonAtomic()
|
||||||
|
self.loop.EndAtomicUpdate()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return ErrCouldNotPerformAction
|
return ErrCouldNotPerformAction
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,6 +55,7 @@ const (
|
|||||||
ActionHistoryNextOrCursorDown
|
ActionHistoryNextOrCursorDown
|
||||||
ActionHistoryNext
|
ActionHistoryNext
|
||||||
ActionHistoryPrevious
|
ActionHistoryPrevious
|
||||||
|
ActionClearScreen
|
||||||
)
|
)
|
||||||
|
|
||||||
type Readline struct {
|
type Readline struct {
|
||||||
|
|||||||
@ -35,6 +35,8 @@ var default_shortcuts = map[string]Action{
|
|||||||
"right": ActionCursorRight,
|
"right": ActionCursorRight,
|
||||||
"ctrl+f": ActionCursorRight,
|
"ctrl+f": ActionCursorRight,
|
||||||
|
|
||||||
|
"ctrl+l": ActionClearScreen,
|
||||||
|
|
||||||
"ctrl+d": ActionEndInput,
|
"ctrl+d": ActionEndInput,
|
||||||
"enter": ActionAcceptInput,
|
"enter": ActionAcceptInput,
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user