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...

This commit is contained in:
jess 2026-04-29 15:40:54 -07:00
parent 7d511195fc
commit 33ab38d5a9
4 changed files with 17 additions and 0 deletions

View File

@ -301,9 +301,12 @@ impl App {
} }
fn save_file_as(&mut self) { fn save_file_as(&mut self) {
let notes_dir = self.config.notes_dir();
let _ = std::fs::create_dir_all(&notes_dir);
let dialog = rfd::FileDialog::new() let dialog = rfd::FileDialog::new()
.add_filter("Markdown", &["md"]) .add_filter("Markdown", &["md"])
.add_filter("All Files", &["*"]) .add_filter("All Files", &["*"])
.set_directory(&notes_dir)
.set_file_name("note.md"); .set_file_name("note.md");
if let Some(path) = dialog.save_file() { if let Some(path) = dialog.save_file() {
self.write_to(&path); self.write_to(&path);
@ -324,6 +327,7 @@ impl App {
} }
fn new_note(&mut self) { fn new_note(&mut self) {
viewport_send_command(self.handle, 12);
let stub = CString::new("# ").unwrap(); let stub = CString::new("# ").unwrap();
viewport_set_text(self.handle, stub.as_ptr()); viewport_set_text(self.handle, stub.as_ptr());
if let Some(w) = &self.window { if let Some(w) = &self.window {
@ -394,6 +398,7 @@ impl ApplicationHandler for App {
Some(h) => { Some(h) => {
self.handle = Box::into_raw(Box::new(h)); self.handle = Box::into_raw(Box::new(h));
self.sync_settings(); self.sync_settings();
viewport_send_command(self.handle, 12);
let stub = CString::new("# ").unwrap(); let stub = CString::new("# ").unwrap();
viewport_set_text(self.handle, stub.as_ptr()); viewport_set_text(self.handle, stub.as_ptr());
} }

View File

@ -6,6 +6,7 @@ import UniformTypeIdentifiers
extension Notification.Name { extension Notification.Name {
static let focusEditor = Notification.Name("focusEditor") static let focusEditor = Notification.Name("focusEditor")
static let focusTitle = Notification.Name("focusTitle") static let focusTitle = Notification.Name("focusTitle")
static let newNoteSeeded = Notification.Name("newNoteSeeded")
} }
class WindowController { class WindowController {
@ -83,6 +84,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
name: .settingsChanged, object: nil name: .settingsChanged, object: nil
) )
NotificationCenter.default.addObserver(
self, selector: #selector(handleNewNoteSeeded),
name: .newNoteSeeded, object: nil
)
if let url = pendingOpenURLs.first { if let url = pendingOpenURLs.first {
pendingOpenURLs = [] pendingOpenURLs = []
appState.loadNoteFromFile(url) appState.loadNoteFromFile(url)
@ -609,6 +615,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {
viewport?.sendCommand(12) viewport?.sendCommand(12)
} }
@objc private func handleNewNoteSeeded() {
viewport?.sendCommand(12)
}
@objc private func setViewMode() { @objc private func setViewMode() {
viewport?.sendCommand(13) viewport?.sendCommand(13)
} }

View File

@ -300,6 +300,7 @@ class AppState: ObservableObject {
let id = bridge.newDocument() let id = bridge.newDocument()
currentNoteID = id currentNoteID = id
selectedNoteIDs = [id] selectedNoteIDs = [id]
NotificationCenter.default.post(name: .newNoteSeeded, object: nil)
documentText = "# " documentText = "# "
evalResults = [:] evalResults = [:]
modified = false modified = false

View File

@ -247,6 +247,7 @@ impl App {
} }
fn new_note(&mut self) { fn new_note(&mut self) {
viewport_send_command(self.handle, 12);
let stub = CString::new("# ").unwrap(); let stub = CString::new("# ").unwrap();
viewport_set_text(self.handle, stub.as_ptr()); viewport_set_text(self.handle, stub.as_ptr());
if let Some(w) = &self.window { if let Some(w) = &self.window {