mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 09:25:38 +00:00
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>
This commit is contained in:
@@ -1250,6 +1250,21 @@ func (e *Editor) ClearSelection() {
|
||||
e.caret.end = e.caret.start
|
||||
}
|
||||
|
||||
// WriteTo implements io.WriterTo.
|
||||
func (e *Editor) WriteTo(w io.Writer) (int64, error) {
|
||||
return e.rr.WriteTo(w)
|
||||
}
|
||||
|
||||
// Seek implements io.Seeker.
|
||||
func (e *Editor) Seek(offset int64, whence int) (int64, error) {
|
||||
return e.rr.Seek(0, io.SeekStart)
|
||||
}
|
||||
|
||||
// Read implements io.Reader.
|
||||
func (e *Editor) Read(p []byte) (int, error) {
|
||||
return e.rr.Read(p)
|
||||
}
|
||||
|
||||
func max(a, b int) int {
|
||||
if a > b {
|
||||
return a
|
||||
|
||||
Reference in New Issue
Block a user