implement view-source feature

This commit is contained in:
yggverse 2024-12-08 13:59:57 +02:00
parent 9784a8a1a1
commit 614aa1d71a
5 changed files with 86 additions and 25 deletions

View file

@ -0,0 +1,25 @@
use gtk::{TextBuffer, TextView};
const MARGIN: i32 = 8;
pub struct Source {
pub text_view: TextView,
}
impl Source {
pub fn new(data: &str) -> Self {
Self {
text_view: TextView::builder()
.bottom_margin(MARGIN)
.buffer(&TextBuffer::builder().text(data).build())
.cursor_visible(false)
.editable(false)
.left_margin(MARGIN)
.monospace(true)
.right_margin(MARGIN)
.top_margin(MARGIN)
.vexpand(true)
.build(),
}
}
}