Commit Graph

10 Commits

Author SHA1 Message Date
Elias Naur 72c48a3c18 widget: fix editBuffer.WriteTo for short writes
Noticed while working in the area.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-13 13:16:19 +01:00
Elias Naur abd8c2c9a3 widget: remove debug panic
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-13 13:05:54 +01:00
Fabien Jansem 9b7ec167bc delete unicode chars with length > 1 correctly
When there were non ASCII characters (for exemple éèàçîï) in a deleted
selection or word, more characters were deleted because there was a
mismatch between runes and bytes in Delete and deleteWord

Fixes: https://todo.sr.ht/~eliasnaur/gio/330
Signed-off-by: Fabien Jansem <fabien@jansem.eu.org>
2022-01-04 17:37:00 +01:00
pierre b6e9c0324d widget: make Editor implement io.Seeker, io.Reader and io.WriterTo
The WriteTo, Seek, Read methods implement a more efficient access to
the Editor content than Text.

Signed-off-by: pierre <pierre.curto@gmail.com>
2021-05-19 17:25:42 +02:00
Larry Clapp e78bd15564 widget: refactoring to prep for editor selection
- Move caret from editBuffer.caret to Editor.caret.pos.ofs and related
  refactoring. Move other fields in Editor.caret into Editor.caret.pos.
- Refactor several functions to change a position passed into them,
  rather than changing e.rr.caret directly.
- Add editBuffer.Seek().
- Remove editBuffer.dump().
- Change Editor.Move to MoveCaret.
- Add Editor.SetCaret.
- Updated tests.

Signed-off-by: Larry Clapp <larry@theclapp.org>
2021-01-24 09:44:41 +01:00
Elias Naur ef21a7ace1 widget: maintain Editor caret position
Only call layoutCaret when the text layout changes, adjust position
for caret movement.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-20 16:50:30 +02:00
Elias Naur 4eb66d2707 widget: fix caret comparison in editBuffer.move
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-20 12:25:24 +02:00
Elias Naur b331407e81 text: add io.Reader Layout method to Shaper
use them for Editor, which is no longer required to construct a string
for laying out its content.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-13 21:38:54 +01:00
Larry Clapp 2b4e9ad426 widget: add some rudimentary exported editing methods
Editor.Delete
Editor.Move
Editor.Insert

Move the Editor.command method up above all the functions it calls.

Signed-off-by: Larry Clapp <larry@theclapp.org>
2019-12-16 19:06:09 +01:00
Elias Naur ff3fc7a24a widget,text: move Label and Editor from text to widget package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:04:34 +02:00