Editor is a widget for editing multiple lines of complicated text (as compared to [core.TextField] for a single line of simple text). The Editor is driven by a [Buffer] buffer which contains all the text, and manages all the edits, sending update events out to the editors. Use NeedsRender to drive
| 54 | // Editor should be within a single goroutine, as it would require |
| 55 | // extensive protections throughout code otherwise. |
| 56 | type Editor struct { //core:embedder |
| 57 | core.Frame |
| 58 | |
| 59 | // Buffer is the text buffer being edited. |
| 60 | Buffer *Buffer `set:"-" json:"-" xml:"-"` |
| 61 | |
| 62 | // CursorWidth is the width of the cursor. |
| 63 | // This should be set in Stylers like all other style properties. |
| 64 | CursorWidth units.Value |
| 65 | |
| 66 | // LineNumberColor is the color used for the side bar containing the line numbers. |
| 67 | // This should be set in Stylers like all other style properties. |
| 68 | LineNumberColor image.Image |
| 69 | |
| 70 | // SelectColor is the color used for the user text selection background color. |
| 71 | // This should be set in Stylers like all other style properties. |
| 72 | SelectColor image.Image |
| 73 | |
| 74 | // HighlightColor is the color used for the text highlight background color (like in find). |
| 75 | // This should be set in Stylers like all other style properties. |
| 76 | HighlightColor image.Image |
| 77 | |
| 78 | // CursorColor is the color used for the text editor cursor bar. |
| 79 | // This should be set in Stylers like all other style properties. |
| 80 | CursorColor image.Image |
| 81 | |
| 82 | // NumLines is the number of lines in the view, synced with the [Buffer] after edits, |
| 83 | // but always reflects the storage size of renders etc. |
| 84 | NumLines int `set:"-" display:"-" json:"-" xml:"-"` |
| 85 | |
| 86 | // renders is a slice of paint.Text representing the renders of the text lines, |
| 87 | // with one render per line (each line could visibly wrap-around, so these are logical lines, not display lines). |
| 88 | renders []paint.Text |
| 89 | |
| 90 | // offsets is a slice of float32 representing the starting render offsets for the top of each line. |
| 91 | offsets []float32 |
| 92 | |
| 93 | // lineNumberDigits is the number of line number digits needed. |
| 94 | lineNumberDigits int |
| 95 | |
| 96 | // LineNumberOffset is the horizontal offset for the start of text after line numbers. |
| 97 | LineNumberOffset float32 `set:"-" display:"-" json:"-" xml:"-"` |
| 98 | |
| 99 | // lineNumberRender is the render for line numbers. |
| 100 | lineNumberRender paint.Text |
| 101 | |
| 102 | // CursorPos is the current cursor position. |
| 103 | CursorPos lexer.Pos `set:"-" edit:"-" json:"-" xml:"-"` |
| 104 | |
| 105 | // cursorTarget is the target cursor position for externally set targets. |
| 106 | // It ensures that the target position is visible. |
| 107 | cursorTarget lexer.Pos |
| 108 | |
| 109 | // cursorColumn is the desired cursor column, where the cursor was last when moved using left / right arrows. |
| 110 | // It is used when doing up / down to not always go to short line columns. |
| 111 | cursorColumn int |
| 112 | |
| 113 | // posHistoryIndex is the current index within PosHistory. |
nothing calls this directly
no outgoing calls
no test coverage detected