mirror of https://github.com/liamg/aminal.git
commit
adee2d2284
|
@ -27,6 +27,7 @@ type Buffer struct {
|
|||
selectionComplete bool // whether the selected text can update or whether it is final
|
||||
selectionExpanded bool // whether the selection to word expansion has already run on this point
|
||||
selectionClickTime time.Time
|
||||
defaultCell Cell
|
||||
}
|
||||
|
||||
type Position struct {
|
||||
|
@ -42,6 +43,7 @@ func NewBuffer(viewCols uint16, viewLines uint16, attr CellAttributes) *Buffer {
|
|||
lines: []Line{},
|
||||
cursorAttr: attr,
|
||||
autoWrap: true,
|
||||
defaultCell: Cell{attr: attr},
|
||||
}
|
||||
b.SetVerticalMargins(0, uint(viewLines-1))
|
||||
b.ResizeView(viewCols, viewLines)
|
||||
|
@ -511,8 +513,7 @@ func (buffer *Buffer) InsertBlankCharacters(count int) {
|
|||
index := int(buffer.RawLine())
|
||||
for i := 0; i < count; i++ {
|
||||
cells := buffer.lines[index].cells
|
||||
c := Cell{}
|
||||
buffer.lines[index].cells = append(cells[:buffer.cursorX], append([]Cell{c}, cells[buffer.cursorX:]...)...)
|
||||
buffer.lines[index].cells = append(cells[:buffer.cursorX], append([]Cell{buffer.defaultCell}, cells[buffer.cursorX:]...)...)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -624,7 +625,7 @@ func (buffer *Buffer) Write(runes ...rune) {
|
|||
}
|
||||
|
||||
for int(buffer.CursorColumn()) >= len(line.cells) {
|
||||
line.cells = append(line.cells, Cell{})
|
||||
line.cells = append(line.cells, buffer.defaultCell)
|
||||
}
|
||||
line.cells[buffer.cursorX].attr = buffer.cursorAttr
|
||||
line.cells[buffer.cursorX].setRune(r)
|
||||
|
@ -655,7 +656,7 @@ func (buffer *Buffer) Write(runes ...rune) {
|
|||
} else {
|
||||
|
||||
for int(buffer.CursorColumn()) >= len(line.cells) {
|
||||
line.cells = append(line.cells, Cell{})
|
||||
line.cells = append(line.cells, buffer.defaultCell)
|
||||
}
|
||||
|
||||
cell := &line.cells[buffer.CursorColumn()]
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/go-gl/gl/all-core/gl"
|
||||
|
@ -33,6 +34,7 @@ type GUI struct {
|
|||
terminalAlpha float32
|
||||
showDebugInfo bool
|
||||
keyboardShortcuts map[config.UserAction]*config.KeyCombination
|
||||
resizeLock *sync.Mutex
|
||||
}
|
||||
|
||||
func New(config *config.Config, terminal *terminal.Terminal, logger *zap.SugaredLogger) (*GUI, error) {
|
||||
|
@ -51,6 +53,7 @@ func New(config *config.Config, terminal *terminal.Terminal, logger *zap.Sugared
|
|||
fontScale: 14.0,
|
||||
terminalAlpha: 1,
|
||||
keyboardShortcuts: shortcuts,
|
||||
resizeLock: &sync.Mutex{},
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -65,6 +68,9 @@ func (gui *GUI) scale() float32 {
|
|||
// can only be called on OS thread
|
||||
func (gui *GUI) resize(w *glfw.Window, width int, height int) {
|
||||
|
||||
gui.resizeLock.Lock()
|
||||
defer gui.resizeLock.Unlock()
|
||||
|
||||
gui.logger.Debugf("Initiating GUI resize to %dx%d", width, height)
|
||||
|
||||
gui.width = width
|
||||
|
|
Loading…
Reference in New Issue