MCPcopy
hub / github.com/micro-editor/micro / Display

Method Display

internal/display/termwindow.go:67–117  ·  view source on GitHub ↗

Display displays this terminal in a view

()

Source from the content-addressed store, hash-verified

65
66// Display displays this terminal in a view
67func (w *TermWindow) Display() {
68 w.State.Lock()
69 defer w.State.Unlock()
70
71 var l buffer.Loc
72 for y := 0; y < w.Height; y++ {
73 for x := 0; x < w.Width; x++ {
74 l.X, l.Y = x, y
75 c, f, b := w.State.Cell(x, y)
76
77 fg, bg := int(f), int(b)
78 if f == terminal.DefaultFG {
79 fg = int(tcell.ColorDefault)
80 }
81 if b == terminal.DefaultBG {
82 bg = int(tcell.ColorDefault)
83 }
84 st := tcell.StyleDefault.Foreground(config.GetColor256(fg)).Background(config.GetColor256(bg))
85
86 if l.LessThan(w.Selection[1]) && l.GreaterEqual(w.Selection[0]) || l.LessThan(w.Selection[0]) && l.GreaterEqual(w.Selection[1]) {
87 st = st.Reverse(true)
88 }
89
90 screen.SetContent(w.X+x, w.Y+y, c, nil, st)
91 }
92 }
93 if config.GetGlobalOption("statusline").(bool) {
94 statusLineStyle := config.DefStyle.Reverse(true)
95 if style, ok := config.Colorscheme["statusline"]; ok {
96 statusLineStyle = style
97 }
98
99 text := []byte(w.Name())
100 textLen := util.CharacterCount(text)
101 for x := 0; x < w.Width; x++ {
102 if x < textLen {
103 r, combc, size := util.DecodeCharacter(text)
104 text = text[size:]
105 screen.SetContent(w.X+x, w.Y+w.Height, r, combc, statusLineStyle)
106 } else {
107 screen.SetContent(w.X+x, w.Y+w.Height, ' ', nil, statusLineStyle)
108 }
109 }
110 }
111 if w.State.CursorVisible() && w.active {
112 curx, cury := w.State.Cursor()
113 if curx < w.Width && cury < w.Height {
114 screen.ShowCursor(curx+w.X, cury+w.Y)
115 }
116 }
117}

Callers

nothing calls this directly

Calls 11

LessThanMethod · 0.95
GreaterEqualMethod · 0.95
GetColor256Function · 0.92
SetContentFunction · 0.92
GetGlobalOptionFunction · 0.92
CharacterCountFunction · 0.92
DecodeCharacterFunction · 0.92
ShowCursorFunction · 0.92
LockMethod · 0.65
UnlockMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected