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

Method getStartInfo

internal/display/bufwindow.go:175–206  ·  view source on GitHub ↗
(n, lineN int)

Source from the content-addressed store, hash-verified

173}
174
175func (w *BufWindow) getStartInfo(n, lineN int) ([]byte, int, int, *tcell.Style) {
176 tabsize := util.IntOpt(w.Buf.Settings["tabsize"])
177 width := 0
178 bloc := buffer.Loc{0, lineN}
179 b := w.Buf.LineBytes(lineN)
180 curStyle := config.DefStyle
181 var s *tcell.Style
182 for len(b) > 0 {
183 r, _, size := util.DecodeCharacter(b)
184
185 curStyle, found := w.getStyle(curStyle, bloc)
186 if found {
187 s = &curStyle
188 }
189
190 w := 0
191 switch r {
192 case '\t':
193 ts := tabsize - (width % tabsize)
194 w = ts
195 default:
196 w = runewidth.RuneWidth(r)
197 }
198 if width+w > n {
199 return b, n - width, bloc.X, s
200 }
201 width += w
202 b = b[size:]
203 bloc.X++
204 }
205 return b, n - width, bloc.X, s
206}
207
208// Clear resets all cells in this window to the default style
209func (w *BufWindow) Clear() {

Callers 1

displayBufferMethod · 0.95

Calls 4

getStyleMethod · 0.95
IntOptFunction · 0.92
DecodeCharacterFunction · 0.92
LineBytesMethod · 0.65

Tested by

no test coverage detected