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

Method displayBuffer

internal/display/bufwindow.go:383–840  ·  view source on GitHub ↗

displayBuffer draws the buffer being shown in this window on the screen.Screen

()

Source from the content-addressed store, hash-verified

381
382// displayBuffer draws the buffer being shown in this window on the screen.Screen
383func (w *BufWindow) displayBuffer() {
384 b := w.Buf
385
386 if w.Height <= 0 || w.Width <= 0 {
387 return
388 }
389
390 maxWidth := w.gutterOffset + w.bufWidth
391
392 if b.ModifiedThisFrame {
393 if b.Settings["diffgutter"].(bool) {
394 b.UpdateDiff()
395 }
396 b.ModifiedThisFrame = false
397 }
398
399 var matchingBraces []buffer.Loc
400 // bracePairs is defined in buffer.go
401 if b.Settings["matchbrace"].(bool) {
402 for _, c := range b.GetCursors() {
403 if c.HasSelection() {
404 continue
405 }
406
407 mb, left, found := b.FindMatchingBrace(c.Loc)
408 if found {
409 matchingBraces = append(matchingBraces, mb)
410 if !left {
411 if b.Settings["matchbracestyle"].(string) != "highlight" {
412 matchingBraces = append(matchingBraces, c.Loc)
413 }
414 } else {
415 matchingBraces = append(matchingBraces, c.Loc.Move(-1, b))
416 }
417 }
418 }
419 }
420
421 lineNumStyle := config.DefStyle
422 if style, ok := config.Colorscheme["line-number"]; ok {
423 lineNumStyle = style
424 }
425 curNumStyle := config.DefStyle
426 if style, ok := config.Colorscheme["current-line-number"]; ok {
427 if !b.Settings["cursorline"].(bool) {
428 curNumStyle = lineNumStyle
429 } else {
430 curNumStyle = style
431 }
432 }
433
434 softwrap := b.Settings["softwrap"].(bool)
435 wordwrap := softwrap && b.Settings["wordwrap"].(bool)
436
437 tabsize := util.IntOpt(b.Settings["tabsize"])
438 colorcolumn := util.IntOpt(b.Settings["colorcolumn"])
439
440 // this represents the current draw position

Callers 1

DisplayMethod · 0.95

Calls 15

drawGutterMethod · 0.95
drawDiffGutterMethod · 0.95
drawLineNumMethod · 0.95
getStartInfoMethod · 0.95
GreaterEqualMethod · 0.95
LessThanMethod · 0.95
showCursorMethod · 0.95
getStyleMethod · 0.95
IntOptFunction · 0.92
CharacterCountFunction · 0.92
GetLeadingWhitespaceFunction · 0.92
GetTrailingWhitespaceFunction · 0.92

Tested by

no test coverage detected