Commit Graph

289 Commits

Author SHA1 Message Date
Isaiah Odhner
2ee021e236 Move expand_directory_tree logic into an EnhancedDirectoryTree class 2023-04-20 22:23:06 -04:00
Isaiah Odhner
9d4cccfe6e Fix type annotation for on_tree_node_highlighted 2023-04-20 22:20:20 -04:00
Isaiah Odhner
5ed2180d7e Fix releasing window drag 2023-04-20 21:39:38 -04:00
Isaiah Odhner
15af8f6403 Fix warning icon visibility after the first display
It gets set to `display = False` when unmounting, I think.
2023-04-20 21:01:33 -04:00
Isaiah Odhner
986db57e17 Improve layout inspector with built in css_identifier_styled
It now shows [name=...] if applicable, and styles each part differently.
And it's less code!
2023-04-20 21:01:32 -04:00
Isaiah Odhner
48f0303a54 Refactor create_warning_message_box into MessageBox 2023-04-20 21:01:14 -04:00
Isaiah Odhner
093a314d60 Move bits of warning_message_box that need App back into App 2023-04-20 18:09:49 -04:00
Isaiah Odhner
37ff810616 Move warning_message_box implementation to windows.py 2023-04-20 18:02:07 -04:00
Isaiah Odhner
9ab748f255 Use Python class names for window CSS 2023-04-20 17:47:20 -04:00
Isaiah Odhner
5e72708fd8 Rename Python class for character selector dialog for consistency
If I want it to be less verbose, I should rename the super-class
from "DialogWindow" to just "Dialog".
2023-04-20 17:42:17 -04:00
Isaiah Odhner
e39fd52381 Rename CSS class for character selector dialog for consistency 2023-04-20 17:40:15 -04:00
Isaiah Odhner
4a9ef84d28 Rely on Python class names instead of CSS class names for menu CSS 2023-04-20 17:40:15 -04:00
Isaiah Odhner
9b3793682d Fix inconsistent CSS ID naming style
I've settled on underscores, for now at least.
Generally I use hyphens.
Built-ins actually use hyphens, like `.-dark-mode`.
Maybe I should be using hyphens.
But for now, consistency is what's important, and I'm using underscores.
2023-04-20 17:26:41 -04:00
Isaiah Odhner
433fa68a21 Refactor anti-garbage-collection Task reference keeping
Now it's really verbose, but I don't have to worry about reusing
the same name twice. Or coming up with new, fun ones.

https://docs.python.org/3/library/asyncio-task.html#asyncio.create_task

> Important: Save a reference to the result of this function, to avoid a task disappearing mid-execution. The event loop only keeps weak references to tasks. A task that isn’t referenced elsewhere may get garbage collected at any time, even before it’s done. For reliable “fire-and-forget” background tasks, gather them in a collection:
>
> background_tasks = set()
>
> for i in range(10):
>     task = asyncio.create_task(some_coro(param=i))
>
>     # Add task to the set. This creates a strong reference.
>     background_tasks.add(task)
>
>     # To prevent keeping references to finished tasks forever,
>     # make each task remove its own reference from the set after
>     # completion:
>     task.add_done_callback(background_tasks.discard)
2023-04-20 17:18:55 -04:00
Isaiah Odhner
2a2b29e30e Use a shared CSS class for styling Open/Save As dialogs 2023-04-20 16:47:11 -04:00
Isaiah Odhner
5b20caf118 Add basic help window 2023-04-20 16:27:46 -04:00
Isaiah Odhner
3235ebcf26 Implement About Paint dialog 2023-04-20 16:27:41 -04:00
Isaiah Odhner
a33dd153ce I tried to fix flickering when using magnifier tool
- Move `self.canvas.magnification = self.magnification` up. It happens,
  due to internal call_after_refresh, and should happen, before scroll.
- Remove note about other code in JS Paint, I think it's not needed.
- Note my attempts at fixing flicker, which were unsuccessful, so that
  I don't try the exact same things later, and feel stupid,
  and so I don't accrue so many branches.
2023-04-20 15:39:33 -04:00
Isaiah Odhner
896f43e7ed Fix one canvas refresh not using magnification 2023-04-20 15:13:14 -04:00
Isaiah Odhner
1740e39301 Fix canvas size not updating
I actually added this before, and then thought it wasn't needed for some reason.
2023-04-20 14:54:20 -04:00
Isaiah Odhner
56ad762819 Fix mismatch between file opening behavior of Open dialog vs CLI arg 2023-04-20 14:51:06 -04:00
Isaiah Odhner
c3763523bd Visually debug IndexError...
The canvas size isn't getting updated (fully) when loading a document.
2023-04-20 14:45:11 -04:00
Isaiah Odhner
5958ba348b OK maybe this isn't so robust... 2023-04-20 14:42:51 -04:00
Isaiah Odhner
51c370dc24 Instead of clearing, prevent filling filename input in Open dialog
Prevent the filename input from being populated in the first place,
instead of resetting after its unintentionally populated when the
directory tree is expanded.

Nip it in the bud. Head it off at the pass. Stop it at the source.

It still needs this new flag to be cleared on a timer, but at least this
timer is near the code for the other timers it needs to trigger after.

Explicitly set filename for Save As dialog, which SHOULD be populated.
2023-04-20 14:42:51 -04:00
Isaiah Odhner
801c147d4c Clear filename input in Open dialog, which gets set unintentionally 2023-04-20 13:00:05 -04:00
Isaiah Odhner
4bca563358 Remove timer for setting focus
Interestingly, this moves the filename input's cursor to the start,
whereas it was positioned at the end when using the timer.
Unfortunately the Input control doesn't support selection,
which is what I would really want as the behavior.
2023-04-20 12:43:14 -04:00
Isaiah Odhner
8a51bd325c Focus default control within window after opening 2023-04-20 12:31:23 -04:00
Isaiah Odhner
ec4d044f8a Handle FileNotFoundError coming from os.path.samefile 2023-04-20 12:08:03 -04:00
Isaiah Odhner
61d1532552 Prevent multiple character selector dialogs from opening at once 2023-04-20 11:54:42 -04:00
Isaiah Odhner
74c4af1a5b Refactor meta character mapping to use match 2023-04-20 01:26:00 -04:00
Isaiah Odhner
7cdb35a4ae Start defining an enlarged view for certain characters 2023-04-20 01:25:43 -04:00
Isaiah Odhner
e48c9cc632 Fix width of selected color/char display input
I'm not sure why it shrunk when changing to an Input
2023-04-20 01:21:27 -04:00
Isaiah Odhner
b955aaf361 Input or pick character to draw with 2023-04-20 01:21:06 -04:00
Isaiah Odhner
8727ed27de Use .dialog_window, already specified in one place, instead of .dialog, scattered about 2023-04-20 00:28:45 -04:00
Isaiah Odhner
29bc94efbc Ignore RuntimeError "cannot join current thread" 2023-04-19 21:45:18 -04:00
Isaiah Odhner
ac10d5e500 Tweak error messages to use colons for clarity 2023-04-19 21:34:29 -04:00
Isaiah Odhner
c659418240 Clean up attempt at more optimal color inverting
I don't want to bother importing Rich's Color class in addition to
Textual's Color class.

This also doesn't work, which might be the fastest if it worked:

    style.color.triplet.red = 255 - style.color.triplet.red
    style.color.triplet.green = 255 - style.color.triplet.green
    style.color.triplet.blue = 255 - style.color.triplet.blue
    style.bgcolor.triplet.red = 255 - style.bgcolor.triplet.red
    style.bgcolor.triplet.green = 255 - style.bgcolor.triplet.green
    style.bgcolor.triplet.blue = 255 - style.bgcolor.triplet.blue
2023-04-19 21:20:10 -04:00
Isaiah Odhner
bf16e60509 Clean up old magnifier preview approach 2023-04-19 21:14:07 -04:00
Isaiah Odhner
bd8ebad377 Implement magnifier preview 2023-04-19 21:08:59 -04:00
Isaiah Odhner
0026c06268 Fix inconsistent indentation 2023-04-19 19:58:07 -04:00
Isaiah Odhner
9120d49546 Implement the magnifier tool 2023-04-19 19:44:57 -04:00
Isaiah Odhner
ad6d799db9 Note reset command to recover from bad terminal state 2023-04-19 19:09:02 -04:00
Isaiah Odhner
eae2ffe44a Remove max size on window content
It's a bad idea, unless applied on a case-by-case basis.
It makes things wrap badly when the viewport is narrow, making things
much less readable, even though the aim is to make it more readable
by ensuring visibility. And it makes message boxes feel less OS-like.
It's better to have to drag a window back and forth to read it, than
to have it wrap at every character.
2023-04-19 16:06:49 -04:00
Isaiah Odhner
dd5e646dfe Prompt to save changes before reloading program 2023-04-19 16:00:43 -04:00
Isaiah Odhner
509618c1be Try to clean up the file change observer when restarting
This is all theoretical.
2023-04-19 15:19:27 -04:00
Isaiah Odhner
3c2ff7b3d8 Note textual console devtool (and slowness) 2023-04-19 14:27:12 -04:00
Isaiah Odhner
18ef3898c6 Fix scroll wheel while hovering over a menu separator 2023-04-19 14:27:12 -04:00
Isaiah Odhner
140ff15ff1 Restart the app on changes 2023-04-19 14:27:12 -04:00
Isaiah Odhner
adcaed47cd Handle base language (English) better
- Don't log an error about a missing language file at startup.
- Don't append to untranslated.txt for strings that don't need
  translation because they're already in the target language.
  I could use an early return for this too, but it's not important.
2023-04-19 02:59:48 -04:00
Isaiah Odhner
7b0eaff108 Reload the app with F2, not F4
I'm dumb, I forgot the app uses F4.
2023-04-19 02:45:55 -04:00