mirror of https://github.com/liamg/aminal.git
started work on scrollable regions
This commit is contained in:
parent
7c7a7e2bc7
commit
daf32ef9ca
|
@ -15,6 +15,8 @@ type Buffer struct {
|
|||
savedX uint16
|
||||
savedY uint16
|
||||
scrollLinesFromBottom uint
|
||||
topMargin uint // see DECSTBM docs - this is for scrollable regions
|
||||
bottomMargin uint // see DECSTBM docs - this is for scrollable regions
|
||||
}
|
||||
|
||||
// NewBuffer creates a new terminal buffer
|
||||
|
@ -29,6 +31,11 @@ func NewBuffer(viewCols uint16, viewLines uint16, attr CellAttributes) *Buffer {
|
|||
return b
|
||||
}
|
||||
|
||||
func (buffer *Buffer) SetMargins(top uint, bottom uint) {
|
||||
buffer.topMargin = top
|
||||
buffer.bottomMargin = bottom
|
||||
}
|
||||
|
||||
func (buffer *Buffer) GetScrollOffset() uint {
|
||||
return buffer.scrollLinesFromBottom
|
||||
}
|
||||
|
@ -536,4 +543,5 @@ func (buffer *Buffer) ResizeView(width uint16, height uint16) {
|
|||
line = buffer.getCurrentLine()
|
||||
buffer.cursorX = uint16((len(line.cells) - cXFromEndOfLine) - 1)
|
||||
|
||||
buffer.SetMargins(0, uint(buffer.viewHeight-1))
|
||||
}
|
||||
|
|
|
@ -16,6 +16,37 @@ var csiSequenceMap = map[rune]csiSequenceHandler{
|
|||
'd': csiLinePositionAbsolute,
|
||||
't': csiWindowManipulation,
|
||||
'X': csiEraseCharactersHandler,
|
||||
'r': csiSetMarginsHandler,
|
||||
}
|
||||
|
||||
// DECSTBM
|
||||
func csiSetMarginsHandler(params []string, intermediate string, terminal *Terminal) error {
|
||||
top := 1
|
||||
bottom := int(terminal.ActiveBuffer().ViewHeight())
|
||||
if len(params) > 0 {
|
||||
var err error
|
||||
top, err = strconv.Atoi(params[0])
|
||||
if err != nil {
|
||||
top = 1
|
||||
}
|
||||
|
||||
if len(params) > 1 {
|
||||
var err error
|
||||
bottom, err = strconv.Atoi(params[1])
|
||||
if err != nil {
|
||||
bottom = 1
|
||||
}
|
||||
if bottom > int(terminal.ActiveBuffer().ViewHeight()) {
|
||||
bottom = int(terminal.ActiveBuffer().ViewHeight())
|
||||
}
|
||||
}
|
||||
}
|
||||
top -= 1
|
||||
bottom -= 1
|
||||
|
||||
terminal.ActiveBuffer().SetPosition(0, 0)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func csiSetMode(modeStr string, enabled bool, terminal *Terminal) error {
|
||||
|
|
Loading…
Reference in New Issue