forked from Mirrors/bubbletea
Create ignoreLines map on demand
This commit is contained in:
parent
902225116c
commit
83e41c15b1
|
@ -167,6 +167,9 @@ func (r *renderer) write(s string) {
|
||||||
// setIngoredLines speicifies lines not to be touched by the standard Bubble Tea
|
// setIngoredLines speicifies lines not to be touched by the standard Bubble Tea
|
||||||
// renderer.
|
// renderer.
|
||||||
func (r *renderer) setIgnoredLines(from int, to int) {
|
func (r *renderer) setIgnoredLines(from int, to int) {
|
||||||
|
if r.ignoreLines == nil {
|
||||||
|
r.ignoreLines = make(map[int]struct{})
|
||||||
|
}
|
||||||
for i := from; i < to; i++ {
|
for i := from; i < to; i++ {
|
||||||
r.ignoreLines[i] = struct{}{}
|
r.ignoreLines[i] = struct{}{}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +179,7 @@ func (r *renderer) setIgnoredLines(from int, to int) {
|
||||||
// Tea renderer. Any lines previously set to be ignored can be rendered to
|
// Tea renderer. Any lines previously set to be ignored can be rendered to
|
||||||
// again.
|
// again.
|
||||||
func (r *renderer) clearIgnoredLines() {
|
func (r *renderer) clearIgnoredLines() {
|
||||||
r.ignoreLines = make(map[int]struct{})
|
r.ignoreLines = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// insertTop effectively scrolls up. It inserts lines at the top of a given
|
// insertTop effectively scrolls up. It inserts lines at the top of a given
|
||||||
|
@ -239,8 +242,7 @@ func (r *renderer) insertBottom(lines []string, topBoundary, bottomBoundary int)
|
||||||
r.out.Write(b.Bytes())
|
r.out.Write(b.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleMessages handles internal messages for the renderer. It belongs in the
|
// handleMessages handles internal messages for the renderer.
|
||||||
// main update loop at the program level.
|
|
||||||
func (r *renderer) handleMessages(msg Msg) {
|
func (r *renderer) handleMessages(msg Msg) {
|
||||||
switch msg := msg.(type) {
|
switch msg := msg.(type) {
|
||||||
case WindowSizeMsg:
|
case WindowSizeMsg:
|
||||||
|
|
Loading…
Reference in New Issue