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:
parent
7d511195fc
commit
33ab38d5a9
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue