mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-14 16:58:05 +00:00
connect spell check by libspelling
This commit is contained in:
parent
045092cc2d
commit
6f7f50b5a2
@ -48,6 +48,9 @@ version = "0.9.1"
|
||||
[dependencies.plurify]
|
||||
version = "0.1.1"
|
||||
|
||||
[dependencies.libspelling]
|
||||
version = "0.3.0"
|
||||
|
||||
# development
|
||||
[patch.crates-io]
|
||||
# ggemini = { git = "https://github.com/YGGverse/ggemini.git" }
|
||||
|
@ -132,13 +132,14 @@ GTK 4 / Libadwaita client written in Rust
|
||||
* Glib `2.80`
|
||||
* Gtk `4.14`
|
||||
* GtkSourceView `5.14`
|
||||
* Libadwaita `1.5` (Ubuntu 24.04+)
|
||||
* libadwaita `1.5` (Ubuntu 24.04+)
|
||||
* libspelling `0.1`
|
||||
|
||||
#### Debian
|
||||
|
||||
``` bash
|
||||
sudo apt install git curl build-essential\
|
||||
libgtk-4-dev libgtksourceview-5-dev libadwaita-1-dev\
|
||||
libgtk-4-dev libgtksourceview-5-dev libadwaita-1-dev libspelling-1-dev\
|
||||
libsqlite3-dev libssl-dev
|
||||
```
|
||||
|
||||
@ -146,7 +147,7 @@ sudo apt install git curl build-essential\
|
||||
|
||||
``` bash
|
||||
sudo dnf install git curl gcc\
|
||||
gtk4-devel gtksourceview5-devel libadwaita-devel\
|
||||
gtk4-devel gtksourceview5-devel libadwaita-devel libspelling-devel\
|
||||
sqlite-devel openssl-devel
|
||||
```
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
use gtk::{
|
||||
gio::SimpleAction,
|
||||
glib::GString,
|
||||
prelude::{ActionExt, TextBufferExt, TextViewExt},
|
||||
prelude::{ActionExt, TextBufferExt, TextViewExt, WidgetExt},
|
||||
TextView, WrapMode,
|
||||
};
|
||||
use libspelling::{Checker, TextBufferAdapter};
|
||||
use sourceview::Buffer;
|
||||
|
||||
const MARGIN: i32 = 8;
|
||||
|
||||
@ -14,15 +16,27 @@ pub struct Widget {
|
||||
impl Widget {
|
||||
// Construct
|
||||
pub fn new(action_update: SimpleAction) -> Self {
|
||||
// Init [SourceView](https://gitlab.gnome.org/GNOME/gtksourceview) type buffer
|
||||
let buffer = Buffer::builder().build();
|
||||
|
||||
// Init [libspelling](https://gitlab.gnome.org/GNOME/libspelling)
|
||||
let checker = Checker::default();
|
||||
let adapter = TextBufferAdapter::new(&buffer, &checker);
|
||||
adapter.set_enabled(true);
|
||||
|
||||
// Init main widget
|
||||
let text_view = TextView::builder()
|
||||
.bottom_margin(MARGIN)
|
||||
.buffer(&buffer)
|
||||
.extra_menu(&adapter.menu_model())
|
||||
.left_margin(MARGIN)
|
||||
.right_margin(MARGIN)
|
||||
.top_margin(MARGIN)
|
||||
.wrap_mode(WrapMode::Word)
|
||||
.build();
|
||||
|
||||
text_view.insert_action_group("spelling", Some(&adapter));
|
||||
|
||||
// Init events
|
||||
text_view.buffer().connect_changed(move |_| {
|
||||
action_update.activate(None);
|
||||
|
Loading…
Reference in New Issue
Block a user