mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 09:25:38 +00:00
widget: replace newline with space in single-line Editors; cover SetText
Move the replacing to Editor.prepend to fix SetText, and replace with space instead of nothing to keep lines separated even in single-line Editors. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+3
-3
@@ -645,14 +645,14 @@ func (e *Editor) Insert(s string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Editor) append(s string) {
|
func (e *Editor) append(s string) {
|
||||||
if e.SingleLine {
|
|
||||||
s = strings.ReplaceAll(s, "\n", "")
|
|
||||||
}
|
|
||||||
e.prepend(s)
|
e.prepend(s)
|
||||||
e.rr.caret += len(s)
|
e.rr.caret += len(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Editor) prepend(s string) {
|
func (e *Editor) prepend(s string) {
|
||||||
|
if e.SingleLine {
|
||||||
|
s = strings.ReplaceAll(s, "\n", " ")
|
||||||
|
}
|
||||||
e.rr.prepend(s)
|
e.rr.prepend(s)
|
||||||
e.caret.xoff = 0
|
e.caret.xoff = 0
|
||||||
e.invalidate()
|
e.invalidate()
|
||||||
|
|||||||
Reference in New Issue
Block a user