improves plak
This commit is contained in:
+98
-30
@@ -1,12 +1,12 @@
|
||||
# Plak v1 spec
|
||||
|
||||
Plak is a native macOS notepad with one long page of plain text. It has no files to open or save: you open it, you paste or type at the bottom, and it keeps everything. The only thing that renders is images: what you paste or drop shows as the image itself.
|
||||
Plak is a native macOS notepad with one long page of plain text. It has no files to open or save: you open it, you paste or type at the bottom, and it keeps everything. Only three things render: images, code blocks and tables. A pasted or dropped image shows as the image itself; pasted code shows with colours; a pasted CSV shows as a grid.
|
||||
|
||||
## 1. Behaviour
|
||||
|
||||
### 1.1 The page
|
||||
- There is one page. It grows at the bottom, without limit.
|
||||
- The page is one plain text: you can click anywhere and type, and you can select across paragraphs. There is no markdown rendering: `# title` or `**bold**` show as you type them.
|
||||
- The page is one plain text: you can click anywhere and type, and you can select across paragraphs. There is no markdown rendering: `# title` or `**bold**` show as you type them. Only images (1.7), code blocks and tables (1.8) render.
|
||||
- The text sits in one reading column, about 68 characters wide, in the centre of the window.
|
||||
- A **block** is a run of lines without a blank line in it. Blocks exist only for the created date (1.6); you do not see them as boxes.
|
||||
|
||||
@@ -29,7 +29,7 @@ Plak is a native macOS notepad with one long page of plain text. It has no files
|
||||
|
||||
### 1.4 Save
|
||||
- Plak saves the page to the page file about 0.5 seconds after you stop typing, and again when you quit and when plak goes to the background.
|
||||
- The page file is plain text, saved exactly as you typed it. Blank lines are kept, also several in a row. Plak adds only two kinds of line: the date line above a block (1.6) and the image line (1.7).
|
||||
- The page file is plain text, saved exactly as you typed it. Blank lines are kept, also several in a row. Plak adds only three kinds of line: the date line above a block (1.6), the image line (1.7) and the fence lines around a code block or table (1.8).
|
||||
- If plak cannot write the page file, a small message shows at the top of the window, and plak tries again on the next change. Plak never loses the text in memory.
|
||||
- If the page file does not exist, plak starts with an empty page and makes the file on the first save.
|
||||
- If the page file exists but cannot be read, plak shows an alert and quits without saving, so it never overwrites the file.
|
||||
@@ -37,7 +37,7 @@ Plak is a native macOS notepad with one long page of plain text. It has no files
|
||||
### 1.5 Window
|
||||
- One window. Plak remembers its size and position.
|
||||
- Esc, ⌘P (while you are in plak), ⌘W, the close button and Hide Plak in the menu bar hide plak, and the app you came from comes in front again. ⌘P, Show Plak or Spotlight shows it again. ⌘Q and Quit Plak quit.
|
||||
- During an input-method composition (Japanese or Chinese input, the accent popup) Esc only cancels the composition; it does not hide plak.
|
||||
- During an input-method composition (Japanese or Chinese input, the accent popup) Esc only cancels the composition; it does not hide plak. In a code block or table, Esc acts in the object and does not hide plak either (1.8).
|
||||
- The window comes to the desktop you are on, and shows over an app in fullscreen.
|
||||
- The window has no toolbar and no title text. The title bar is transparent and shows the paper; the text scrolls under it.
|
||||
- The top 28 pt of the window is a drag strip over its full width: press and drag there to move the window, a double-click there does what the macOS setting for a title bar double-click says (zoom or minimise). A click in the strip never moves the caret. The pointer over the strip is the normal arrow, not the text cursor. The window buttons keep working.
|
||||
@@ -63,17 +63,65 @@ Plak is a native macOS notepad with one long page of plain text. It has no files
|
||||
- Plak never deletes an image file. An image you delete keeps its file in `images/` (cleaning up is for later).
|
||||
- Remote images (`https://…`) and browser drags without a real file are not supported in v1.
|
||||
|
||||
### 1.8 Keyboard
|
||||
### 1.8 Code blocks and tables
|
||||
- **Paste**: ⌘V of plain text that is one of these kinds inserts one object at the caret, on its own line, as an image does:
|
||||
- PHP: the text starts with `<?php` or `<?=`.
|
||||
- JSON: the text starts with `{` or `[` and is valid JSON.
|
||||
- XML: the text starts with `<` and is valid XML.
|
||||
- CSV: 2 or more lines, the delimiter is `,`, `;` or tab, every line has the same field count, and that count is 2 or more. Quotes follow RFC 4180.
|
||||
- Other text stays text. ⌥⇧⌘V (Paste as Plain Text) skips the detection and always pastes text.
|
||||
- JSON that you paste on one line is pretty-printed with a 2-space indent. The key order stays as it was.
|
||||
- **One object**: a code block or table is one character in the text, as an image is (1.7). PHP, JSON and XML become a code block; CSV becomes a table.
|
||||
|
||||
**Code block** (PHP, JSON, XML)
|
||||
- **Look**: syntax colours on `codePaper`, the full column width, in OpenDyslexic Mono. Long lines wrap.
|
||||
- **Edit**: click the code block to edit it in place. A caret appears inside, and the colours update while you type. Tab inserts 4 spaces.
|
||||
- Esc or a click outside ends the edit. ↑ on the first line goes to the text above; ↓ on the last line goes to the text below.
|
||||
|
||||
**Table** (CSV)
|
||||
- **Look**: a grid with thin lines in `selection`, in OpenDyslexic Mono. Each column is as wide as its content. A long value is cut off with `…`. A wide table scrolls sideways while you are in it.
|
||||
- Click a cell to select it. Then:
|
||||
|
||||
| Keys | Action |
|
||||
|---|---|
|
||||
| ← → ↑ ↓ | Move to the next cell |
|
||||
| Tab / ⇧Tab | Move right / left; Tab on the last column adds a column |
|
||||
| Typing | Replaces the value of the cell |
|
||||
| Enter or F2 | Edits the value of the cell |
|
||||
| Enter (while editing) | Saves and moves down; on the last row it adds a row |
|
||||
| Tab (while editing) | Saves and moves right |
|
||||
| Esc (while editing) | Cancels the edit |
|
||||
| Backspace / Delete | Clears the cell |
|
||||
| ⌘⌫ | Deletes the row |
|
||||
| ⌥⌘⌫ | Deletes the column |
|
||||
| Esc or a click outside | Leaves the table |
|
||||
| ↑ on the first row / ↓ on the last row | Goes to the text above / below |
|
||||
|
||||
**Both**
|
||||
- Esc in a code block or table never hides plak (1.5). When plak hides or quits, an open edit is saved first.
|
||||
- ⌘Z on the page undoes a whole edit of a code block or table in one step.
|
||||
- An empty code block, or a table without cells, is removed.
|
||||
- **Copy**: ⌘C on a selection with a code block or table puts its fenced text on the pasteboard. A paste of that text back into plak gives the object again.
|
||||
- **Page file**: a code block or table is a fenced block: the line ```` ```php ```` (or `json`, `xml`, `csv`), the text exactly as it is, and the closing line ```` ``` ````.
|
||||
- When the text holds a line that starts with ```` ``` ````, the fence is longer than the longest such run.
|
||||
- On read, only a fence with exactly `php`, `json`, `xml` or `csv` and a closing fence becomes an object. Any other fence, or a fence without a close, stays text.
|
||||
- Blank lines inside the fence belong to the object; they do not split a block.
|
||||
- A date line directly above the fence dates the object (1.6).
|
||||
- The CSV text stays exactly as it was until you edit the table. After an edit, plak writes it with its own delimiter, and with quotes only where they are necessary.
|
||||
- A fence that you type by hand stays text until plak opens the page again.
|
||||
|
||||
### 1.9 Keyboard
|
||||
|
||||
| Keys | Action |
|
||||
|---|---|
|
||||
| ⌘↓ / ⌘↑ | End / start of the page |
|
||||
| ⌘Z / ⇧⌘Z | Undo and redo, image inserts included |
|
||||
| ⌘Z / ⇧⌘Z | Undo and redo, image inserts and edits of code blocks and tables included |
|
||||
| ⌘C / ⌘X / ⌘V | Normal text actions |
|
||||
| ⌥⇧⌘V | Paste as Plain Text: no code block or table detection (1.8) |
|
||||
| ⌘A | Does nothing. Plak has no Select All: the page is not meant to be cleared in one go. The Edit menu has no Select All item. |
|
||||
| ⌘+ / ⌘− / ⌘0 | Text size bigger, smaller, default |
|
||||
| ⌘P | Show the window, from any app on any desktop; in plak, hide it and go back to the previous app |
|
||||
| Esc | Hide plak and go back to the previous app; during an input-method composition, cancel the composition |
|
||||
| Esc | Hide plak and go back to the previous app; during an input-method composition, cancel the composition; in a code block or table, end the edit or leave the table (1.8) |
|
||||
| ⌘W | Hide plak and go back to the previous app |
|
||||
| ⌘Q | Save and quit |
|
||||
|
||||
@@ -87,9 +135,11 @@ Plak is a native macOS notepad with one long page of plain text. It has no files
|
||||
| `ink` | `#2B2621` | Text |
|
||||
| `inkMuted` | `#6E655A` | Dates, `image missing` |
|
||||
| `accent` | `#8A4B2A` | The caret |
|
||||
| `selection` | `#B9AE98` | Selected text |
|
||||
| `selection` | `#B9AE98` | Selected text, the lines of a table |
|
||||
| `codePaper` | `#CBC2B0` | Code block background |
|
||||
|
||||
- **Font**: OpenDyslexic for all text, bundled in the app (OFL licence, `OFL.txt` next to the files).
|
||||
- **Syntax colours** for code blocks have no start values; we tune them on screen.
|
||||
- **Font**: OpenDyslexic for all text, and OpenDyslexic Mono for code blocks and tables. Both are bundled in the app. OpenDyslexic has the OFL licence (`OFL.txt`); OpenDyslexic Mono has the Bitstream Vera licence (`OpenDyslexicMono-LICENSE.txt`), both next to the files.
|
||||
- **Text size** is 16 pt by default, with a line height of 1.6.
|
||||
- No shadows, no borders, no scroll bar unless you scroll.
|
||||
|
||||
@@ -99,14 +149,15 @@ SwiftPM package, macOS 14+, Swift 6, AppKit. No dependencies.
|
||||
|
||||
| Target | Contents |
|
||||
|---|---|
|
||||
| `PlakCore` | `PageFile`: reads the page file text into plain text plus block dates and image lines, and writes it back. Block splitting (blank lines), the date line pattern, the image line pattern, the date formatter. Pure Swift, no AppKit. |
|
||||
| `PlakCore` | `PageFile`: reads the page file text into plain text plus block dates and image lines, and writes it back. Block splitting (blank lines), the date line pattern, the image line pattern, the date formatter. Fence parsing, paste detection, the CSV model, the JSON formatter and the syntax tokenizers. Pure Swift, no AppKit. |
|
||||
| `PlakServices` | `PageStore`: reads and writes the page file, the debounced save. `ImageStore`: copies or writes image files into `images/` and gives back the relative path. |
|
||||
| `PlakUI` | The window, the page text view, the image attachments, the date margin, paste and drop, the theme and the fonts. |
|
||||
| `PlakUI` | The window, the page text view, the image attachments, the code block and table attachments and their in-place editors, the date margin, paste and drop, the theme and the fonts. |
|
||||
| `Plak` | The executable: the app delegate, the menu, the menu bar icon, the global ⌘P. |
|
||||
|
||||
### Page view
|
||||
- An `NSScrollView` with one editable `NSTextView` for the whole page, the text in the reading column, and a bottom inset of half the visible height. The inset changes when the window changes size.
|
||||
- An image is an `NSTextAttachment` that knows its relative path.
|
||||
- A code block or table is an `NSTextAttachment` too. While you edit it, an editor view is placed over the object; when the edit ends, the editor goes away.
|
||||
- The created date is a custom text attribute on every character of a block. The date of a block is the date on its first character. When a new block has no date, plak stamps it with now. Because the characters carry the date, a split keeps the date for both parts. New typing at the start of a new block must not inherit the date of the block above.
|
||||
- The margin draws the dates; it is not made of views that take clicks.
|
||||
|
||||
@@ -143,33 +194,44 @@ scripts/bundle.sh # build/Plak.app, ad-hoc signed (--install copies it
|
||||
10. An image attachment is never wider than the column; a missing file gives the `image missing` placeholder and saves back as the same line.
|
||||
11. Copy of a selection with an image gives the `` line as plain text; pasting that text gives the image again.
|
||||
12. `PageStore` writes once after a burst of changes (debounce), with the latest text, and starts with an empty page when the page file is missing.
|
||||
13. Fence round trip: a page file with a fenced code block and a fenced table, each with a date line above it and blank lines inside, reads and writes back the same.
|
||||
14. A code block whose text holds a line that starts with ```` ``` ```` gets a longer fence, and reads back as the same text.
|
||||
15. A fence without a closing line, or with a word other than `php`, `json`, `xml` or `csv`, stays normal text.
|
||||
16. Paste detection gives the right kind for PHP (`<?php` and `<?=`), JSON, XML and CSV (`,`, `;` and tab). These stay text: a sentence with commas, one CSV line, lines with different field counts, invalid JSON, invalid XML.
|
||||
17. CSV: quoted fields with the delimiter, quotes and line breaks inside read correctly. An unedited table writes back its original text; an edited table writes its own delimiter and quotes only where necessary.
|
||||
18. JSON on one line is pretty-printed with a 2-space indent and the key order kept. Copy of a selection with a code block or table gives the fenced text; pasting that text gives the object again.
|
||||
|
||||
### Manual checks on the running app
|
||||
13. Launch with a long page: the window shows the end of the text in the vertical middle, with the caret there.
|
||||
14. Launch with an empty page: the caret is in the vertical middle.
|
||||
15. Click in the middle of the page and type: the text goes there. Select across two paragraphs and delete: it works as in any text field.
|
||||
16. Type `# title` and `**bold**`: they show as typed, without styling.
|
||||
17. In a wide window the dates show in the left margin; in a narrow window they disappear.
|
||||
18. Paste a screenshot (⇧⌃⌘4, then ⌘V): the image shows at the caret. Backspace after it deletes it; ⌘Z brings it back.
|
||||
19. Drag an image from Finder into the middle of the page: the caret shows the drop place, and the image lands there.
|
||||
20. Quit and open again: text, dates and images are back; page.md holds the date lines and the `` lines.
|
||||
21. ⌘W hides the window; ⌘P shows it again with the same scroll position.
|
||||
22. Plak shows no Dock icon and is not in ⌘Tab; the menu bar icon is there. Hide Plak hides the window, Show Plak shows it.
|
||||
23. Show the window on desktop 1, go to desktop 2 and press ⌘P: the window comes to desktop 2.
|
||||
24. Put another app in fullscreen and press ⌘P: the window shows over it. With another app in front, press ⌘P: plak comes in front with the caret ready; click the other app and it comes in front again.
|
||||
25. Quit Plak from the menu bar icon, then open plak from Spotlight: it starts, scrolled to the end.
|
||||
26. With plak running, scroll up, then open plak from Spotlight: it shows scrolled to the end. Do it again after ⌘W: the same. Scroll up and press ⌘P, or use Show Plak: the scroll position stays.
|
||||
27. Move the pointer into the top 28 pt of the window, also after a scroll, a resize, and with another app in front: it is the arrow, and press and drag moves the window. Below the strip it is the text cursor.
|
||||
28. In another app, press ⌘P, then Esc: plak hides and the other app is in front with its caret ready. Do it again with ⌘P instead of Esc: the same. ⌘P again shows plak with the same scroll position, on the current desktop.
|
||||
29. ⌘W and Hide Plak also give the other app its focus back; type a word just before, quit and open again: the word is there.
|
||||
30. Hold `e` for the accent popup and press Esc: the popup closes and plak stays. Start a Japanese or Chinese composition and press Esc: the composition is cancelled and plak stays.
|
||||
19. Launch with a long page: the window shows the end of the text in the vertical middle, with the caret there.
|
||||
20. Launch with an empty page: the caret is in the vertical middle.
|
||||
21. Click in the middle of the page and type: the text goes there. Select across two paragraphs and delete: it works as in any text field.
|
||||
22. Type `# title` and `**bold**`: they show as typed, without styling.
|
||||
23. In a wide window the dates show in the left margin; in a narrow window they disappear.
|
||||
24. Paste a screenshot (⇧⌃⌘4, then ⌘V): the image shows at the caret. Backspace after it deletes it; ⌘Z brings it back.
|
||||
25. Drag an image from Finder into the middle of the page: the caret shows the drop place, and the image lands there.
|
||||
26. Quit and open again: text, dates and images are back; page.md holds the date lines and the `` lines.
|
||||
27. ⌘W hides the window; ⌘P shows it again with the same scroll position.
|
||||
28. Plak shows no Dock icon and is not in ⌘Tab; the menu bar icon is there. Hide Plak hides the window, Show Plak shows it.
|
||||
29. Show the window on desktop 1, go to desktop 2 and press ⌘P: the window comes to desktop 2.
|
||||
30. Put another app in fullscreen and press ⌘P: the window shows over it. With another app in front, press ⌘P: plak comes in front with the caret ready; click the other app and it comes in front again.
|
||||
31. Quit Plak from the menu bar icon, then open plak from Spotlight: it starts, scrolled to the end.
|
||||
32. With plak running, scroll up, then open plak from Spotlight: it shows scrolled to the end. Do it again after ⌘W: the same. Scroll up and press ⌘P, or use Show Plak: the scroll position stays.
|
||||
33. Move the pointer into the top 28 pt of the window, also after a scroll, a resize, and with another app in front: it is the arrow, and press and drag moves the window. Below the strip it is the text cursor.
|
||||
34. In another app, press ⌘P, then Esc: plak hides and the other app is in front with its caret ready. Do it again with ⌘P instead of Esc: the same. ⌘P again shows plak with the same scroll position, on the current desktop.
|
||||
35. ⌘W and Hide Plak also give the other app its focus back; type a word just before, quit and open again: the word is there.
|
||||
36. Hold `e` for the accent popup and press Esc: the popup closes and plak stays. Start a Japanese or Chinese composition and press Esc: the composition is cancelled and plak stays.
|
||||
37. Paste PHP, JSON, XML and CSV text: each becomes one object on its own line. Paste a normal sentence: it stays text. Paste JSON with ⌥⇧⌘V: it stays text.
|
||||
38. Click a code block and type: the caret is inside and the colours update. Tab inserts 4 spaces. Esc ends the edit. ⌘Z undoes the whole edit in one step.
|
||||
39. In a table, move with the arrows and with Tab, type to replace a value, Enter on the last row adds a row, Tab on the last column adds a column, ⌘⌫ deletes the row, ⌥⌘⌫ deletes the column.
|
||||
40. ↑ on the first line of a code block, or on the first row of a table, goes to the text above; ↓ on the last goes to the text below.
|
||||
41. Press Esc while you edit a code block or a table cell: the edit ends and plak stays open.
|
||||
42. Edit a code block and a table, then quit and open again: the edits are back, and page.md holds the fenced blocks.
|
||||
|
||||
## 6. Out of scope for v1
|
||||
|
||||
Remembered for later, not built now:
|
||||
- Cleaning up image files that no text uses any more.
|
||||
- Remote images and browser drags without a file.
|
||||
- Pasting code that becomes a code block by itself.
|
||||
- Drawing with the touch screen or the mouse.
|
||||
- A diagram editor: lines, arrows, shapes.
|
||||
|
||||
@@ -188,3 +250,9 @@ These follow from the answers, but you did not choose them yourself. Change them
|
||||
- A paste inside a block gets no own date (1.6).
|
||||
- While dragging an image, the text caret shows the drop place, not a separate line (1.7).
|
||||
- Blank lines are kept exactly as typed (1.4).
|
||||
- JSON pasted on one line is pretty-printed (1.8).
|
||||
- A fence typed by hand becomes a code block or table only when plak opens the page again (1.8).
|
||||
- Long lines in a code block wrap (1.8).
|
||||
- Long values in a table are cut off with `…` (1.8).
|
||||
- ⌥⇧⌘V pastes without code block or table detection (1.8).
|
||||
- The key map of the table (1.8).
|
||||
|
||||
Reference in New Issue
Block a user