mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
connect sourceview5
This commit is contained in:
parent
614aa1d71a
commit
c1fc022643
5 changed files with 29 additions and 11 deletions
|
|
@ -198,8 +198,8 @@ impl Page {
|
|||
};
|
||||
|
||||
// Detect source view mode, return `request` string prepared for route
|
||||
let (request, is_view_source) = match request.strip_prefix("view-source:") {
|
||||
Some(postfix) => (gformat!("{}", postfix.to_string()), true),
|
||||
let (request, is_view_source) = match request.strip_prefix("source:") {
|
||||
Some(postfix) => (GString::from(postfix), true),
|
||||
None => (request, false),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,29 @@
|
|||
use gtk::{TextBuffer, TextView};
|
||||
|
||||
use sourceview::{Buffer, StyleScheme, View};
|
||||
const MARGIN: i32 = 8;
|
||||
|
||||
pub struct Source {
|
||||
pub text_view: TextView,
|
||||
pub text_view: View,
|
||||
}
|
||||
|
||||
impl Source {
|
||||
pub fn new(data: &str) -> Self {
|
||||
Self {
|
||||
text_view: TextView::builder()
|
||||
text_view: View::builder()
|
||||
.bottom_margin(MARGIN)
|
||||
.buffer(&TextBuffer::builder().text(data).build())
|
||||
.buffer(
|
||||
&Buffer::builder()
|
||||
.text(data)
|
||||
.style_scheme(&StyleScheme::builder().build()) // adaptive
|
||||
.highlight_syntax(true)
|
||||
.build(),
|
||||
)
|
||||
.cursor_visible(false)
|
||||
.editable(false)
|
||||
.left_margin(MARGIN)
|
||||
.monospace(true)
|
||||
.right_margin(MARGIN)
|
||||
.show_line_marks(true)
|
||||
.show_line_numbers(true)
|
||||
.top_margin(MARGIN)
|
||||
.vexpand(true)
|
||||
.build(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue