Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
03e8d4c
feat(ui): the Script pane finds and replaces text, with Ctrl+F (#2996)
jgregoriorincon Nov 26, 2026
20872f8
fix(ui): Ctrl+F and Ctrl+H in the Script box leave AltGr alone (#2996)
jgregoriorincon Nov 26, 2026
45d45e6
fix(ui): the Script find query has a length limit and Enter keeps the…
jgregoriorincon Nov 26, 2026
cb6a3d2
fix(ui): the Script find limits the replacement, guards the whole sea…
jgregoriorincon Nov 26, 2026
bb51dc9
fix(web): the Script find chords leave Ctrl+Alt to the browser (#2996)
jgregoriorincon Nov 26, 2026
f8cfa6b
fix(web): refresh the Script find chords after the UI pass too (#2996)
jgregoriorincon Nov 26, 2026
78d9243
fix(ui): the Script find says what a longer paste leaves out (#2996)
jgregoriorincon Nov 26, 2026
1115a6e
fix(ui): each Script find field keeps its own note of what was cut (#…
jgregoriorincon Nov 26, 2026
be0fe8e
fix(ui): a selection that fills the Script find query drops the old c…
jgregoriorincon Nov 26, 2026
99c7305
fix(ui): the Script find keeps the keyboard, starts over with the pro…
jgregoriorincon Nov 26, 2026
0609357
refactor(ui): the Script find fixes each family of faults at its root…
jgregoriorincon Nov 26, 2026
9a3a63f
fix(ui): the Script find says a cut once and Replace All keeps the sc…
jgregoriorincon Nov 26, 2026
d7746ae
perf(ui): the Script find reads the script once, whatever the query h…
jgregoriorincon Nov 26, 2026
63e5868
fix(ui): the Script find cut notes are literals where they are format…
jgregoriorincon Nov 26, 2026
769ebe8
fix(ui): the browser keeps none of the Script find's keys, and its fi…
jgregoriorincon Nov 26, 2026
1ee7104
fix(ui): the Script find takes its exact shortcuts, and no empty Undo…
jgregoriorincon Nov 26, 2026
bdcd029
perf(ui): the Script find reads the script without copying it (#2996)
jgregoriorincon Nov 26, 2026
cc6356a
fix(ui): Escape in the Script box closes the find bar (#2996)
jgregoriorincon Nov 26, 2026
e00567c
fix(ui): the Script find bar owns its keys wherever the keyboard is i…
jgregoriorincon Nov 26, 2026
ee43a7c
refactor(ui): the Script find holds its current match once, with one …
jgregoriorincon Nov 26, 2026
23b571f
fix(ui): every long paste into the Script find says what it left out …
jgregoriorincon Nov 27, 2026
2d1ca32
fix(ui): a huge paste into the Script find is cut before the field ta…
jgregoriorincon Nov 27, 2026
89c3889
fix(ui): the Script find's note counts every character a field left o…
jgregoriorincon Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 29 additions & 14 deletions apps/rustgis-web/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::collections::HashMap;
use std::rc::Rc;

use rustgis_ui_egui::rustgis_engine::{data::diagnostics::Capture, sources::message_with_address};
use rustgis_ui_egui::{Inbox, RustGisApp, Services, Slot};
use rustgis_ui_egui::{FindChords, Inbox, RustGisApp, Services, Slot};

use crate::parts::Notes;
use wasm_bindgen::JsCast as _;
Expand Down Expand Up @@ -344,13 +344,14 @@ struct WebShell {
embed: Option<Embed>,
/// The app's Ctrl (⌘) shortcuts, kept current for [`keep_app_shortcuts`].
taken: TakenKeys,
/// [`RustGisApp::shortcuts_fingerprint`] when `taken` was last filled.
taken_print: Option<u64>,
/// [`RustGisApp::shortcuts_fingerprint`] and [`RustGisApp::script_find_keys`] when `taken`
/// was last filled.
taken_print: Option<(u64, FindChords)>,
}

/// The app's Ctrl (⌘) shortcuts as (Alt, Shift, key): [`RustGisApp::command_keys`], shared with
/// the page's key listener.
type TakenKeys = Rc<RefCell<Vec<(bool, bool, egui::Key)>>>;
/// The app's Ctrl (⌘) shortcuts as (Alt, Shift, key), [`RustGisApp::command_keys`], and the Script
/// box's find chords, [`RustGisApp::script_find_keys`], shared with the page's key listener.
type TakenKeys = Rc<RefCell<(Vec<(bool, bool, egui::Key)>, FindChords)>>;

/// The link to the page that embeds the app (`?embed`; see `embed.rs`).
struct Embed {
Expand Down Expand Up @@ -451,6 +452,20 @@ impl Embed {
}
}

impl WebShell {
/// Keeps the key listener's shortcuts current: the shortcuts can be changed in the app, and
/// the Script box takes its find chords only while it has the focus. Rebuilt only when one of
/// them changed.
fn follow_keys(&mut self, ctx: &egui::Context) {
let find = self.app.script_find_keys(ctx);
let print = (self.app.shortcuts_fingerprint(), find);
if self.taken_print.as_ref() != Some(&print) {
*self.taken.borrow_mut() = (self.app.command_keys(), print.1.clone());
self.taken_print = Some(print);
}
}
}

impl eframe::App for WebShell {
fn logic(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
// The GPU map backend draws inside egui's wgpu pass; hand over the render state.
Expand Down Expand Up @@ -482,17 +497,14 @@ impl eframe::App for WebShell {
}
self.app.logic(ctx);
self.dirty.set(self.app.session.dirty());
// The shortcuts can be changed in the app: the key listener follows, rebuilt only when
// the keymap changed.
let print = self.app.shortcuts_fingerprint();
if self.taken_print != Some(print) {
self.taken_print = Some(print);
*self.taken.borrow_mut() = self.app.command_keys();
}
self.follow_keys(ctx);
}

fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
self.app.ui(ui);
// The pass may have moved the focus into the Script box, or out of it: a key pressed
// before the next frame's `logic` is judged by where the focus is now.
self.follow_keys(ui.ctx());
}
}

Expand Down Expand Up @@ -1502,7 +1514,10 @@ fn keep_app_shortcuts(taken: TakenKeys) -> Result<(), String> {
// As eframe reads it, Ctrl or ⌘ is egui's command on every platform, so the app's
// shortcut runs on either and the browser's is kept from both.
let command = e.ctrl_key() || e.meta_key();
if RustGisApp::takes_browser_key(&taken.borrow(), &e.key(), &e.code(), command, e.alt_key(), e.shift_key()) {
let (keys, find) = &*taken.borrow();
if RustGisApp::takes_browser_key(keys, &e.key(), &e.code(), command, e.alt_key(), e.shift_key())
|| find.takes(&e.key(), &e.code(), command, e.alt_key(), e.shift_key())
{
e.prevent_default();
}
});
Expand Down
708 changes: 702 additions & 6 deletions crates/ui-egui/src/analysispane.rs

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions crates/ui-egui/src/chrome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,15 +849,17 @@ pub fn shortcuts(app: &mut RustGisApp, ctx: &egui::Context) {
app.ui.history_jump = None;
}
crate::modelbuilder::shortcuts(app, ctx);
// The search box (or a table cell) was typed in until egui took its focus away on Escape:
// that Escape clears the box (leaves the cell as it was), not the tool. An open list (a
// clause's Functions) keeps the same keys as a box, those without Ctrl (⌘): Escape closes it.
// The search box (or a table cell, or the Script pane's find bar) had the focus until egui
// took it away on Escape: that Escape clears the box (leaves the cell as it was, closes the
// bar), not the tool. An open list (a clause's Functions) keeps the same keys as a box, those
// without Ctrl (⌘): Escape closes it.
let pass = ctx.cumulative_pass_nr();
let typing = ctx.egui_wants_keyboard_input()
|| crate::completion::menu_is_open(ctx)
|| crate::crspicker::list_is_open(ctx)
|| crate::searchbox::had_focus(&app.ui.search, pass)
|| crate::table::had_focus(&app.table, pass);
|| crate::table::had_focus(&app.table, pass)
|| app.workflow.script_find.had_focus(pass);
// A text field focused, not any widget (a button reached with Tab): it has an undo of its own.
let text_field = ctx.text_edit_focused();
// An element selected in the open layout, for the layout's own keys.
Expand Down
21 changes: 21 additions & 0 deletions crates/ui-egui/src/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,25 @@ pub fn paint(painter: &Painter, r: Rect, name: &str, ink: Color32, accent: Color
p.line(&[(12.0, 8.0), (12.0, 15.0)], 1.8, p.acc);
p.line(&[(9.2, 12.4), (12.0, 15.2), (14.8, 12.4)], 1.8, p.acc);
}
"replace" | "replace_all" => {
// The word and what takes its place: the old one as a bare letter, the new one in a box of the
// accent, as the other icons draw a thing (a box, its outline), and the action in green, as Export and Add
// draw theirs. The arrow alone for Replace (this match), with an asterisk for Replace All.
// Regular weight, not the semibold the other icons' letters take: it is the plain word.
painter.text(p.pt(6.0, 5.5), egui::Align2::CENTER_CENTER, "a", egui::FontId::proportional(14.0 * p.s()), ink);
if name == "replace_all" {
// An asterisk in the free corner: every match, as a code editor's pattern marks it.
for deg in [90.0_f32, 30.0, 150.0] {
let (s, c) = deg.to_radians().sin_cos();
p.line(&[(19.0 - 3.4 * c, 6.0 - 3.4 * s), (19.0 + 3.4 * c, 6.0 + 3.4 * s)], 1.7, green);
}
}
p.rect(9.5, 11.5, 14.0, 11.0, Some(accent), Some((1.3, ink)), 1.5);
p.text(16.5, 17.0, "b", 10.0, Color32::WHITE);
// From the old word down and over to the new one.
p.line(&[(6.0, 10.0), (6.0, 17.0), (7.2, 17.0)], 1.7, green);
p.fill(&[(6.8, 15.0), (9.3, 17.0), (6.8, 19.0)], green);
}
"up" => p.line(&[(6.0, 15.0), (12.0, 9.0), (18.0, 15.0)], 1.8, ink),
"down" => p.line(&[(6.0, 9.0), (12.0, 15.0), (18.0, 9.0)], 1.8, ink),
"logo" => {
Expand Down Expand Up @@ -1398,6 +1417,8 @@ pub const ALL: &[&str] = &[
"run",
"up",
"down",
"replace",
"replace_all",
"logo",
"point_layer",
"line_layer",
Expand Down
8 changes: 8 additions & 0 deletions crates/ui-egui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ mod s3ui;
mod saveprompt;
mod scriptcolor;
mod scriptcomplete;
mod scriptfind;
pub use scriptfind::FindChords;
mod searchbox;
mod serviceui;
mod sessionlog;
Expand Down Expand Up @@ -1661,6 +1663,12 @@ impl RustGisApp {
keys
}

/// The chords the Script box and its find bar take now, none while neither has the focus: with
/// [`Self::command_keys`], what the web app keeps from the browser's own shortcuts.
pub fn script_find_keys(&self, ctx: &egui::Context) -> FindChords {
scriptfind::browser_keys(ctx, &self.workflow.script_find)
}

/// The keyboard shortcuts of a command run without parameters, in the keymap's order, for a
/// native menu to show (the macOS menu bar).
pub fn shortcuts_of(&self, command: &str) -> Vec<egui::KeyboardShortcut> {
Expand Down
Loading
Loading