SetBuffer sets this window's buffer.
(b *buffer.Buffer)
| 46 | |
| 47 | // SetBuffer sets this window's buffer. |
| 48 | func (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. |
| 78 | func (w *BufWindow) GetView() *View { |
nothing calls this directly
no test coverage detected