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

Method SetBuffer

internal/display/bufwindow.go:48–75  ·  view source on GitHub ↗

SetBuffer sets this window's buffer.

(b *buffer.Buffer)

Source from the content-addressed store, hash-verified

46
47// SetBuffer sets this window's buffer.
48func (w *BufWindow) SetBuffer(b *buffer.Buffer) {
49 w.Buf = b
50 b.OptionCallback = func(option string, nativeValue any) {
51 if option == "softwrap" {
52 if nativeValue.(bool) {
53 w.StartCol = 0
54 } else {
55 w.StartLine.Row = 0
56 }
57 }
58
59 if option == "softwrap" || option == "wordwrap" {
60 w.Relocate()
61 for _, c := range w.Buf.GetCursors() {
62 c.LastWrappedVisualX = c.GetVisualX(true)
63 }
64 }
65
66 if option == "diffgutter" || option == "ruler" || option == "scrollbar" ||
67 option == "statusline" {
68 w.updateDisplayInfo()
69 w.Relocate()
70 }
71 }
72 b.GetVisualX = func(loc buffer.Loc) int {
73 return w.VLocFromLoc(loc).VisualX
74 }
75}
76
77// GetView gets the view.
78func (w *BufWindow) GetView() *View {

Callers

nothing calls this directly

Calls 5

RelocateMethod · 0.95
updateDisplayInfoMethod · 0.95
VLocFromLocMethod · 0.95
GetCursorsMethod · 0.80
GetVisualXMethod · 0.80

Tested by

no test coverage detected