Skip to content

Commit 6b7fd66

Browse files
committed
v1.0.1
Enable AccessKit Fix terminal visibility on Windows Tweak default WASM UI scale
1 parent 6f0fe84 commit 6b7fd66

File tree

7 files changed

+36
-8
lines changed

7 files changed

+36
-8
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/target
1+
/target
2+
/dist

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "deduct"
33
authors = ["Colonial"]
4-
version = "1.0.0"
4+
version = "1.0.1"
55
edition = "2021"
66
description = "A Fitch-style natural deduction proof checker, with support for modal logic."
77
repository = "https://github.com/Colonial-Dev/deduct"
@@ -18,7 +18,7 @@ opt-level = 2
1818

1919
[dependencies]
2020
# GUI
21-
egui = "0.27.2"
21+
egui = { version = "0.27.2", features = ["accesskit"] }
2222
eframe = { version = "0.27.2", features = [
2323
"wgpu", # Use the WGPU rendering backend.
2424
"persistence", # Enable restoring app state when restarting the app.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
## Installation
2020

21-
### Web Version
21+
### Web Version (Recommended)
2222
Deduct is available as a web app [here](https://colonial-dev.github.io/deduct/). Use a laptop or desktop for the best experience.
2323

2424
### Precompiled Binaries
2525
Precompiled versions of Deduct are available for:
26-
- Windows
26+
- Windows (note that, although unlikely, you may need to install the Microsoft Visual C/++ Redistributables)
2727
- macOS
2828
- Linux (compiled against `x86_64-unknown-linux-musl`, which should Just Work™ on most distributions.)
2929

src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Prevents Windows from opening a terminal when the executable is started
2+
#![windows_subsystem = "windows"]
3+
14
mod check;
25
mod parse;
36
mod ui;

src/ui/mod.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,25 @@ const NEW_SO: KeyboardShortcut = KeyboardShortcut::new(
5656

5757
const UI_ZOOM_FACTORS: [f32; 5] = [1.0, 1.25, 1.50, 1.75, 2.0];
5858

59+
/// Top-level application state.
5960
#[derive(Serialize, Deserialize, Default)]
6061
#[serde(default)]
6162
pub struct Deduct {
63+
/// The current proof, if any.
6264
#[serde(skip)]
6365
proof : Option<proof::ProofUi>,
66+
/// Popup window visibilities.
6467
#[serde(skip)]
6568
vis : popups::Visibility,
69+
/// New proof popup state.
6670
#[serde(skip)]
6771
new : popups::NewProof,
72+
/// Preferences popup state.
6873
prefs : popups::Preferences,
6974
}
7075

7176
impl Deduct {
77+
/// Called once on startup.
7278
pub fn new(cc: &eframe::CreationContext<'_>) -> Self {
7379
egui_extras::install_image_loaders(&cc.egui_ctx);
7480

@@ -90,6 +96,8 @@ impl Deduct {
9096
Default::default()
9197
}
9298

99+
/// Try and use the input from the new proof popup
100+
/// to start a new proof.
93101
pub fn try_new_proof(&mut self) {
94102
if let Some(ui) = self.new.try_create() {
95103
self.proof = Some(ui);
@@ -98,6 +106,7 @@ impl Deduct {
98106
self.new.ready = false;
99107
}
100108

109+
/// Handle keyboard shortcuts.
101110
fn handle_shortcuts(&mut self, ctx: &Context) {
102111
let mut op = None;
103112

@@ -153,6 +162,7 @@ impl eframe::App for Deduct {
153162

154163
self.handle_shortcuts(ctx);
155164

165+
// Render top menu bar.
156166
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
157167
egui::menu::bar(ui, |ui| {
158168
ui.menu_button("Proof", |ui| {
@@ -207,6 +217,7 @@ impl eframe::App for Deduct {
207217

208218
});
209219

220+
// Render quick reference side bar.
210221
egui::SidePanel::right("proof_rules")
211222
.resizable(false)
212223
.min_width(w * 0.25)
@@ -303,8 +314,10 @@ impl eframe::App for Deduct {
303314
});
304315
});
305316

317+
// Render central panel.
306318
egui::CentralPanel::default()
307319
.show(ctx, |ui| {
320+
// If we don't have a proof, display a placeholder message.
308321
let Some(proof) = &mut self.proof else {
309322
ui.with_layout(
310323
Layout::centered_and_justified(Direction::TopDown),
@@ -337,6 +350,7 @@ impl eframe::App for Deduct {
337350
}
338351
}
339352

353+
/// Render the about window.
340354
fn about(ui: &mut Ui) {
341355
let title_font = FontId::new(
342356
40.0,
@@ -353,7 +367,7 @@ fn about(ui: &mut Ui) {
353367
ui.label("A Fitch-style natural deduction proof checker.");
354368

355369
ui.label(
356-
RichText::new("Built with love by Colonial, using Rust and egui!").weak().italics()
370+
RichText::new("Built with love by Colonial using Rust and egui!").weak().italics()
357371
);
358372

359373
ui.separator();
@@ -385,6 +399,7 @@ fn about(ui: &mut Ui) {
385399
});
386400
}
387401

402+
/// Render the shortcut info window.
388403
fn shortcuts(ui: &mut Ui) {
389404
ui.label("All shortcuts act on the currently selected line or (if no line is selected) the last line.");
390405
ui.separator();
@@ -438,6 +453,7 @@ fn shortcuts(ui: &mut Ui) {
438453
});
439454
}
440455

456+
/// Load LaTeX `Latin Modern Math` font into memory under the name `math`.
441457
fn fonts_init(cc: &eframe::CreationContext<'_>) {
442458
let mut fonts = FontDefinitions::default();
443459

@@ -454,6 +470,7 @@ fn fonts_init(cc: &eframe::CreationContext<'_>) {
454470
cc.egui_ctx.set_fonts(fonts);
455471
}
456472

473+
/// Return the current width and height of the window.
457474
fn window_size(ui: &Ui) -> (f32, f32) {
458475
let w = ui.ctx().input(|i| {
459476
let r = i.screen_rect().x_range();
@@ -468,13 +485,15 @@ fn window_size(ui: &Ui) -> (f32, f32) {
468485
(w, h)
469486
}
470487

488+
/// Generate a dummy [`Response`] that does not influence the UI.
471489
fn dummy_response(ui: &mut Ui) -> Response {
472490
ui.allocate_response(
473491
Vec2::ZERO,
474492
Sense::click()
475493
)
476494
}
477495

496+
/// Create a new popup window with the given title and open flag.
478497
fn new_window<'a>(title: &'static str, open: &'a mut bool) -> Window<'a> {
479498
egui::Window::new(title)
480499
.default_open(true)

src/ui/popups.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ impl Widget for &mut Preferences {
223223

224224
impl Default for Preferences {
225225
fn default() -> Self {
226-
Self { dark_mode: true, ui_scale: 0 }
226+
// On WASM, bump the default UI scale to 125% as most browsers will be fullscreened.
227+
if cfg!(target_arch = "wasm32") {
228+
Self { dark_mode: true, ui_scale: 1 }
229+
} else {
230+
Self { dark_mode: true, ui_scale: 0 }
231+
}
227232
}
228233
}

0 commit comments

Comments
 (0)