add line wrapping

This commit is contained in:
LordMZTE 2021-09-24 20:33:00 +02:00
parent d9216db411
commit b292421155

View file

@ -1,7 +1,9 @@
use gtk::{
prelude::{FrameExt, OrientableExt, TextBufferExt, TextViewExt, WidgetExt},
prelude::{FrameExt, OrientableExt, ScrolledWindowExt, TextBufferExt, TextViewExt, WidgetExt},
Inhibit,
Orientation,
PolicyType,
WrapMode,
};
use relm::{connect, Relm, Widget};
use relm_derive::{widget, Msg};
@ -71,6 +73,14 @@ impl Widget for Win {
}
fn init_view(&mut self) {
self.widgets
.input_scroll
.set_policy(PolicyType::Never, PolicyType::Automatic);
self.widgets
.output_scroll
.set_policy(PolicyType::Never, PolicyType::Automatic);
if let Some(buf) = self.widgets.input.buffer() {
connect!(buf, connect_changed(_), self.model.relm, Msg::Edited);
}
@ -84,23 +94,28 @@ impl Widget for Win {
gtk::Frame {
label: Some("Input"),
#[name = "input_scroll"]
gtk::ScrolledWindow {
hexpand: true,
vexpand: true,
#[name = "input"]
gtk::TextView {},
gtk::TextView {
wrap_mode: WrapMode::WordChar,
},
},
},
gtk::Frame {
label: Some("Output"),
#[name = "output_scroll"]
gtk::ScrolledWindow {
hexpand: true,
vexpand: true,
#[name = "output"]
gtk::TextView {
editable: false,
wrap_mode: WrapMode::WordChar,
},
},
},