mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-08-03 06:38:52 +00:00
feat: vte shortcuts handled by term widget; add shift+ctrl to shortcuts
This commit is contained in:
parent
947fb33545
commit
002d178bd5
2 changed files with 46 additions and 28 deletions
|
@ -2,12 +2,10 @@ use super::term_widget::TermWidget;
|
||||||
use crate::log_level::LogLevel;
|
use crate::log_level::LogLevel;
|
||||||
use crate::log_parser::MonadoLog;
|
use crate::log_parser::MonadoLog;
|
||||||
use crate::ui::app::{DebugCopyEnvVarsAction, DebugOpenDataAction, DebugOpenPrefixAction};
|
use crate::ui::app::{DebugCopyEnvVarsAction, DebugOpenDataAction, DebugOpenPrefixAction};
|
||||||
use crate::ui::util::copy_text;
|
|
||||||
use gtk::glib::clone;
|
use gtk::glib::clone;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use relm4::prelude::*;
|
use relm4::prelude::*;
|
||||||
use relm4::{ComponentSender, SimpleComponent};
|
use relm4::{ComponentSender, SimpleComponent};
|
||||||
use vte4::TerminalExt;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum SearchDirection {
|
pub enum SearchDirection {
|
||||||
|
@ -243,29 +241,6 @@ impl SimpleComponent for DebugView {
|
||||||
};
|
};
|
||||||
model.term.set_color_scheme();
|
model.term.set_color_scheme();
|
||||||
|
|
||||||
{
|
|
||||||
let sc = gtk::ShortcutController::new();
|
|
||||||
let term = model.term.term.clone();
|
|
||||||
sc.add_shortcut(gtk::Shortcut::new(
|
|
||||||
gtk::ShortcutTrigger::parse_string("<Control>c"),
|
|
||||||
Some(gtk::CallbackAction::new(move |_, _| {
|
|
||||||
if let Some(text) = term.text_selected(vte4::Format::Text) {
|
|
||||||
copy_text(text.as_str());
|
|
||||||
}
|
|
||||||
gtk::glib::Propagation::Proceed
|
|
||||||
})),
|
|
||||||
));
|
|
||||||
let term = model.term.term.clone();
|
|
||||||
sc.add_shortcut(gtk::Shortcut::new(
|
|
||||||
gtk::ShortcutTrigger::parse_string("<Control>a"),
|
|
||||||
Some(gtk::CallbackAction::new(move |_, _| {
|
|
||||||
term.select_all();
|
|
||||||
gtk::glib::Propagation::Proceed
|
|
||||||
})),
|
|
||||||
));
|
|
||||||
model.term.term.add_controller(sc);
|
|
||||||
}
|
|
||||||
|
|
||||||
let widgets = view_output!();
|
let widgets = view_output!();
|
||||||
model.searchbar = Some(widgets.searchbar.clone());
|
model.searchbar = Some(widgets.searchbar.clone());
|
||||||
model.search_entry = Some(widgets.search_entry.clone());
|
model.search_entry = Some(widgets.search_entry.clone());
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use gtk4::gdk;
|
use gtk4::{gdk, glib::clone};
|
||||||
use relm4::adw;
|
use relm4::adw;
|
||||||
use vte4::{Terminal, TerminalExt, TerminalExtManual};
|
use vte4::{Terminal, TerminalExt, TerminalExtManual, WidgetExt};
|
||||||
|
|
||||||
|
use super::util::copy_text;
|
||||||
|
|
||||||
const MAX_SCROLLBACK: u32 = 2000;
|
const MAX_SCROLLBACK: u32 = 2000;
|
||||||
|
|
||||||
|
@ -34,7 +36,48 @@ impl TermWidget {
|
||||||
.child(&term)
|
.child(&term)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Self { container, term }
|
let this = Self { container, term };
|
||||||
|
|
||||||
|
this.setup_shortcuts();
|
||||||
|
|
||||||
|
this
|
||||||
|
}
|
||||||
|
|
||||||
|
fn setup_shortcuts(&self) {
|
||||||
|
let sc = gtk4::ShortcutController::new();
|
||||||
|
["<Control>c", "<Shift><Control>c"]
|
||||||
|
.iter()
|
||||||
|
.for_each(|combo| {
|
||||||
|
sc.add_shortcut(gtk4::Shortcut::new(
|
||||||
|
gtk4::ShortcutTrigger::parse_string(combo),
|
||||||
|
Some(gtk4::CallbackAction::new(clone!(
|
||||||
|
#[strong(rename_to = term)]
|
||||||
|
self.term,
|
||||||
|
move |_, _| {
|
||||||
|
if let Some(text) = term.text_selected(vte4::Format::Text) {
|
||||||
|
copy_text(text.as_str());
|
||||||
|
}
|
||||||
|
gtk4::glib::Propagation::Proceed
|
||||||
|
}
|
||||||
|
))),
|
||||||
|
));
|
||||||
|
});
|
||||||
|
["<Control>a", "<Shift><Control>a"]
|
||||||
|
.iter()
|
||||||
|
.for_each(|combo| {
|
||||||
|
sc.add_shortcut(gtk4::Shortcut::new(
|
||||||
|
gtk4::ShortcutTrigger::parse_string(combo),
|
||||||
|
Some(gtk4::CallbackAction::new(clone!(
|
||||||
|
#[strong(rename_to = term)]
|
||||||
|
self.term,
|
||||||
|
move |_, _| {
|
||||||
|
term.select_all();
|
||||||
|
gtk4::glib::Propagation::Proceed
|
||||||
|
}
|
||||||
|
))),
|
||||||
|
));
|
||||||
|
});
|
||||||
|
self.term.add_controller(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_color_scheme(&self) {
|
pub fn set_color_scheme(&self) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue