rust: --connect startup flag; palette launcher hint fits narrow windows
This commit is contained in:
@@ -23,6 +23,8 @@ pub struct Options {
|
||||
/// Open a window at startup: editor, quick, settings[:tab], keys, snippets, triggers,
|
||||
/// recordings, palette, export, import (screenshot checks).
|
||||
pub open: Option<String>,
|
||||
/// Connect a saved profile (by name or id) at startup.
|
||||
pub connect: Option<String>,
|
||||
}
|
||||
|
||||
/// Errors from worker threads, drained into toasts each frame.
|
||||
@@ -158,6 +160,12 @@ impl App {
|
||||
run_local: opts.run_local.map(|c| (c, None)),
|
||||
resize_sidebar: false,
|
||||
};
|
||||
if let Some(c) = opts.connect.as_deref() {
|
||||
match app.s.profiles.iter().find(|p| p.id == c || p.display_name == c).map(|p| p.id.clone()) {
|
||||
Some(id) => app.connect_profile(&id, true),
|
||||
None => eprintln!("--connect: no profile named {c:?}"),
|
||||
}
|
||||
}
|
||||
if let Some(w) = opts.open.as_deref() {
|
||||
app.open_window(w);
|
||||
}
|
||||
|
||||
@@ -194,14 +194,11 @@ pub fn title_bar(app: &mut App, ui: &mut Ui) {
|
||||
let resp = ui.interact(r, ui.id().with("palette-launch"), Sense::click());
|
||||
ui.painter().rect(r, 6.0, if resp.hovered() { t.hover } else { t.field }, Stroke::new(1.0, t.field_border), egui::StrokeKind::Inside);
|
||||
ui.painter().text(r.left_center() + vec2(9.0, 0.0), Align2::LEFT_CENTER, icon::MAGNIFYING_GLASS, egui::FontId::proportional(13.0), t.text_faint);
|
||||
ui.painter().with_clip_rect(r.shrink(2.0)).text(
|
||||
r.left_center() + vec2(28.0, 0.0),
|
||||
Align2::LEFT_CENTER,
|
||||
"Search connections and commands",
|
||||
egui::FontId::proportional(12.0),
|
||||
t.text_faint,
|
||||
);
|
||||
if w > 250.0 {
|
||||
let show_keys = w > 250.0;
|
||||
let clip = Rect::from_min_max(r.min, pos2(r.right() - if show_keys { 52.0 } else { 4.0 }, r.bottom()));
|
||||
let hint = if w > 290.0 { "Search connections and commands" } else { "Search" };
|
||||
ui.painter().with_clip_rect(clip).text(r.left_center() + vec2(28.0, 0.0), Align2::LEFT_CENTER, hint, egui::FontId::proportional(12.0), t.text_faint);
|
||||
if show_keys {
|
||||
ui.painter().text(r.right_center() - vec2(8.0, 0.0), Align2::RIGHT_CENTER, keys("Mod+K").replace('+', " "), theme::semibold(10.5), t.text_faint);
|
||||
}
|
||||
if resp.clicked() {
|
||||
|
||||
@@ -33,7 +33,7 @@ use nexus_core::service::Service;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn main() -> eframe::Result {
|
||||
let mut opts = app::Options { screenshot: None, theme: None, run_local: None, open: None };
|
||||
let mut opts = app::Options { screenshot: None, theme: None, run_local: None, open: None, connect: None };
|
||||
let mut size = [1360.0, 860.0];
|
||||
let mut data_dir = None;
|
||||
let mut args = std::env::args().skip(1);
|
||||
@@ -42,6 +42,7 @@ fn main() -> eframe::Result {
|
||||
"--theme" => opts.theme = args.next(),
|
||||
"--run-local" => opts.run_local = args.next(),
|
||||
"--open" => opts.open = args.next(),
|
||||
"--connect" => opts.connect = args.next(),
|
||||
"--screenshot" => opts.screenshot = args.next().map(Into::into),
|
||||
// Use another data directory (testing, screenshots, portable installs).
|
||||
"--data-dir" => data_dir = args.next(),
|
||||
|
||||
Reference in New Issue
Block a user