Skip to content

Commit 56e0097

Browse files
committedDec 30, 2023
update readme
1 parent 8cab916 commit 56e0097

17 files changed

+1340
-1439
lines changed
 

‎.github/FUNDING.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ liberapay: # Replace with a single Liberapay username
1010
issuehunt: # Replace with a single IssueHunt username
1111
otechie: # Replace with a single Otechie username
1212
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13-
custom: ['https://www.buymeacoffee.com/edfloreshz', 'https://www.paypal.com/paypalme/edfloreshz', 'https://donate.stripe.com/fZe9B24JU7Xa8AUdQQ']
13+
custom: ['https://www.buymeacoffee.com/vhdirk', 'https://paypal.me/vhdirk']

‎README.md

+14-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ A tiling terminal emulator for GNOME on Linux using GTK4, written in Rust.
99

1010
## Goal
1111

12-
Terms is an experiment. I like [Tilix](Tilix) and I like [Black Box](BlackBox). Why can't I have both?
12+
Terms is an experiment. I like [Tilix][Tilix] and I like [BlackBox]. Why can't I have both?
1313

1414
## Status
1515

@@ -54,10 +54,16 @@ Join the GNOME and gtk-rs community!
5454

5555
Lots of ideas and code from these projects:
5656

57-
- [Podcasts](https://gitlab.gnome.org/World/podcasts)
58-
- [Shortwave](https://gitlab.gnome.org/World/Shortwave)
59-
- [BlackBox](https://gitlab.gnome.org/raggesilver/blackbox)
60-
- [Tilix](https://github.com/gnunn1/tilix)
61-
- [Fractal](https://gitlab.gnome.org/World/fractal)
62-
- [Zoha](https://github.com/hkoosha/zoha4)
63-
57+
- [Podcasts]
58+
- [Shortwave]
59+
- [BlackBox]
60+
- [Tilix]
61+
- [Fractal]
62+
- [Zoha]
63+
64+
[Podcasts]: https://gitlab.gnome.org/World/podcasts
65+
[Shortwave]: https://gitlab.gnome.org/World/Shortwave
66+
[BlackBox]: https://gitlab.gnome.org/raggesilver/blackbox
67+
[Tilix]: https://github.com/gnunn1/tilix
68+
[Fractal]: https://gitlab.gnome.org/World/fractal
69+
[Zoha]: https://github.com/hkoosha/zoha4

‎build.rs

+33-40
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,55 @@
11
use std::{env, fs, path::Path, process::Command};
22

33
fn render_schema(gschema: &str, out_dir: &Path) {
4-
let gettext_package = env::var("GETTEXT_PACKAGE").unwrap();
5-
let app_id = env::var("APP_ID").unwrap();
4+
let gettext_package = env::var("GETTEXT_PACKAGE").unwrap();
5+
let app_id = env::var("APP_ID").unwrap();
66

7-
let contents = fs::read_to_string(gschema).unwrap();
7+
let contents = fs::read_to_string(gschema).unwrap();
88
eprintln!("{:?}", contents);
9-
let new = contents
10-
.replace("@gettext-package@", &gettext_package)
11-
.replace("@app-id@", &app_id);
9+
let new = contents.replace("@gettext-package@", &gettext_package).replace("@app-id@", &app_id);
1210

1311
let filename = Path::new(gschema).file_name().unwrap();
14-
let outfile = Path::new(filename).file_stem().unwrap();
15-
let outpath = out_dir.join(outfile);
12+
let outfile = Path::new(filename).file_stem().unwrap();
13+
let outpath = out_dir.join(outfile);
1614

17-
fs::write(outpath.clone(), new).unwrap();
15+
fs::write(outpath.clone(), new).unwrap();
1816

1917
let outpath_file = outpath.to_string_lossy();
20-
println!("cargo:rerun-if-changed={gschema}");
18+
println!("cargo:rerun-if-changed={gschema}");
2119
println!("cargo:rerun-if-changed={outpath_file}");
2220
}
2321

2422
pub fn compile_schemas<P: AsRef<Path>>(gschemas: &[P]) {
25-
let out_dir = env::var("OUT_DIR").unwrap();
26-
let out_dir = Path::new(&out_dir);
27-
28-
for gschema in gschemas {
29-
render_schema(&gschema.as_ref().to_string_lossy(), out_dir);
30-
}
31-
32-
let schema_dir = env::var("GSETTINGS_SCHEMA_DIR").unwrap();
33-
let output = Command::new("glib-compile-schemas")
34-
.arg("--targetdir")
35-
.arg(schema_dir)
36-
.arg(out_dir)
37-
.output()
38-
.unwrap();
39-
40-
assert!(
41-
output.status.success(),
42-
"glib-compile-schemas failed with exit status {} and stderr:\n{}",
43-
output.status,
44-
String::from_utf8_lossy(&output.stderr)
45-
);
23+
let out_dir = env::var("OUT_DIR").unwrap();
24+
let out_dir = Path::new(&out_dir);
25+
26+
for gschema in gschemas {
27+
render_schema(&gschema.as_ref().to_string_lossy(), out_dir);
28+
}
29+
30+
let schema_dir = env::var("GSETTINGS_SCHEMA_DIR").unwrap();
31+
let output = Command::new("glib-compile-schemas")
32+
.arg("--targetdir")
33+
.arg(schema_dir)
34+
.arg(out_dir)
35+
.output()
36+
.unwrap();
37+
38+
assert!(
39+
output.status.success(),
40+
"glib-compile-schemas failed with exit status {} and stderr:\n{}",
41+
output.status,
42+
String::from_utf8_lossy(&output.stderr)
43+
);
4644
}
4745

4846
fn compile_glib() {
49-
glib_build_tools::compile_resources(
50-
&["data/resources/"],
51-
"data/resources/resources.gresource.xml",
52-
"resources.gresource",
53-
);
54-
55-
compile_schemas(&["data/com.github.vhdirk.Terms.gschema.xml.in"]);
47+
glib_build_tools::compile_resources(&["data/resources/"], "data/resources/resources.gresource.xml", "resources.gresource");
5648

49+
compile_schemas(&["data/com.github.vhdirk.Terms.gschema.xml.in"]);
5750
}
5851

5952
fn main() {
60-
// TODO: we probably only want to do this when not running under meson
61-
compile_glib();
53+
// TODO: we probably only want to do this when not running under meson
54+
compile_glib();
6255
}

‎po/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Create a new translation
22

3-
To start translating, duplicate any of the `.po` files and start translating it,
3+
To start translating, duplicate any of the `.po` files and start translating it,
44
rename it to match your country code and add your contry code.
55

6-
Be sure to add your country code to the [LINGUAS](https://github.com/edfloreshz/done/blob/main/po/LINGUAS) file too.
6+
Be sure to add your country code to the [LINGUAS](https://github.com/vhdirk/terms/blob/main/po/LINGUAS) file too.
77

88
|Code |Language |
99
|----------|------------------------------------------|

‎rustfmt.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
edition = "2021"
2-
max_width = 80
3-
hard_tabs = true
2+
max_width = 160
3+
hard_tabs = false
44
match_block_trailing_comma = true
55
merge_derives = true
66
newline_style = "Unix"
77
reorder_imports = true
88
reorder_modules = true
9-
tab_spaces = 2
9+
tab_spaces = 4
1010
use_field_init_shorthand = true

‎src/application.rs

+203-215
Large diffs are not rendered by default.

‎src/components/header_bar.rs

+44-44
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,54 @@ use gtk::glib;
55
use gtk::prelude::*;
66

77
mod imp {
8-
use super::*;
9-
10-
#[derive(Debug, Default, gtk::CompositeTemplate)]
11-
#[template(resource = "/com/github/vhdirk/Terms/gtk/header_bar.ui")]
12-
pub struct HeaderBar {
13-
#[template_child]
14-
pub revealer: TemplateChild<gtk::Revealer>,
15-
16-
#[template_child]
17-
pub title_widget: TemplateChild<adw::WindowTitle>,
18-
}
19-
20-
#[glib::object_subclass]
21-
impl ObjectSubclass for HeaderBar {
22-
const NAME: &'static str = "TermsHeaderBar";
23-
type Type = super::HeaderBar;
24-
type ParentType = adw::Bin;
25-
26-
fn class_init(klass: &mut Self::Class) {
27-
klass.bind_template();
28-
}
29-
30-
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
31-
obj.init_template();
32-
}
33-
}
34-
35-
impl ObjectImpl for HeaderBar {}
36-
impl WidgetImpl for HeaderBar {}
37-
impl BinImpl for HeaderBar {}
8+
use super::*;
9+
10+
#[derive(Debug, Default, gtk::CompositeTemplate)]
11+
#[template(resource = "/com/github/vhdirk/Terms/gtk/header_bar.ui")]
12+
pub struct HeaderBar {
13+
#[template_child]
14+
pub revealer: TemplateChild<gtk::Revealer>,
15+
16+
#[template_child]
17+
pub title_widget: TemplateChild<adw::WindowTitle>,
18+
}
19+
20+
#[glib::object_subclass]
21+
impl ObjectSubclass for HeaderBar {
22+
const NAME: &'static str = "TermsHeaderBar";
23+
type Type = super::HeaderBar;
24+
type ParentType = adw::Bin;
25+
26+
fn class_init(klass: &mut Self::Class) {
27+
klass.bind_template();
28+
}
29+
30+
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
31+
obj.init_template();
32+
}
33+
}
34+
35+
impl ObjectImpl for HeaderBar {}
36+
impl WidgetImpl for HeaderBar {}
37+
impl BinImpl for HeaderBar {}
3838
}
3939

4040
glib::wrapper! {
41-
pub struct HeaderBar(ObjectSubclass<imp::HeaderBar>)
42-
@extends gtk::Widget, gtk::Window, gtk::HeaderBar,
43-
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
41+
pub struct HeaderBar(ObjectSubclass<imp::HeaderBar>)
42+
@extends gtk::Widget, gtk::Window, gtk::HeaderBar,
43+
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget;
4444
}
4545

4646
impl HeaderBar {
47-
pub fn new() -> Self {
48-
let obj: Self = glib::Object::builder().build();
49-
50-
match PROFILE {
51-
AppProfile::Devel => {
52-
obj.set_css_classes(&["devel"]);
53-
},
54-
_ => (),
55-
}
56-
obj
57-
}
47+
pub fn new() -> Self {
48+
let obj: Self = glib::Object::builder().build();
49+
50+
match PROFILE {
51+
AppProfile::Devel => {
52+
obj.set_css_classes(&["devel"]);
53+
},
54+
_ => (),
55+
}
56+
obj
57+
}
5858
}

‎src/components/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ mod header_bar;
22
mod session;
33
mod terminal;
44
// mod terminal_args;
5-
mod terminal_panel;
65
mod search_toolbar;
6+
mod terminal_panel;
77
mod window;
88
mod workspace;
99

1010
pub use header_bar::*;
11+
pub use search_toolbar::*;
1112
pub use session::*;
1213
pub use terminal::*;
1314
pub use terminal_panel::*;
14-
pub use search_toolbar::*;
1515
pub use window::*;
1616
pub use workspace::*;

‎src/components/search_toolbar.rs

+25-25
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,40 @@ use gtk::glib;
55
use gtk::prelude::*;
66

77
mod imp {
8-
use super::*;
8+
use super::*;
99

10-
#[derive(Debug, Default, gtk::CompositeTemplate)]
11-
#[template(resource = "/com/github/vhdirk/Terms/gtk/search_toolbar.ui")]
12-
pub struct SearchToolbar {}
10+
#[derive(Debug, Default, gtk::CompositeTemplate)]
11+
#[template(resource = "/com/github/vhdirk/Terms/gtk/search_toolbar.ui")]
12+
pub struct SearchToolbar {}
1313

14-
#[glib::object_subclass]
15-
impl ObjectSubclass for SearchToolbar {
16-
const NAME: &'static str = "TermsSearchToolbar";
17-
type Type = super::SearchToolbar;
18-
type ParentType = gtk::Widget;
14+
#[glib::object_subclass]
15+
impl ObjectSubclass for SearchToolbar {
16+
const NAME: &'static str = "TermsSearchToolbar";
17+
type Type = super::SearchToolbar;
18+
type ParentType = gtk::Widget;
1919

20-
fn class_init(klass: &mut Self::Class) {
21-
klass.bind_template();
22-
}
20+
fn class_init(klass: &mut Self::Class) {
21+
klass.bind_template();
22+
}
2323

24-
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
25-
obj.init_template();
26-
}
27-
}
24+
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
25+
obj.init_template();
26+
}
27+
}
2828

29-
impl ObjectImpl for SearchToolbar {}
30-
impl WidgetImpl for SearchToolbar {}
29+
impl ObjectImpl for SearchToolbar {}
30+
impl WidgetImpl for SearchToolbar {}
3131
}
3232

3333
glib::wrapper! {
34-
pub struct SearchToolbar(ObjectSubclass<imp::SearchToolbar>)
35-
@extends gtk::Widget,
36-
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
34+
pub struct SearchToolbar(ObjectSubclass<imp::SearchToolbar>)
35+
@extends gtk::Widget,
36+
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
3737
}
3838

3939
impl SearchToolbar {
40-
pub fn new() -> Self {
41-
let obj: Self = glib::Object::builder().build();
42-
obj
43-
}
40+
pub fn new() -> Self {
41+
let obj: Self = glib::Object::builder().build();
42+
obj
43+
}
4444
}

‎src/components/session.rs

+82-86
Original file line numberDiff line numberDiff line change
@@ -11,96 +11,92 @@ use gtk::CompositeTemplate;
1111
use super::terminal::TerminalInitArgs;
1212

1313
mod imp {
14-
use std::cell::RefCell;
15-
16-
use glib::{clone, subclass::Signal};
17-
use once_cell::sync::Lazy;
18-
19-
use crate::components::terminal_panel::TerminalPanel;
20-
21-
use super::*;
22-
23-
#[derive(Debug, Default, CompositeTemplate)]
24-
#[template(resource = "/com/github/vhdirk/Terms/gtk/session.ui")]
25-
// #[properties(wrapper_type = super::Session)]
26-
pub struct Session {
27-
pub init_args: RefCell<TerminalInitArgs>,
28-
}
29-
30-
#[glib::object_subclass]
31-
impl ObjectSubclass for Session {
32-
const NAME: &'static str = "TermsSession";
33-
type Type = super::Session;
34-
type ParentType = adw::Bin;
35-
36-
fn class_init(klass: &mut Self::Class) {
37-
klass.bind_template();
38-
}
39-
40-
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
41-
obj.init_template();
42-
}
43-
}
44-
45-
// #[glib::derived_properties]
46-
impl ObjectImpl for Session {
47-
fn constructed(&self) {
48-
self.parent_constructed();
49-
50-
self.setup_widgets();
51-
}
52-
53-
fn signals() -> &'static [Signal] {
54-
static SIGNALS: Lazy<Vec<Signal>> =
55-
Lazy::new(|| vec![Signal::builder("close").build()]);
56-
SIGNALS.as_ref()
57-
}
58-
}
59-
60-
impl WidgetImpl for Session {}
61-
impl BinImpl for Session {}
62-
63-
#[gtk::template_callbacks]
64-
impl Session {
65-
pub fn set_init_args(&self, init_args: TerminalInitArgs) {
66-
let mut args = self.init_args.borrow_mut();
67-
*args = init_args;
68-
}
69-
70-
fn setup_widgets(&self) {
71-
let panel = TerminalPanel::new(self.init_args.borrow().clone());
72-
self.obj().set_property("child", &panel);
73-
74-
panel.connect_exit(clone!(@weak self as this => move |panel| {
75-
this.obj().emit_by_name::<()>("close", &[]);
76-
}));
77-
}
78-
}
14+
use std::cell::RefCell;
15+
16+
use glib::{clone, subclass::Signal};
17+
use once_cell::sync::Lazy;
18+
19+
use crate::components::terminal_panel::TerminalPanel;
20+
21+
use super::*;
22+
23+
#[derive(Debug, Default, CompositeTemplate)]
24+
#[template(resource = "/com/github/vhdirk/Terms/gtk/session.ui")]
25+
// #[properties(wrapper_type = super::Session)]
26+
pub struct Session {
27+
pub init_args: RefCell<TerminalInitArgs>,
28+
}
29+
30+
#[glib::object_subclass]
31+
impl ObjectSubclass for Session {
32+
const NAME: &'static str = "TermsSession";
33+
type Type = super::Session;
34+
type ParentType = adw::Bin;
35+
36+
fn class_init(klass: &mut Self::Class) {
37+
klass.bind_template();
38+
}
39+
40+
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
41+
obj.init_template();
42+
}
43+
}
44+
45+
// #[glib::derived_properties]
46+
impl ObjectImpl for Session {
47+
fn constructed(&self) {
48+
self.parent_constructed();
49+
50+
self.setup_widgets();
51+
}
52+
53+
fn signals() -> &'static [Signal] {
54+
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| vec![Signal::builder("close").build()]);
55+
SIGNALS.as_ref()
56+
}
57+
}
58+
59+
impl WidgetImpl for Session {}
60+
impl BinImpl for Session {}
61+
62+
#[gtk::template_callbacks]
63+
impl Session {
64+
pub fn set_init_args(&self, init_args: TerminalInitArgs) {
65+
let mut args = self.init_args.borrow_mut();
66+
*args = init_args;
67+
}
68+
69+
fn setup_widgets(&self) {
70+
let panel = TerminalPanel::new(self.init_args.borrow().clone());
71+
self.obj().set_property("child", &panel);
72+
73+
panel.connect_exit(clone!(@weak self as this => move |panel| {
74+
this.obj().emit_by_name::<()>("close", &[]);
75+
}));
76+
}
77+
}
7978
}
8079

8180
glib::wrapper! {
82-
pub struct Session(ObjectSubclass<imp::Session>)
83-
@extends gtk::Widget, adw::Bin,
84-
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
81+
pub struct Session(ObjectSubclass<imp::Session>)
82+
@extends gtk::Widget, adw::Bin,
83+
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
8584
}
8685

8786
impl Session {
88-
pub fn new(init_args: TerminalInitArgs) -> Self {
89-
let obj: Self = glib::Object::builder().build();
90-
obj.imp().set_init_args(init_args);
91-
obj
92-
}
93-
94-
pub fn connect_close<F: Fn(&Self) + 'static>(
95-
&self,
96-
f: F,
97-
) -> glib::SignalHandlerId {
98-
self.connect_closure(
99-
"close",
100-
true,
101-
closure_local!(move |obj: Session| {
102-
f(&obj);
103-
}),
104-
)
105-
}
87+
pub fn new(init_args: TerminalInitArgs) -> Self {
88+
let obj: Self = glib::Object::builder().build();
89+
obj.imp().set_init_args(init_args);
90+
obj
91+
}
92+
93+
pub fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> glib::SignalHandlerId {
94+
self.connect_closure(
95+
"close",
96+
true,
97+
closure_local!(move |obj: Session| {
98+
f(&obj);
99+
}),
100+
)
101+
}
106102
}

‎src/components/terminal.rs

+241-272
Large diffs are not rendered by default.

‎src/components/terminal_panel.rs

+91-98
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,108 @@
1-
use std::path::PathBuf;
2-
3-
use crate::components::{Terminal, TerminalInitArgs, SearchToolbar};
1+
use crate::components::{SearchToolbar, Terminal, TerminalInitArgs};
42
use adw::subclass::prelude::*;
53
use glib::value::ValueType;
64
use glib::{closure_local, ObjectExt, Value};
75
use gtk::glib;
86
use gtk::CompositeTemplate;
97

108
mod imp {
11-
use std::cell::{Cell, RefCell};
12-
13-
use glib::{clone, closure_local, subclass::Signal, ObjectExt};
14-
use once_cell::sync::Lazy;
15-
16-
use super::*;
17-
18-
#[derive(Debug, Default, CompositeTemplate)]
19-
#[template(resource = "/com/github/vhdirk/Terms/gtk/terminal_panel.ui")]
20-
// #[properties(wrapper_type = super::TerminalPanel)]
21-
pub struct TerminalPanel {
22-
pub init_args: RefCell<TerminalInitArgs>,
23-
24-
#[template_child]
25-
terminal: TemplateChild<Terminal>,
26-
27-
#[template_child]
28-
search_toolbar: TemplateChild<SearchToolbar>,
29-
}
30-
31-
#[glib::object_subclass]
32-
impl ObjectSubclass for TerminalPanel {
33-
const NAME: &'static str = "TermsTerminalPanel";
34-
type Type = super::TerminalPanel;
35-
type ParentType = gtk::Box;
36-
37-
fn class_init(klass: &mut Self::Class) {
38-
klass.bind_template();
39-
}
40-
41-
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
42-
obj.init_template();
43-
}
44-
}
45-
46-
// #[glib::derived_properties]
47-
impl ObjectImpl for TerminalPanel {
48-
fn constructed(&self) {
49-
self.parent_constructed();
50-
51-
self.setup_widgets();
52-
}
53-
54-
fn signals() -> &'static [Signal] {
55-
static SIGNALS: Lazy<Vec<Signal>> =
56-
Lazy::new(|| vec![Signal::builder("exit").build()]);
57-
SIGNALS.as_ref()
58-
}
59-
}
60-
61-
impl WidgetImpl for TerminalPanel {}
62-
impl BoxImpl for TerminalPanel {}
63-
64-
#[gtk::template_callbacks]
65-
impl TerminalPanel {
66-
pub fn set_init_args(&self, init_args: TerminalInitArgs) {
67-
let mut args = self.init_args.borrow_mut();
68-
*args = init_args;
69-
}
70-
71-
fn setup_widgets(&self) {
72-
self.connect_signals();
73-
}
74-
75-
fn connect_signals(&self) {
76-
dbg!("Connect exit closure");
77-
self.terminal.connect_exit(
78-
clone!(@weak self as this => move |_terminal: &Terminal , status: i32| {
79-
println!("Terminal exited with {}", status);
80-
this.obj().emit_by_name::<()>("exit", &[]);
81-
}),
82-
);
83-
}
84-
}
9+
use std::cell::{Cell, RefCell};
10+
11+
use glib::{clone, closure_local, subclass::Signal, ObjectExt};
12+
use once_cell::sync::Lazy;
13+
14+
use super::*;
15+
16+
#[derive(Debug, Default, CompositeTemplate)]
17+
#[template(resource = "/com/github/vhdirk/Terms/gtk/terminal_panel.ui")]
18+
// #[properties(wrapper_type = super::TerminalPanel)]
19+
pub struct TerminalPanel {
20+
pub init_args: RefCell<TerminalInitArgs>,
21+
22+
#[template_child]
23+
terminal: TemplateChild<Terminal>,
24+
25+
#[template_child]
26+
search_toolbar: TemplateChild<SearchToolbar>,
27+
}
28+
29+
#[glib::object_subclass]
30+
impl ObjectSubclass for TerminalPanel {
31+
const NAME: &'static str = "TermsTerminalPanel";
32+
type Type = super::TerminalPanel;
33+
type ParentType = gtk::Box;
34+
35+
fn class_init(klass: &mut Self::Class) {
36+
klass.bind_template();
37+
}
38+
39+
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
40+
obj.init_template();
41+
}
42+
}
43+
44+
// #[glib::derived_properties]
45+
impl ObjectImpl for TerminalPanel {
46+
fn constructed(&self) {
47+
self.parent_constructed();
48+
49+
self.setup_widgets();
50+
}
51+
52+
fn signals() -> &'static [Signal] {
53+
static SIGNALS: Lazy<Vec<Signal>> = Lazy::new(|| vec![Signal::builder("exit").build()]);
54+
SIGNALS.as_ref()
55+
}
56+
}
57+
58+
impl WidgetImpl for TerminalPanel {}
59+
impl BoxImpl for TerminalPanel {}
60+
61+
#[gtk::template_callbacks]
62+
impl TerminalPanel {
63+
pub fn set_init_args(&self, init_args: TerminalInitArgs) {
64+
let mut args = self.init_args.borrow_mut();
65+
*args = init_args;
66+
}
67+
68+
fn setup_widgets(&self) {
69+
self.connect_signals();
70+
}
71+
72+
fn connect_signals(&self) {
73+
dbg!("Connect exit closure");
74+
self.terminal
75+
.connect_exit(clone!(@weak self as this => move |_terminal: &Terminal , status: i32| {
76+
println!("Terminal exited with {}", status);
77+
this.obj().emit_by_name::<()>("exit", &[]);
78+
}));
79+
}
80+
}
8581
}
8682

8783
glib::wrapper! {
88-
pub struct TerminalPanel(ObjectSubclass<imp::TerminalPanel>)
89-
@extends gtk::Widget, gtk::Box,
90-
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
84+
pub struct TerminalPanel(ObjectSubclass<imp::TerminalPanel>)
85+
@extends gtk::Widget, gtk::Box,
86+
@implements gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
9187
}
9288

9389
#[gtk::template_callbacks]
9490
impl TerminalPanel {
95-
pub fn new(init_args: TerminalInitArgs) -> Self {
96-
let obj: Self = glib::Object::builder().build();
97-
obj.imp().set_init_args(init_args);
98-
obj
99-
}
100-
101-
pub fn connect_exit<F: Fn(&Self) + 'static>(
102-
&self,
103-
f: F,
104-
) -> glib::SignalHandlerId {
105-
self.connect_closure(
106-
"exit",
107-
true,
108-
closure_local!(move |obj: TerminalPanel| {
109-
f(&obj);
110-
}),
111-
)
112-
}
91+
pub fn new(init_args: TerminalInitArgs) -> Self {
92+
let obj: Self = glib::Object::builder().build();
93+
obj.imp().set_init_args(init_args);
94+
obj
95+
}
96+
97+
pub fn connect_exit<F: Fn(&Self) + 'static>(&self, f: F) -> glib::SignalHandlerId {
98+
self.connect_closure(
99+
"exit",
100+
true,
101+
closure_local!(move |obj: TerminalPanel| {
102+
f(&obj);
103+
}),
104+
)
105+
}
113106
}
114107

115108
// // // <child>

‎src/components/window.rs

+68-75
Original file line numberDiff line numberDiff line change
@@ -9,107 +9,100 @@ use super::{HeaderBar, Session, Terminal, TerminalInitArgs, TerminalPanel};
99

1010
mod imp {
1111

12-
use super::*;
12+
use super::*;
1313

14-
// var builder = new Gtk.Builder.from_resource ("/com/raggesilver/BlackBox/gtk/tab-menu.ui");
15-
// this.tab_view.menu_model = builder.get_object ("tab-menu") as GLib.Menu;
14+
// var builder = new Gtk.Builder.from_resource ("/com/raggesilver/BlackBox/gtk/tab-menu.ui");
15+
// this.tab_view.menu_model = builder.get_object ("tab-menu") as GLib.Menu;
1616

17-
// this.layout_box.append (this.header_bar_revealer);
18-
// this.layout_box.append (this.tab_view);
17+
// this.layout_box.append (this.header_bar_revealer);
18+
// this.layout_box.append (this.tab_view);
1919

20-
// this.overlay = new Gtk.Overlay ();
21-
// this.overlay.child = this.layout_box;
20+
// this.overlay = new Gtk.Overlay ();
21+
// this.overlay.child = this.layout_box;
2222

23-
// this.content = this.overlay;
23+
// this.content = this.overlay;
2424

25-
// this.set_name ("blackbox-main-window");
25+
// this.set_name ("blackbox-main-window");
2626

27-
#[derive(Debug, Default, gtk::CompositeTemplate)]
28-
#[template(resource = "/com/github/vhdirk/Terms/gtk/window.ui")]
29-
pub struct Window {
30-
pub init_args: RefCell<TerminalInitArgs>,
27+
#[derive(Debug, Default, gtk::CompositeTemplate)]
28+
#[template(resource = "/com/github/vhdirk/Terms/gtk/window.ui")]
29+
pub struct Window {
30+
pub init_args: RefCell<TerminalInitArgs>,
3131

32-
#[template_child]
33-
pub header_bar: TemplateChild<HeaderBar>,
32+
#[template_child]
33+
pub header_bar: TemplateChild<HeaderBar>,
3434

35-
#[template_child]
36-
pub tab_view: TemplateChild<adw::TabView>,
37-
}
35+
#[template_child]
36+
pub tab_view: TemplateChild<adw::TabView>,
37+
}
3838

39-
#[glib::object_subclass]
40-
impl ObjectSubclass for Window {
41-
const NAME: &'static str = "TermsWindow";
42-
type Type = super::Window;
43-
type ParentType = adw::ApplicationWindow;
39+
#[glib::object_subclass]
40+
impl ObjectSubclass for Window {
41+
const NAME: &'static str = "TermsWindow";
42+
type Type = super::Window;
43+
type ParentType = adw::ApplicationWindow;
4444

45-
fn class_init(klass: &mut Self::Class) {
46-
klass.bind_template();
47-
}
45+
fn class_init(klass: &mut Self::Class) {
46+
klass.bind_template();
47+
}
4848

49-
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
50-
obj.init_template();
51-
}
52-
}
49+
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
50+
obj.init_template();
51+
}
52+
}
5353

54-
impl ObjectImpl for Window {
55-
fn constructed(&self) {
56-
self.parent_constructed();
54+
impl ObjectImpl for Window {
55+
fn constructed(&self) {
56+
self.parent_constructed();
5757

58-
self.setup_widgets();
59-
}
60-
}
58+
self.setup_widgets();
59+
}
60+
}
6161

62-
impl WidgetImpl for Window {}
63-
impl WindowImpl for Window {}
64-
impl ApplicationWindowImpl for Window {}
65-
impl AdwApplicationWindowImpl for Window {}
66-
// impl WorkspaceImpl for Window {}
62+
impl WidgetImpl for Window {}
63+
impl WindowImpl for Window {}
64+
impl ApplicationWindowImpl for Window {}
65+
impl AdwApplicationWindowImpl for Window {}
66+
// impl WorkspaceImpl for Window {}
6767

68-
impl Window {
69-
fn setup_widgets(&self) {
70-
let session = Session::new(self.init_args.borrow().clone());
71-
self.tab_view.append(&session);
68+
impl Window {
69+
fn setup_widgets(&self) {
70+
let session = Session::new(self.init_args.borrow().clone());
71+
self.tab_view.append(&session);
7272

73-
session.connect_close(
74-
clone!(@weak self as this => move |session: &Session| {
75-
this.tab_view.close_page(&this.tab_view.page(session));
73+
session.connect_close(clone!(@weak self as this => move |session: &Session| {
74+
this.tab_view.close_page(&this.tab_view.page(session));
7675

77-
if this.tab_view.n_pages() == 0 {
78-
this.obj().close();
79-
}
80-
}),
81-
);
76+
if this.tab_view.n_pages() == 0 {
77+
this.obj().close();
78+
}
79+
}));
8280

83-
self.connect_signals();
84-
}
81+
self.connect_signals();
82+
}
8583

86-
fn connect_signals(&self) {}
84+
fn connect_signals(&self) {}
8785

88-
pub fn set_init_args(&self, init_args: TerminalInitArgs) {
89-
let mut args = self.init_args.borrow_mut();
90-
*args = init_args;
91-
}
92-
}
86+
pub fn set_init_args(&self, init_args: TerminalInitArgs) {
87+
let mut args = self.init_args.borrow_mut();
88+
*args = init_args;
89+
}
90+
}
9391
}
9492

9593
glib::wrapper! {
96-
pub struct Window(ObjectSubclass<imp::Window>)
97-
@extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow, //, panel::Workspace,
98-
@implements gio::ActionGroup, gio::ActionMap; //, gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
94+
pub struct Window(ObjectSubclass<imp::Window>)
95+
@extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow, //, panel::Workspace,
96+
@implements gio::ActionGroup, gio::ActionMap; //, gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
9997
}
10098

10199
impl Window {
102-
pub fn new<P: glib::IsA<gtk::Application>>(
103-
application: &P,
104-
init_args: TerminalInitArgs,
105-
) -> Self {
106-
let this: Self = glib::Object::builder()
107-
.property("application", application)
108-
.build();
109-
this.imp().set_init_args(init_args);
110-
111-
this
112-
}
100+
pub fn new<P: glib::IsA<gtk::Application>>(application: &P, init_args: TerminalInitArgs) -> Self {
101+
let this: Self = glib::Object::builder().property("application", application).build();
102+
this.imp().set_init_args(init_args);
103+
104+
this
105+
}
113106
}
114107

115108
// use super::{app_header::AppHeaderModel, session::SessionModel};

‎src/components/workspace.rs

+81-88
Original file line numberDiff line numberDiff line change
@@ -6,125 +6,118 @@ use panel::subclass::prelude::*;
66
use super::terminal::TerminalInitArgs;
77

88
mod imp {
9-
use std::cell::RefCell;
9+
use std::cell::RefCell;
1010

11-
use glib::{clone, closure_local, RustClosure};
11+
use glib::{clone, closure_local, RustClosure};
1212

13-
use crate::components::{
14-
header_bar::HeaderBar,
15-
terminal::{Terminal, TerminalInitArgs},
16-
terminal_panel::TerminalPanel,
17-
};
13+
use crate::components::{
14+
header_bar::HeaderBar,
15+
terminal::{Terminal, TerminalInitArgs},
16+
terminal_panel::TerminalPanel,
17+
};
1818

19-
use super::*;
19+
use super::*;
2020

21-
// var builder = new Gtk.Builder.from_resource ("/com/raggesilver/BlackBox/gtk/tab-menu.ui");
22-
// this.tab_view.menu_model = builder.get_object ("tab-menu") as GLib.Menu;
21+
// var builder = new Gtk.Builder.from_resource ("/com/raggesilver/BlackBox/gtk/tab-menu.ui");
22+
// this.tab_view.menu_model = builder.get_object ("tab-menu") as GLib.Menu;
2323

24-
// this.layout_box.append (this.header_bar_revealer);
25-
// this.layout_box.append (this.tab_view);
24+
// this.layout_box.append (this.header_bar_revealer);
25+
// this.layout_box.append (this.tab_view);
2626

27-
// this.overlay = new Gtk.Overlay ();
28-
// this.overlay.child = this.layout_box;
27+
// this.overlay = new Gtk.Overlay ();
28+
// this.overlay.child = this.layout_box;
2929

30-
// this.content = this.overlay;
30+
// this.content = this.overlay;
3131

32-
// this.set_name ("blackbox-main-Workspace");
32+
// this.set_name ("blackbox-main-Workspace");
3333

34-
#[derive(Debug, Default, gtk::CompositeTemplate)]
35-
#[template(resource = "/com/github/vhdirk/Terms/gtk/workspace.ui")]
36-
pub struct Workspace {
37-
pub init_args: RefCell<TerminalInitArgs>,
34+
#[derive(Debug, Default, gtk::CompositeTemplate)]
35+
#[template(resource = "/com/github/vhdirk/Terms/gtk/workspace.ui")]
36+
pub struct Workspace {
37+
pub init_args: RefCell<TerminalInitArgs>,
3838

39-
#[template_child]
40-
pub header_bar: TemplateChild<HeaderBar>,
39+
#[template_child]
40+
pub header_bar: TemplateChild<HeaderBar>,
4141

42-
#[template_child]
43-
pub tab_view: TemplateChild<adw::TabView>,
44-
}
42+
#[template_child]
43+
pub tab_view: TemplateChild<adw::TabView>,
44+
}
4545

46-
#[glib::object_subclass]
47-
impl ObjectSubclass for Workspace {
48-
const NAME: &'static str = "TermsWorkspace";
49-
type Type = super::Workspace;
50-
type ParentType = panel::Workspace;
46+
#[glib::object_subclass]
47+
impl ObjectSubclass for Workspace {
48+
const NAME: &'static str = "TermsWorkspace";
49+
type Type = super::Workspace;
50+
type ParentType = panel::Workspace;
5151

52-
fn class_init(klass: &mut Self::Class) {
53-
klass.bind_template();
54-
}
52+
fn class_init(klass: &mut Self::Class) {
53+
klass.bind_template();
54+
}
5555

56-
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
57-
obj.init_template();
58-
}
59-
}
56+
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
57+
obj.init_template();
58+
}
59+
}
6060

61-
impl ObjectImpl for Workspace {
62-
fn constructed(&self) {
63-
self.parent_constructed();
61+
impl ObjectImpl for Workspace {
62+
fn constructed(&self) {
63+
self.parent_constructed();
6464

65-
self.setup_widgets();
66-
}
67-
}
65+
self.setup_widgets();
66+
}
67+
}
6868

69-
impl WidgetImpl for Workspace {}
70-
impl WindowImpl for Workspace {}
71-
impl ApplicationWindowImpl for Workspace {}
72-
impl AdwApplicationWindowImpl for Workspace {}
73-
impl WorkspaceImpl for Workspace {}
69+
impl WidgetImpl for Workspace {}
70+
impl WindowImpl for Workspace {}
71+
impl ApplicationWindowImpl for Workspace {}
72+
impl AdwApplicationWindowImpl for Workspace {}
73+
impl WorkspaceImpl for Workspace {}
7474

75-
impl Workspace {
76-
fn setup_widgets(&self) {
77-
let panel = TerminalPanel::new(self.init_args.borrow().clone());
78-
self.tab_view.append(&panel);
75+
impl Workspace {
76+
fn setup_widgets(&self) {
77+
let panel = TerminalPanel::new(self.init_args.borrow().clone());
78+
self.tab_view.append(&panel);
7979

80-
panel.connect_exit(
81-
clone!(@weak self as this => move |panel: &TerminalPanel| {
82-
this.tab_view.close_page(&this.tab_view.page(panel));
80+
panel.connect_exit(clone!(@weak self as this => move |panel: &TerminalPanel| {
81+
this.tab_view.close_page(&this.tab_view.page(panel));
8382

84-
if this.tab_view.n_pages() == 0 {
85-
this.obj().close();
86-
}
87-
}),
88-
);
83+
if this.tab_view.n_pages() == 0 {
84+
this.obj().close();
85+
}
86+
}));
8987

90-
// panel.connect_closure(
91-
// "exit",
92-
// false,
93-
// RustClosure::new_local(clone!(@weak self as this, move |_terminal: TerminalPanel| {
88+
// panel.connect_closure(
89+
// "exit",
90+
// false,
91+
// RustClosure::new_local(clone!(@weak self as this, move |_terminal: TerminalPanel| {
9492

95-
// })),
96-
// );
93+
// })),
94+
// );
9795

98-
self.connect_signals();
99-
}
96+
self.connect_signals();
97+
}
10098

101-
fn connect_signals(&self) {}
99+
fn connect_signals(&self) {}
102100

103-
pub fn set_init_args(&self, init_args: TerminalInitArgs) {
104-
let mut args = self.init_args.borrow_mut();
105-
*args = init_args;
106-
}
107-
}
101+
pub fn set_init_args(&self, init_args: TerminalInitArgs) {
102+
let mut args = self.init_args.borrow_mut();
103+
*args = init_args;
104+
}
105+
}
108106
}
109107

110108
glib::wrapper! {
111-
pub struct Workspace(ObjectSubclass<imp::Workspace>)
112-
@extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow, panel::Workspace,
113-
@implements gio::ActionGroup, gio::ActionMap, gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
109+
pub struct Workspace(ObjectSubclass<imp::Workspace>)
110+
@extends gtk::Widget, gtk::Window, gtk::ApplicationWindow, adw::ApplicationWindow, panel::Workspace,
111+
@implements gio::ActionGroup, gio::ActionMap, gtk::Accessible, gtk::Buildable, gtk::ConstraintTarget, gtk::Native, gtk::Root, gtk::ShortcutManager;
114112
}
115113

116114
impl Workspace {
117-
pub fn new<P: glib::IsA<gtk::Application>>(
118-
application: &P,
119-
init_args: TerminalInitArgs,
120-
) -> Self {
121-
let this: Self = glib::Object::builder()
122-
.property("application", application)
123-
.build();
124-
this.imp().set_init_args(init_args);
125-
126-
this
127-
}
115+
pub fn new<P: glib::IsA<gtk::Application>>(application: &P, init_args: TerminalInitArgs) -> Self {
116+
let this: Self = glib::Object::builder().property("application", application).build();
117+
this.imp().set_init_args(init_args);
118+
119+
this
120+
}
128121
}
129122

130123
// use super::{app_header::AppHeaderModel, session::SessionModel};

‎src/main.rs

+50-59
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ mod utils;
1010

1111
use application::Application;
1212

13-
1413
// #[doc(hidden)]
1514
// pub fn resources_register_include_impl(bytes: &'static [u8]) -> Result<(), glib::Error> {
1615
// let bytes = glib::Bytes::from_static(bytes);
@@ -37,84 +36,76 @@ use application::Application;
3736
// };
3837
// }
3938

40-
4139
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
4240
pub enum ColorScheme {
43-
Dark,
44-
Light,
45-
Default,
41+
Dark,
42+
Light,
43+
Default,
4644
}
4745

4846
impl Default for ColorScheme {
49-
fn default() -> Self {
50-
Self::Default
51-
}
47+
fn default() -> Self {
48+
Self::Default
49+
}
5250
}
5351

5452
fn init_appearance() -> Result<(), glib::Error> {
55-
// let project = Project::open("dev", "edfloreshz", "done").unwrap();
56-
// match project.get_file_as::<Preferences>("preferences", FileFormat::JSON) {
57-
// Ok(preferences) => {
58-
// let color_scheme = match preferences.color_scheme {
59-
// ColorScheme::Dark => adw::ColorScheme::ForceDark,
60-
// ColorScheme::Light => adw::ColorScheme::ForceLight,
61-
// ColorScheme::Default => adw::ColorScheme::Default,
62-
// };
63-
// adw::StyleManager::default().set_color_scheme(color_scheme);
64-
// },
65-
// Err(err) => {
66-
// tracing::error!("Failed to open settings: {}", err.to_string())
67-
// },
68-
// }
69-
Ok(())
53+
// let project = Project::open("com", "github", "vhdirk", "terms").unwrap();
54+
// match project.get_file_as::<Preferences>("preferences", FileFormat::JSON) {
55+
// Ok(preferences) => {
56+
// let color_scheme = match preferences.color_scheme {
57+
// ColorScheme::Dark => adw::ColorScheme::ForceDark,
58+
// ColorScheme::Light => adw::ColorScheme::ForceLight,
59+
// ColorScheme::Default => adw::ColorScheme::Default,
60+
// };
61+
// adw::StyleManager::default().set_color_scheme(color_scheme);
62+
// },
63+
// Err(err) => {
64+
// tracing::error!("Failed to open settings: {}", err.to_string())
65+
// },
66+
// }
67+
Ok(())
7068
}
7169

7270
fn init_gettext() {
73-
gettextrs::setlocale(LocaleCategory::LcAll, "");
74-
gettextrs::bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR)
75-
.expect("Unable to bind the text domain");
76-
gettextrs::bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8")
77-
.expect("Unable to set the text domain encoding");
78-
gettextrs::textdomain(GETTEXT_PACKAGE)
79-
.expect("Unable to switch to the text domain");
71+
gettextrs::setlocale(LocaleCategory::LcAll, "");
72+
gettextrs::bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Unable to bind the text domain");
73+
gettextrs::bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8").expect("Unable to set the text domain encoding");
74+
gettextrs::textdomain(GETTEXT_PACKAGE).expect("Unable to switch to the text domain");
8075
}
8176

8277
fn init_resource() -> Result<(), glib::Error> {
83-
glib::set_application_name(&gettext("Terms"));
84-
gio::resources_register_include!("resources.gresource")?;
85-
let provider = gtk::CssProvider::new();
86-
provider.load_from_resource("/com/github/vhdirk/Terms/gtk/style.css");
87-
if let Some(display) = gdk::Display::default() {
88-
gtk::style_context_add_provider_for_display(
89-
&display,
90-
&provider,
91-
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
92-
);
93-
}
94-
gtk::Window::set_default_icon_name(APP_ID);
95-
Ok(())
78+
glib::set_application_name(&gettext("Terms"));
79+
gio::resources_register_include!("resources.gresource")?;
80+
let provider = gtk::CssProvider::new();
81+
provider.load_from_resource("/com/github/vhdirk/Terms/gtk/style.css");
82+
if let Some(display) = gdk::Display::default() {
83+
gtk::style_context_add_provider_for_display(&display, &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION);
84+
}
85+
gtk::Window::set_default_icon_name(APP_ID);
86+
Ok(())
9687
}
9788

9889
pub fn init() -> Result<(), glib::Error> {
99-
gtk::init().expect("Could not initialize gtk");
100-
adw::init().expect("Could not initialize libadwaita");
101-
panel::init();
90+
gtk::init().expect("Could not initialize gtk");
91+
adw::init().expect("Could not initialize libadwaita");
92+
panel::init();
10293

103-
init_gettext();
104-
tracing_subscriber::fmt()
105-
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::FULL)
106-
.with_max_level(tracing::Level::INFO)
107-
.init();
108-
init_resource()?;
109-
init_appearance()?;
110-
Ok(())
94+
init_gettext();
95+
tracing_subscriber::fmt()
96+
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::FULL)
97+
.with_max_level(tracing::Level::INFO)
98+
.init();
99+
init_resource()?;
100+
init_appearance()?;
101+
Ok(())
111102
}
112103

113104
fn main() -> glib::ExitCode {
114-
init().expect("Could not initialize");
115-
// Create a new application
116-
let app = Application::new();
105+
init().expect("Could not initialize");
106+
// Create a new application
107+
let app = Application::new();
117108

118-
// Run the application
119-
app.run()
109+
// Run the application
110+
app.run()
120111
}

‎src/services/sandbox.rs

+372-382
Large diffs are not rendered by default.

‎src/utils/constants.rs

+28-39
Original file line numberDiff line numberDiff line change
@@ -7,55 +7,44 @@ pub const USERCHARS: &'static str = "-[:alnum:]";
77
pub const USERCHARS_CLASS: &'static str = concat!("[", USERCHARS, "]");
88
pub const PASSCHARS_CLASS: &'static str = "[-[:alnum:]\\Q,?;.:/!%$^*&~\"#'\\E]";
99
pub const HOSTCHARS_CLASS: &'static str = "[-[:alnum:]]";
10-
pub const HOST: &'static str =
11-
concat!(HOSTCHARS_CLASS, "+(\\.", HOSTCHARS_CLASS, "+)*");
10+
pub const HOST: &'static str = concat!(HOSTCHARS_CLASS, "+(\\.", HOSTCHARS_CLASS, "+)*");
1211
pub const PORT: &'static str = "(?:\\:[[:digit:]]{1,5})?";
1312
pub const PATHCHARS_CLASS: &'static str = "[-[:alnum:]\\Q_$.+!*,;:@&=?/~#%\\E]";
1413
pub const PATHTERM_CLASS: &'static str = "[^\\Q]'.}>) \t\r\n,\"\\E]";
1514
pub const SCHEME: &'static str = concat!(
16-
"(?:news:|telnet:|nntp:|file:\\/|https?:|ftps?:|sftp:|webcal:",
17-
"|irc:|sftp:|ldaps?:|nfs:|smb:|rsync:|ssh:|rlogin:|telnet:|git:",
18-
"|git\\+ssh:|bzr:|bzr\\+ssh:|svn:|svn\\+ssh:|hg:|mailto:|magnet:)"
15+
"(?:news:|telnet:|nntp:|file:\\/|https?:|ftps?:|sftp:|webcal:",
16+
"|irc:|sftp:|ldaps?:|nfs:|smb:|rsync:|ssh:|rlogin:|telnet:|git:",
17+
"|git\\+ssh:|bzr:|bzr\\+ssh:|svn:|svn\\+ssh:|hg:|mailto:|magnet:)"
1918
);
2019

21-
pub const USERPASS: &'static str =
22-
concat!(USERCHARS_CLASS, "+(?:", PASSCHARS_CLASS, "+)?");
20+
pub const USERPASS: &'static str = concat!(USERCHARS_CLASS, "+(?:", PASSCHARS_CLASS, "+)?");
2321
pub const URLPATH: &'static str = concat!(
24-
"(?:(/",
25-
PATHCHARS_CLASS,
26-
"+(?:[(]",
27-
PATHCHARS_CLASS,
28-
"*[)])*",
29-
PATHCHARS_CLASS,
30-
"*)*",
31-
PATHTERM_CLASS,
32-
")?"
22+
"(?:(/",
23+
PATHCHARS_CLASS,
24+
"+(?:[(]",
25+
PATHCHARS_CLASS,
26+
"*[)])*",
27+
PATHCHARS_CLASS,
28+
"*)*",
29+
PATHTERM_CLASS,
30+
")?"
3331
);
3432

3533
pub const URL_REGEX_STRINGS: [&str; 5] = [
36-
concat!(SCHEME, "//(?:", USERPASS, "\\@)?", HOST, PORT, URLPATH),
37-
concat!("(?:www|ftp)", HOSTCHARS_CLASS, "*\\.", HOST, PORT, URLPATH),
38-
concat!(
39-
"(?:callto:|h323:|sip:)",
40-
USERCHARS_CLASS,
41-
"[",
42-
USERCHARS,
43-
".]*(?:",
44-
PORT,
45-
"/[a-z0-9]+)?\\@",
46-
HOST
47-
),
48-
concat!(
49-
"(?:mailto:)?",
50-
USERCHARS_CLASS,
51-
"[",
52-
USERCHARS,
53-
".]*\\@",
54-
HOSTCHARS_CLASS,
55-
"+\\.",
56-
HOST
57-
),
58-
"(?:news:|man:|info:)[[:alnum:]\\Q^_{|}~!\"#$%&'()*+,./;:=?`\\E]+",
34+
concat!(SCHEME, "//(?:", USERPASS, "\\@)?", HOST, PORT, URLPATH),
35+
concat!("(?:www|ftp)", HOSTCHARS_CLASS, "*\\.", HOST, PORT, URLPATH),
36+
concat!(
37+
"(?:callto:|h323:|sip:)",
38+
USERCHARS_CLASS,
39+
"[",
40+
USERCHARS,
41+
".]*(?:",
42+
PORT,
43+
"/[a-z0-9]+)?\\@",
44+
HOST
45+
),
46+
concat!("(?:mailto:)?", USERCHARS_CLASS, "[", USERCHARS, ".]*\\@", HOSTCHARS_CLASS, "+\\.", HOST),
47+
"(?:news:|man:|info:)[[:alnum:]\\Q^_{|}~!\"#$%&'()*+,./;:=?`\\E]+",
5948
];
6049

6150
// pub const MENU_BUTTON_ALTERNATIVE: &'static str =

0 commit comments

Comments
 (0)
Please sign in to comment.