Skip to content

Commit

Permalink
Impl Write on text buffers and Editable widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
ranfdev committed Aug 4, 2023
1 parent 413eae2 commit e5b7cdd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gtk4/src/entry_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,11 @@ impl Default for EntryBuffer {
glib::Object::new()
}
}

impl std::fmt::Write for EntryBuffer {
fn write_str(&mut self, s: &str) -> std::fmt::Result {
let pos = self.length();
self.insert_text(pos, s);
Ok(())
}
}
8 changes: 8 additions & 0 deletions gtk4/src/text_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,11 @@ pub trait TextBufferExtManual: sealed::Sealed + IsA<TextBuffer> + 'static {
}

impl<O: IsA<TextBuffer>> TextBufferExtManual for O {}

impl std::fmt::Write for TextBuffer {
fn write_str(&mut self, s: &str) -> std::fmt::Result {
let mut iter = self.end_iter();
self.insert(&mut iter, s);
Ok(())
}
}

0 comments on commit e5b7cdd

Please sign in to comment.