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

Method updateDisplayInfo

internal/display/bufwindow.go:119–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

117}
118
119func (w *BufWindow) updateDisplayInfo() {
120 b := w.Buf
121
122 w.drawDivider = false
123 if !b.Settings["statusline"].(bool) {
124 _, h := screen.Screen.Size()
125 infoY := h
126 if config.GetGlobalOption("infobar").(bool) {
127 infoY--
128 }
129 if w.Y+w.Height != infoY {
130 w.drawDivider = true
131 }
132 }
133
134 w.bufHeight = w.Height
135 if b.Settings["statusline"].(bool) || w.drawDivider {
136 w.bufHeight--
137 }
138
139 scrollbarWidth := 0
140 if w.Buf.Settings["scrollbar"].(bool) && w.Buf.LinesNum() > w.Height && w.Width > 0 {
141 scrollbarWidth = 1
142 }
143
144 w.hasMessage = len(b.Messages) > 0
145
146 // We need to know the string length of the largest line number
147 // so we can pad appropriately when displaying line numbers
148 w.maxLineNumLength = len(strconv.Itoa(b.LinesNum()))
149
150 w.gutterOffset = 0
151 if w.hasMessage {
152 w.gutterOffset += 2
153 }
154 if b.Settings["diffgutter"].(bool) {
155 w.gutterOffset++
156 }
157 if b.Settings["ruler"].(bool) {
158 w.gutterOffset += w.maxLineNumLength + 1
159 }
160
161 if w.gutterOffset > w.Width-scrollbarWidth {
162 w.gutterOffset = w.Width - scrollbarWidth
163 }
164
165 prevBufWidth := w.bufWidth
166 w.bufWidth = w.Width - w.gutterOffset - scrollbarWidth
167
168 if w.bufWidth != prevBufWidth && w.Buf.Settings["softwrap"].(bool) {
169 for _, c := range w.Buf.GetCursors() {
170 c.LastWrappedVisualX = c.GetVisualX(true)
171 }
172 }
173}
174
175func (w *BufWindow) getStartInfo(n, lineN int) ([]byte, int, int, *tcell.Style) {
176 tabsize := util.IntOpt(w.Buf.Settings["tabsize"])

Callers 3

SetBufferMethod · 0.95
ResizeMethod · 0.95
DisplayMethod · 0.95

Calls 5

GetGlobalOptionFunction · 0.92
SizeMethod · 0.80
GetCursorsMethod · 0.80
GetVisualXMethod · 0.80
LinesNumMethod · 0.65

Tested by

no test coverage detected