Commit Graph

943 Commits

Author SHA1 Message Date
Isaiah Odhner
94e02197f5 Convert NanoTiny font to text (2x2 metaglyphs) 2023-05-12 18:53:36 -04:00
Isaiah Odhner
2753427ae6 Repack NanoTiny to remove border 2023-05-12 18:18:17 -04:00
Isaiah Odhner
0f769689ef Update readme 2023-05-10 01:34:46 -04:00
Isaiah Odhner
8e6bc9d9a4 Formalize canvas events API: don't include event object in message
This has upsides and downsides.
- It's less verbose in most cases
- But event.offset I can't use unless I define that myself.
  (I wasn't even taking full advantage of this property.)
- It's clearer what's used because what is used has to be copied.
- But what's used has to be copied.
2023-05-10 00:38:05 -04:00
Isaiah Odhner
6dc6dc1a60 Handle stransi.Unsupported 2023-05-09 23:56:26 -04:00
Isaiah Odhner
1cdf570955 Handle minimum height at end so it no longer needs one row initially
Regarding "Initial document is zero wide to avoid an extraneous character at (0,0)",
this is not necessary anymore since I (recently) changed it to set, rather than append, values.
Regarding "...but needs one row to avoid IndexError", this commit removes that constraint.
It could now be initialized with size (1, 1) or (0, 0) or even (1, 0) I suppose, although that's not really a contender.
2023-05-09 23:56:26 -04:00
Isaiah Odhner
0d2840d5da Recode samples with new efficient ANSI export
- Will this make the files smaller when compressed? Doubtful.
- Will this commit make the repo larger? Yes, since the old is kept.
- But keeping the files in line with current encoding will allow me
to see changes in encoding, using --recode-samples.
- I'm excluding files not saved with the app:
  generated files (4x4_font_template.ans and gradient_test.ans)
  which will be recreated in their original form when regenerating,
  and a manually created empty file (0x0.ans), which tests the minumum
  document size of 1x1.
2023-05-09 23:08:43 -04:00
Isaiah Odhner
ef4fb910d5 Generate smaller ANSI files with Segment.simplify 2023-05-09 22:55:41 -04:00
Isaiah Odhner
7baba86a68 Fix type checker errors by making a return type more specific
With the more general type, it was giving:

  /home/io/Projects/textual-paint/src/textual_paint/paint.py:798:38 - error: Cannot access member "markup" for type "ConsoleRenderable"
    Member "markup" is unknown (reportGeneralTypeIssues)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:798:16 - error: Type of "markup" is unknown (reportUnknownMemberType)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:798:38 - error: Cannot access member "markup" for type "RichCast"
    Member "markup" is unknown (reportGeneralTypeIssues)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:798:38 - error: Cannot access member "markup" for type "str"
    Member "markup" is unknown (reportGeneralTypeIssues)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:798:16 - error: Return type is unknown (reportUnknownVariableType)
2023-05-09 22:45:37 -04:00
Isaiah Odhner
bb8aff84e9 Refactor so x is a column index when padding row widths 2023-05-09 22:36:33 -04:00
Isaiah Odhner
349887a74e Add minimum size of 1x1 for plain text files to match ANSI file loading 2023-05-09 22:32:43 -04:00
Isaiah Odhner
fa625e5868 Add empty file as a sample 2023-05-09 22:08:47 -04:00
Isaiah Odhner
6a650b7547 Fix missing last row when loading ANSI file not ending with a newline
This fixes loading samples/4x4_font_template.ans, and I should be able
to rebase my code for more efficient ANSI file saving, where I was also
running into missing last rows.
2023-05-09 22:08:02 -04:00
Isaiah Odhner
91ad494063 Detect file as ANSI if it includes tab, bell, backspace, etc.
This fixes opening/pasting text containing tabs (but not escape codes),
for instance if you want to copy/paste a table of characters, as I did.
2023-05-09 21:51:36 -04:00
Isaiah Odhner
7ce6cc08ca Add support for tab, backspace, and (ignoring) bell for ANSI loading 2023-05-09 19:56:36 -04:00
Isaiah Odhner
de4cf01f73 Fix scrolling in editing area, broken when updating Textual
somewhere from 0.19.0 to 0.22.3
2023-05-09 19:35:30 -04:00
Isaiah Odhner
77f631e396 Fix squashed columns when ANSI file jumps horizontally
Now I can load the font template that I made with generate_font_template.py
2023-05-09 19:23:55 -04:00
Isaiah Odhner
bd4bfa93e1 Swap x/y as received from stransi 2023-05-09 19:15:27 -04:00
Isaiah Odhner
d90449e2de Fix type errors in watchdog thread cleanup
- `observer` can be None, if --restart-on-changes was not passed, but
  the hotkey F2 is pressed.
- `is_alive` is a bound method, not a property. It was definitely used
  like a property in the code I referenced.

I didn't fix these type checker errors for a long time because:
  1. they never caused actual problems for me, and
  2. when adding a type annotation `observer: Observer | None`, Pyright
     gets even _more_ confused, saying it's Unknown | None instead of
     BaseObserver | None. The secret trick was to leave it unannotated.
  3. Adding parentheses to make it `is_alive()` also made Pyright seem
     even more confused, saying it was Unknown — until I added the
     conditional.
2023-05-09 18:03:40 -04:00
Isaiah Odhner
ef409f4756 Ignore a type checker error with watchdog observer.schedule
Type of "schedule" is partially unknown
  Type of "schedule" is "(event_handler: Unknown, path: Unknown, recursive: bool = False) -> ObservedWatch"PylancereportUnknownMemberType
2023-05-09 17:07:56 -04:00
Isaiah Odhner
302e578387 Generate type stubs for stransi and ochre 2023-05-09 16:58:25 -04:00
Isaiah Odhner
385fffb704 Handle cursor and clear command when loading ANSI files 2023-05-09 16:44:49 -04:00
Isaiah Odhner
b814789b17 Generate font template for a meta-character font 2023-05-09 16:39:42 -04:00
Isaiah Odhner
d54a4e690f Extend meta-character handling to shaded block characters 2023-05-09 15:03:06 -04:00
Isaiah Odhner
24331bd5e2 Add type annotations for this silly test script 2023-05-09 02:04:53 -04:00
Isaiah Odhner
cc06bcc6e7 Make pink fade to blue towards the bottom 2023-05-09 02:04:53 -04:00
Isaiah Odhner
de625b2d9b Arrange flowers in a spiral 2023-05-09 02:04:53 -04:00
Isaiah Odhner
2faf7f55a6 Make gradient test more floral 2023-05-09 02:04:53 -04:00
Isaiah Odhner
f7fdecd5a3 Generate gradient test ANSI art 2023-05-09 01:18:30 -04:00
Isaiah Odhner
2e6abea6ee Fix terrible UnicodeDecodeError message that didn't fit on screen 2023-05-09 00:51:25 -04:00
Isaiah Odhner
5a0f1dacfe Add max file size limit when opening or pasting from files 2023-05-09 00:33:22 -04:00
Isaiah Odhner
e37255fc98 Reimplement --recode-samples in parallel, not loading into editor
Ooh, more importantly than running in parallel, this actually fixes
error handling. I had chmodded a file to be read-only for testing,
and this is failing on it loudly instead of silently ignoring an error
that I didn't know about! Because it was silenced! That was a bit of a
redundant way of saying that, but better to be heard than be SILENT...!
                                                             *crickets*
2023-05-08 01:33:35 -04:00
Isaiah Odhner
15980dd4c9 Reuse method to open files for --recode-samples
This got LONGER. I hate asyncio.
2023-05-08 01:10:36 -04:00
Isaiah Odhner
fa173963f6 Reuse method to open files from CLI, with in-TUI error handling
Sigh, it didn't even get shorter, because of stupid async shit.
2023-05-08 01:05:46 -04:00
Isaiah Odhner
3af12599dd Hide dotfiles, dotfolders, and backup files in file dialogs 2023-05-07 21:56:50 -04:00
Isaiah Odhner
403e816644 Remove stupid comment
It doesn't help in this context, and it doesn't help give context.
The function is named "go_ahead"!
2023-05-07 21:48:32 -04:00
Isaiah Odhner
fa86f6f5ce Don't discard backup file if you open it for editing 2023-05-07 21:48:32 -04:00
Isaiah Odhner
aa96062f97 Fix confused comment 2023-05-07 18:56:25 -04:00
Isaiah Odhner
51152faca6 Include file path in error messages 2023-05-07 17:03:40 -04:00
Isaiah Odhner
30eb9ba38f Fix confusing error message after opening backup of the active file
The backup of the current file will be deleted just after opening it.
I should probably actually prevent that, but this commit just fixes
an error message thrown up when trying to then open another file.
It said "File not found", but confusingly was not referring to the file
you were trying to open, but rather the currently open file.

Repro test steps:
Open a file (optional), make changes, and wait for backup to be saved;
open the new .ans~ backup file (discarding changes to the main file),
then try to open any file. "File not found" message should not be shown.
2023-05-07 17:03:40 -04:00
Isaiah Odhner
e47c9693b1 DRY handle_button code between Open / Save As 2023-05-07 13:37:27 -04:00
Isaiah Odhner
c2fd1f5dfd Make Open / Save As dialogs' handle_button code more similar
- request_close() instead of close() for Open dialog
- code path structure
- `filename` vs `name`
- `self.content.query_one` vs `self.query_one`
2023-05-07 13:37:27 -04:00
Isaiah Odhner
ad9983ecfe Remove Static() wrappers and disable markup parsing for messages
- This is shorter/cleaner.
- This is less prone to mistaken parentheses placement, although it
  should give a type error to do `Static() + Static()`
- I already disabled markup parsing for two cases where filenames are
  interpolated, but there was still:
  "An unexpected error occurred while reading %1"
  which was liable to misinterpret things as markup.
  Note that anything in square brackets can be treated as markup and
  become hidden, not just recognized tags like [red].
2023-05-07 13:36:32 -04:00
Isaiah Odhner
08cef5e875 Rename parameter that does not have to be a widget 2023-05-07 13:09:34 -04:00
Isaiah Odhner
e3ccb7614c Rename message box helper method 2023-05-07 13:05:55 -04:00
Isaiah Odhner
6c1b458cee Fix warning icon not showing up on subsequent dialogs 2023-05-07 12:55:19 -04:00
Isaiah Odhner
a06cf807e0 Fix immediate closing of dialog opened with Enter
For example, in the Open dialog, typing a filename that doesn't exist,
and then hitting enter, it's supposed to say "File not found", but
if the event isn't prevented/stopped, it will also be handled by
the new dialog, and you won't even see it.
2023-05-07 12:51:10 -04:00
Isaiah Odhner
b4971a0abf DRY Open / Save As dialog window content 2023-05-07 12:41:41 -04:00
Isaiah Odhner
e7b251a1c3 Add label for filename input, instead of using placeholder text 2023-05-07 12:26:55 -04:00
Isaiah Odhner
1a28f5cb49 Focus filename input in file dialogs by default 2023-05-07 12:02:25 -04:00