mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-18 06:25:13 +02:00
More work on readline
This commit is contained in:
@@ -193,6 +193,40 @@ func (self *Loop) Beep() {
|
||||
self.QueueWriteString("\a")
|
||||
}
|
||||
|
||||
func (self *Loop) StartAtomicUpdate() {
|
||||
self.QueueWriteString(PENDING_UPDATE.EscapeCodeToSet())
|
||||
}
|
||||
|
||||
func (self *Loop) EndAtomicUpdate() {
|
||||
self.QueueWriteString(PENDING_UPDATE.EscapeCodeToReset())
|
||||
}
|
||||
|
||||
func (self *Loop) SetCursorShape(shape CursorShapes, blink bool) {
|
||||
self.QueueWriteString(CursorShape(shape, blink))
|
||||
}
|
||||
|
||||
func (self *Loop) MoveCursorHorizontally(amt int) {
|
||||
suffix := "C"
|
||||
if amt < 0 {
|
||||
suffix = "D"
|
||||
amt *= -1
|
||||
}
|
||||
self.QueueWriteString(fmt.Sprintf("\x1b[%d%s", amt, suffix))
|
||||
}
|
||||
|
||||
func (self *Loop) MoveCursorVertically(amt int) {
|
||||
suffix := "B"
|
||||
if amt < 0 {
|
||||
suffix = "A"
|
||||
amt *= -1
|
||||
}
|
||||
self.QueueWriteString(fmt.Sprintf("\x1b[%d%s", amt, suffix))
|
||||
}
|
||||
|
||||
func (self *Loop) ClearToEndOfScreen() {
|
||||
self.QueueWriteString("\x1b[J")
|
||||
}
|
||||
|
||||
func (self *Loop) Quit(exit_code int) {
|
||||
self.exit_code = exit_code
|
||||
self.keep_going = false
|
||||
|
||||
@@ -21,6 +21,14 @@ const (
|
||||
CLEAR_SCREEN = "\033[H\033[2J"
|
||||
)
|
||||
|
||||
type CursorShapes uint
|
||||
|
||||
const (
|
||||
BLOCK_CURSOR CursorShapes = 1
|
||||
UNDERLINE_CURSOR CursorShapes = 3
|
||||
BAR_CURSOR CursorShapes = 5
|
||||
)
|
||||
|
||||
type Mode uint32
|
||||
|
||||
const private Mode = 1 << 31
|
||||
@@ -147,3 +155,10 @@ func (self *TerminalStateOptions) ResetStateEscapeCodes() string {
|
||||
sb.WriteString(RESTORE_COLORS)
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
func CursorShape(shape CursorShapes, blink bool) string {
|
||||
if !blink {
|
||||
shape += 1
|
||||
}
|
||||
return fmt.Sprintf("\x1b[%d q", shape)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user