mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-02 10:38:15 -06:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6c1396405 |
@@ -5,23 +5,23 @@ version: 'v0.0.3'
|
||||
workflows:
|
||||
'.github/workflows/ci.yml':
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'step-security/harden-runner@v2.22.4'
|
||||
- 'step-security/harden-runner@v2.23.0'
|
||||
'.github/workflows/freebsd.yml': []
|
||||
'.github/workflows/house-rules.yml': []
|
||||
'.github/workflows/lockfile.yml':
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'step-security/harden-runner@v2.22.4'
|
||||
- 'step-security/harden-runner@v2.23.0'
|
||||
'.github/workflows/nightly-dispatch.yml': []
|
||||
'.github/workflows/nightly-macos.yml':
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'step-security/harden-runner@v2.22.4'
|
||||
- 'step-security/harden-runner@v2.23.0'
|
||||
'.github/workflows/nightly-sign.yml': []
|
||||
'.github/workflows/nightly.yml': []
|
||||
'.github/workflows/nix.yml': []
|
||||
'.github/workflows/notify-services.yml': []
|
||||
'.github/workflows/packaging-lint.yml':
|
||||
- 'actions/checkout@v7.0.1'
|
||||
- 'step-security/harden-runner@v2.22.4'
|
||||
- 'step-security/harden-runner@v2.23.0'
|
||||
'.github/workflows/release.yml': []
|
||||
'.github/workflows/sonarcloud.yml': []
|
||||
'.github/workflows/windows-arm64.yml': []
|
||||
@@ -31,8 +31,8 @@ dependencies:
|
||||
commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
|
||||
owner_id: 44036562
|
||||
repo_id: 197814629
|
||||
'step-security/harden-runner@v2.22.4':
|
||||
ref: 'v2.22.4'
|
||||
commit: 'sha1-1d88384fd173af6ecb012dfd0264a306b711241a'
|
||||
'step-security/harden-runner@v2.23.0':
|
||||
ref: 'v2.23.0'
|
||||
commit: 'sha1-aebdcf6156ab6691adf63218240e476564a1ed4c'
|
||||
owner_id: 88700172
|
||||
repo_id: 422287306
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
CRAFT_FONTS_REF: 37827adc41fd165f9a9234ac40f94dbad353aa69
|
||||
steps:
|
||||
- name: Harden runner
|
||||
uses: step-security/harden-runner@v2.22.4
|
||||
uses: step-security/harden-runner@v2.23.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
- name: Check out craft-fonts
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Harden runner
|
||||
uses: step-security/harden-runner@v2.22.4
|
||||
uses: step-security/harden-runner@v2.23.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@v7.0.1
|
||||
|
||||
@@ -36,7 +36,7 @@ jobs:
|
||||
RUST_BACKTRACE: 1
|
||||
steps:
|
||||
- name: Harden runner
|
||||
uses: step-security/harden-runner@v2.22.4
|
||||
uses: step-security/harden-runner@v2.23.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@v7.0.1
|
||||
|
||||
@@ -28,7 +28,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Harden runner
|
||||
uses: step-security/harden-runner@v2.22.4
|
||||
uses: step-security/harden-runner@v2.23.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@v7.0.1
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
contents: read
|
||||
steps:
|
||||
- name: Harden runner
|
||||
uses: step-security/harden-runner@v2.22.4
|
||||
uses: step-security/harden-runner@v2.23.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/checkout@v7.0.1
|
||||
|
||||
@@ -168,8 +168,6 @@ impl Session {
|
||||
"end" => "End",
|
||||
"tab" => "Tab",
|
||||
"space" | " " => "Space",
|
||||
// Ctrl+Shift+= reaches us as the shifted character, `+`; shortcuts are written with `=`.
|
||||
"+" if mods.shift => "=",
|
||||
_ => k,
|
||||
};
|
||||
let found = crate::command_specs().iter().find(|c| c.shortcut.is_some_and(|s| shortcut_matches(s, key_name, mods))).map(|c| c.id);
|
||||
|
||||
@@ -381,16 +381,6 @@ impl SlideApp {
|
||||
if fired.source == FireSource::Palette {
|
||||
CommandPalette::remember(&mut self.palette_recents, fired.command.clone());
|
||||
}
|
||||
// Ctrl+= and Ctrl+Shift+= are also Subscript and Superscript: the key formats while text or shapes are
|
||||
// selected and zooms only with nothing to format. Buttons keep zooming.
|
||||
let id = if id == "view.zoomIn"
|
||||
&& fired.source == FireSource::Key
|
||||
&& self.session.active().is_some_and(|d| d.selection.text.is_some() || !d.selection.shapes.is_empty())
|
||||
{
|
||||
if fired.mods.shift || ctx.input(|i| i.modifiers.shift) { "format.superscript" } else { "format.subscript" }
|
||||
} else {
|
||||
id
|
||||
};
|
||||
match id {
|
||||
"edit.paste" => self.paste(ctx, fired.pasted.clone()),
|
||||
"edit.copy" | "edit.cut" if fired.command.key_text().as_ref() == fired.command.id.as_str() => {
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
//! #1926: Ctrl+= (Subscript) and Ctrl+Shift+= (Superscript) zoomed or twitched the screen instead.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use deckcraft_engine::Session;
|
||||
use deckcraft_ui_egui::{Platform, Services, SlideApp};
|
||||
use egui::{Key, Modifiers};
|
||||
use egui_kittest::Harness;
|
||||
use serde_json::json;
|
||||
|
||||
struct Window(SlideApp);
|
||||
|
||||
impl eframe::App for Window {
|
||||
fn raw_input_hook(&mut self, ctx: &egui::Context, raw: &mut egui::RawInput) {
|
||||
self.0.raw_input_hook(ctx, raw);
|
||||
}
|
||||
|
||||
fn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
||||
self.0.logic(ctx);
|
||||
}
|
||||
|
||||
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
||||
self.0.ui(ui);
|
||||
}
|
||||
}
|
||||
|
||||
fn window(cc: &mut eframe::CreationContext<'_>, session: Session) -> Window {
|
||||
let host = craft::host::Host::builder(craft::host::AppInfo { id: "deckcraft", name: "DeckCraft", version: "0" })
|
||||
.files(Arc::new(craft::host::ScriptedFiles::new()))
|
||||
.build();
|
||||
let clipboard = craft::platform::clipboard::Clipboard::new(craft::platform::clipboard::MemoryClipboard::default());
|
||||
let platform = Platform {
|
||||
install: craft::ui::runtime::InstallSpec::new(Default::default(), Arc::new(craft::window::system::SystemWindows))
|
||||
.app_id("deckcraft")
|
||||
.clipboard(clipboard),
|
||||
host,
|
||||
settings: craft::settings::Location::Memory,
|
||||
intake: None,
|
||||
audio_out: None,
|
||||
control: None,
|
||||
frame: craft::window::policy::Frame::Native,
|
||||
at_exit: None,
|
||||
};
|
||||
let mut app = SlideApp::new(&cc.egui_ctx, platform).unwrap_or_else(|error| panic!("window installation failed: {error}"));
|
||||
app.session = session;
|
||||
app.services = Services::default();
|
||||
Window(app)
|
||||
}
|
||||
|
||||
fn harness_of(session: Session) -> Harness<'static, Window> {
|
||||
let mut h = Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0).build_eframe(move |cc| window(cc, session));
|
||||
h.run_steps(4);
|
||||
h
|
||||
}
|
||||
|
||||
fn harness() -> Harness<'static, Window> {
|
||||
let mut s = Session::with_new();
|
||||
s.execute("shape.insert", &json!({"preset": "rect", "rect": [80.0, 80.0, 320.0, 80.0], "text": "Hello"})).unwrap();
|
||||
// A selected shape, not a caret: the shortcuts then format the text that is already there.
|
||||
let _ = s.execute("text.exit", &json!({}));
|
||||
harness_of(s)
|
||||
}
|
||||
|
||||
fn baseline_of(h: &Harness<'_, Window>) -> Option<f64> {
|
||||
let st = h.state().0.session.active().unwrap();
|
||||
st.selected_shapes()
|
||||
.first()
|
||||
.and_then(|sh| sh.text.as_ref())
|
||||
.and_then(|t| t.paragraphs.first())
|
||||
.and_then(|p| p.runs.first())
|
||||
.and_then(|r| r.props.baseline)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ctrl_equals_subscripts_without_zooming() {
|
||||
let mut h = harness();
|
||||
h.key_press_modifiers(Modifiers::COMMAND, Key::Equals);
|
||||
h.run_steps(1);
|
||||
assert_eq!(baseline_of(&h), Some(-0.25), "status {:?}", h.state().0.status);
|
||||
assert!(!h.ctx.options(|o| o.zoom_with_keyboard), "egui's own keyboard zoom must not act on Ctrl+=");
|
||||
assert_eq!(h.ctx.zoom_factor(), 1.0);
|
||||
assert!(h.state().0.ui.zoom.is_none(), "Ctrl+= must not zoom the slide while there is text to format");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ctrl_shift_equals_superscripts_without_zooming() {
|
||||
let mut h = harness();
|
||||
// Ctrl+Shift+= is the shifted character, so egui reports it as `Plus`.
|
||||
h.key_press_modifiers(Modifiers::COMMAND | Modifiers::SHIFT, Key::Plus);
|
||||
h.run_steps(1);
|
||||
assert_eq!(baseline_of(&h), Some(0.3), "status {:?}", h.state().0.status);
|
||||
assert!(!h.ctx.options(|o| o.zoom_with_keyboard), "egui's own keyboard zoom must not act on Ctrl+Shift+=");
|
||||
assert_eq!(h.ctx.zoom_factor(), 1.0);
|
||||
assert!(h.state().0.ui.zoom.is_none(), "Ctrl+Shift+= must not zoom the slide while there is text to format");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ctrl_equals_zooms_with_nothing_to_format() {
|
||||
let mut h = harness_of(Session::with_new());
|
||||
h.key_press_modifiers(Modifiers::COMMAND, Key::Equals);
|
||||
h.run_steps(1);
|
||||
assert!(h.state().0.ui.zoom.is_some(), "Ctrl+= zooms in when no text or shape is selected");
|
||||
}
|
||||
Reference in New Issue
Block a user