MCPcopy
hub / github.com/liamg/darktile / grow

Method grow

internal/app/darktile/termutil/resize.go:34–68  ·  view source on GitHub ↗
(width uint16)

Source from the content-addressed store, hash-verified

32}
33
34func (buffer *Buffer) grow(width uint16) {
35
36 var replace []Line
37 var current Line
38
39 prevCursor := int(buffer.cursorPosition.Line)
40
41 for i, line := range buffer.lines {
42
43 if !line.wrapped {
44 if i > 0 {
45 replace = append(replace, current)
46 }
47 current = newLine()
48 }
49
50 if i == prevCursor {
51 buffer.cursorPosition.Line -= uint64(i - len(replace))
52 }
53
54 for _, cell := range line.cells {
55 if len(current.cells) == int(width) {
56 replace = append(replace, current)
57 current = newLine()
58 current.wrapped = true
59 }
60 current.cells = append(current.cells, cell)
61 }
62
63 }
64
65 replace = append(replace, current)
66
67 buffer.lines = replace
68}
69
70// deprecated
71func (buffer *Buffer) resizeView(width uint16, height uint16) {

Callers 1

resizeViewMethod · 0.95

Calls 1

newLineFunction · 0.85

Tested by

no test coverage detected