macos: link to helpful resources from Help menu

This commit is contained in:
Wez Furlong committed 2022-12-21 00:31:58 -07:00
1 parent b5aea795ca
commit 787f6550b8
10 files changed
+59 -1

No files matched your search

+1 -1
View File
@@ -65,7 +65,7 @@ metrics = { version="0.17", features=["std"]}
mlua = {version="0.8.3", features=["send"]}
mux = { path = "../mux" }
mux-lua = { path = "../lua-api-crates/mux" }
open = "3.0"
open = "3.2"
ordered-float = "3.0"
parking_lot = "0.12"
portable-pty = { path = "../pty", features = ["serde_support"]}
+24
View File
@@ -235,6 +235,30 @@ impl CommandDef {
main_menu.add_item(&help_item);
help_item.set_sub_menu(&help_menu);
help_menu.assign_as_help_menu();
for (caption, url) in [
("Documentation", "https://wezfurlong.org/wezterm/"),
/* Omitted because the underlying `open` utility rewrites the `#` to `%23`
* and matrix's URL parser doesn't like that, despite it being a core
* part of how URLs work.
(
"Discuss in realtime on Matrix",
"https://matrix.to/#/#wezterm:matrix.org",
),
*/
(
"Discuss on GitHub",
"https://github.com/wez/wezterm/discussions",
),
(
"Search or report issue on GitHub",
"https://github.com/wez/wezterm/issues",
),
] {
let item = MenuItem::new_with(caption, Some(sel!(weztermPerformKeyAssignment:)), "");
item.set_represented_item(RepresentedItem::OpenInBrowser(url.to_string()));
help_menu.add_item(&item);
}
}
}
+7
View File
@@ -213,6 +213,13 @@ impl GuiFrontEnd {
// future.
log::info!("perform: {action:?}");
}
ApplicationEvent::OpenInBrowser(url) => {
std::thread::spawn(move || {
if let Err(err) = open::that(&url) {
log::error!("Error opening {}: {:#}", url, err);
}
});
}
}
}
+8
View File
@@ -879,6 +879,14 @@ impl TermWindow {
}
Ok(true)
}
WindowEvent::OpenInBrowser(url) => {
std::thread::spawn(move || {
if let Err(err) = open::that(&url) {
log::error!("Error opening {}: {:#}", url, err);
}
});
Ok(true)
}
WindowEvent::FocusChanged(focused) => {
self.focus_changed(focused, window);
Ok(true)
+1
View File
@@ -85,6 +85,7 @@ impl MyWindow {
| WindowEvent::DraggedFile(_)
| WindowEvent::DroppedFile(_)
| WindowEvent::PerformKeyAssignment(_)
| WindowEvent::OpenInBrowser(_)
| WindowEvent::MouseLeave => {}
}
}
+2
View File
@@ -24,6 +24,8 @@ pub enum ApplicationEvent {
/// The system wants to open a command in the terminal
OpenCommandScript(String),
PerformKeyAssignment(KeyAssignment),
/// A request to open a URL in the browser
OpenInBrowser(String),
}
pub trait ConnectionOps {
+2
View File
@@ -189,6 +189,8 @@ pub enum WindowEvent {
/// Called by menubar dispatching stuff on some systems
PerformKeyAssignment(config::keyassignment::KeyAssignment),
/// Called by menubar dispatching stuff on some systems
OpenInBrowser(String),
}
pub struct WindowEventSender {
+5
View File
@@ -53,6 +53,11 @@ extern "C" fn wezterm_perform_key_assignment(
conn.dispatch_app_event(ApplicationEvent::PerformKeyAssignment(action));
}
}
Some(RepresentedItem::OpenInBrowser(url)) => {
if let Some(conn) = Connection::get() {
conn.dispatch_app_event(ApplicationEvent::OpenInBrowser(url));
}
}
None => {}
}
}
+1
View File
@@ -111,6 +111,7 @@ pub struct MenuItem {
#[derive(Clone, Debug)]
pub enum RepresentedItem {
KeyAssignment(KeyAssignment),
OpenInBrowser(String),
}
impl MenuItem {
+8
View File
@@ -1922,6 +1922,14 @@ impl WindowView {
.dispatch(WindowEvent::PerformKeyAssignment(action));
}
}
Some(RepresentedItem::OpenInBrowser(url)) => {
if let Some(this) = Self::get_this(this) {
this.inner
.borrow_mut()
.events
.dispatch(WindowEvent::OpenInBrowser(url));
}
}
None => {}
}
}