Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The app is not notarized yet. If macOS blocks the first launch, try opening it o
- Open a Markdown or HTML file with **File > Open** (`⌘O`), or drag a file into the app window.
- Use the **Aa** button in the toolbar to choose Native Reader or Book Reader and set light or dark appearance. The same options are in the **View** menu.
- In a Markdown task list, click a checkbox to update its marker in the file. Other document text is read-only.
- Right-click a tab to put it in a group. A group has a colored chip with an optional name: click the chip to collapse the group, right-click it to rename or recolor it, and drag it to move the whole group. Groups reopen with the session.
- Each file opens in its own tab. **File > Open Files In** switches to new windows instead. `⌘T` and `⌘N` add an empty tab or window, and an empty tab lists your recent files.
- `⌘F` finds text in the page. The outline button in the toolbar (`⌥⌘O`) jumps to a heading.
- The page updates when the file changes on disk, so you can keep it open next to your editor. The reload button in the toolbar (`⌘R`) reloads it by hand.
Expand Down
187 changes: 110 additions & 77 deletions Sources/ZenMarky/App.swift

Large diffs are not rendered by default.

27 changes: 26 additions & 1 deletion Sources/ZenMarky/ReaderDocument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@ struct ReaderSession: Codable, Equatable {
var files: [String]
var selected: String?
var frame: String
var groups: [Group] = []
}

// A tab group, with its tabs by file. A file is open in one tab at most, so the path names the tab.
struct Group: Codable, Equatable {
var name: String
var color: GroupColor
var collapsed: Bool
var files: [String]
}

static let key = "session"
Expand All @@ -171,14 +180,30 @@ struct ReaderSession: Codable, Equatable {
UserDefaults.standard.set(try? JSONEncoder().encode(self), forKey: Self.key)
}

// Drops files that no longer exist and the windows left with none.
// Drops files that no longer exist and the groups and windows left with none.
func existing(_ exists: (String) -> Bool = { FileManager.default.fileExists(atPath: $0) }) -> ReaderSession {
var kept = self
kept.windows = windows.compactMap { window in
var window = window
window.files = window.files.filter(exists)
window.groups = window.groups.compactMap { group in
var group = group
group.files = group.files.filter(exists)
return group.files.isEmpty ? nil : group
}
return window.files.isEmpty ? nil : window
}
return kept
}
}

// Sessions saved before tab groups have no groups key, so a missing one reads as none.
extension ReaderSession.Window {
init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
files = try container.decode([String].self, forKey: .files)
selected = try container.decodeIfPresent(String.self, forKey: .selected)
frame = try container.decode(String.self, forKey: .frame)
groups = try container.decodeIfPresent([ReaderSession.Group].self, forKey: .groups) ?? []
}
}
664 changes: 664 additions & 0 deletions Sources/ZenMarky/ReaderTab.swift

Large diffs are not rendered by default.

902 changes: 311 additions & 591 deletions Sources/ZenMarky/ReaderWindowController.swift

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions Sources/ZenMarky/Resources/Shortcuts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
| Open a file | ⌘O |
| New tab | ⌘T |
| New window | ⌘N |
| Close tab or window | ⌘W |
| Close tab | ⌘W |
| Close window | ⇧⌘W |
| Reload the file | ⌘R |
| Print | ⌘P |
| Copy / select all | ⌘C / ⌘A |
| Find | ⌘F |
| Find next / previous | ⌘G / ⇧⌘G |
| Show outline | ⌥⌘O |
| Zoom in / out / actual size | ⌘= / ⌘− / ⌘0 |
| Previous / next tab | ⇧⌘[ / ⇧⌘] |
| Previous / next tab | ⇧⌘[ / ⇧⌘], or ⌃⇧⇥ / ⌃⇥ |
| Go to tab 1–8, last tab | ⌘1–⌘8, ⌘9 |
| Show tab bar / all tabs | ⇧⌘T / ⇧⌘\\ |
| Always show the tab bar | ⇧⌘T |
| Cycle windows | ⌘` |
| Minimize | ⌘M |
| Hide / quit the app | ⌘H / ⌘Q |
Expand All @@ -27,6 +28,11 @@
| --- | --- |
| Open a file | Drop it on any window |
| Open a linked file in a new tab | ⌘-click the link |
| Group a tab | Right-click the tab, then Add Tab to New Group |
| Collapse or expand a group | Click its chip |
| Rename, recolor, or close a group | Right-click its chip |
| Move a tab or a whole group | Drag the tab or the chip along the tab bar; pull it away from the bar to drop it on another window's tab bar, or outside every window for a new window |
| Close a tab | Middle-click it |
| Check or uncheck a task | Click the box |
| Copy a code block | Hover over it, then click the copy button |
| Zoom | Pinch on the trackpad |
Expand All @@ -38,4 +44,5 @@
| Reader style: Native or Book | Aa button, or View > Reader Style |
| Appearance: System, Light, or Dark | Aa button, or View > Appearance |
| Open files in a new tab or window | File > Open Files In |
| Tab bar with a single tab | View > Always Show Tab Bar |
| Front matter (title, date, tags) | View > Show Front Matter |
Loading
Loading