From 33ab38d5a9230dac53e21daf5762f6347bf652de Mon Sep 17 00:00:00 2001 From: jess Date: Wed, 29 Apr 2026 15:40:54 -0700 Subject: [PATCH] Well... It's a bit of a cop out, I won't lie. But editor mode is the default across platforms now because it solves a bunch of issues with starting in Live mode I just don't feel like tackling right now. I'll come around... --- linux/src/app.rs | 5 +++++ src/AppDelegate.swift | 10 ++++++++++ src/AppState.swift | 1 + windows/src/app.rs | 1 + 4 files changed, 17 insertions(+) diff --git a/linux/src/app.rs b/linux/src/app.rs index 631c89b..94c1013 100644 --- a/linux/src/app.rs +++ b/linux/src/app.rs @@ -301,9 +301,12 @@ impl App { } fn save_file_as(&mut self) { + let notes_dir = self.config.notes_dir(); + let _ = std::fs::create_dir_all(¬es_dir); let dialog = rfd::FileDialog::new() .add_filter("Markdown", &["md"]) .add_filter("All Files", &["*"]) + .set_directory(¬es_dir) .set_file_name("note.md"); if let Some(path) = dialog.save_file() { self.write_to(&path); @@ -324,6 +327,7 @@ impl App { } fn new_note(&mut self) { + viewport_send_command(self.handle, 12); let stub = CString::new("# ").unwrap(); viewport_set_text(self.handle, stub.as_ptr()); if let Some(w) = &self.window { @@ -394,6 +398,7 @@ impl ApplicationHandler for App { Some(h) => { self.handle = Box::into_raw(Box::new(h)); self.sync_settings(); + viewport_send_command(self.handle, 12); let stub = CString::new("# ").unwrap(); viewport_set_text(self.handle, stub.as_ptr()); } diff --git a/src/AppDelegate.swift b/src/AppDelegate.swift index 104f475..8af9ba7 100644 --- a/src/AppDelegate.swift +++ b/src/AppDelegate.swift @@ -6,6 +6,7 @@ import UniformTypeIdentifiers extension Notification.Name { static let focusEditor = Notification.Name("focusEditor") static let focusTitle = Notification.Name("focusTitle") + static let newNoteSeeded = Notification.Name("newNoteSeeded") } class WindowController { @@ -83,6 +84,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation { name: .settingsChanged, object: nil ) + NotificationCenter.default.addObserver( + self, selector: #selector(handleNewNoteSeeded), + name: .newNoteSeeded, object: nil + ) + if let url = pendingOpenURLs.first { pendingOpenURLs = [] appState.loadNoteFromFile(url) @@ -609,6 +615,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation { viewport?.sendCommand(12) } + @objc private func handleNewNoteSeeded() { + viewport?.sendCommand(12) + } + @objc private func setViewMode() { viewport?.sendCommand(13) } diff --git a/src/AppState.swift b/src/AppState.swift index 2aea83e..9321b8c 100644 --- a/src/AppState.swift +++ b/src/AppState.swift @@ -300,6 +300,7 @@ class AppState: ObservableObject { let id = bridge.newDocument() currentNoteID = id selectedNoteIDs = [id] + NotificationCenter.default.post(name: .newNoteSeeded, object: nil) documentText = "# " evalResults = [:] modified = false diff --git a/windows/src/app.rs b/windows/src/app.rs index 7fe7fb7..e0d1742 100644 --- a/windows/src/app.rs +++ b/windows/src/app.rs @@ -247,6 +247,7 @@ impl App { } fn new_note(&mut self) { + viewport_send_command(self.handle, 12); let stub = CString::new("# ").unwrap(); viewport_set_text(self.handle, stub.as_ptr()); if let Some(w) = &self.window {