Commit Graph

703 Commits

Author SHA1 Message Date
Isaiah Odhner
321dd1284f Move "type: ignore" comment now serving a different purpose
Before this was presumably suppressing the `self.app` bogus error.
2023-07-17 12:25:33 -04:00
Isaiah Odhner
a0f837aad7 Remove unnecessary "type: ignore" comments 2023-07-16 01:06:24 -04:00
Isaiah Odhner
15b35eaf5c Fix new errors after updating pyright (v1.1.314 -> v1.1.317)
→ PYRIGHT_PYTHON_FORCE_VERSION=latest pyright

added 1 package, and audited 2 packages in 4s

found 0 vulnerabilities
/home/io/Projects/textual-paint/src/textual_paint/paint.py
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1173:64 - error: Condition will always evaluate to True since the types "Never" and "None" have no overlap (reportUnnecessaryComparison)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1214:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1217:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1220:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1223:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1229:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
  /home/io/Projects/textual-paint/src/textual_paint/paint.py:1233:26 - error: Pattern will never be matched for subject type "Never" (reportUnnecessaryComparison)
7 errors, 0 warnings, 0 informations
2023-07-15 23:32:18 -04:00
Isaiah Odhner
f21899fd1d Use LineFilter to avoid private _segments access
This fixes the last pyright error (on pyright v1.1.314)
2023-07-15 23:24:56 -04:00
Isaiah Odhner
f6a40028e8 Update and clarify help text 2023-07-15 23:05:41 -04:00
Isaiah Odhner
b62a92a782 Simplify using Segment.apply_style 2023-07-15 22:45:52 -04:00
Isaiah Odhner
96b2d08789 Ignore all but one last Pyright error
(on pyright v1.1.314)
2023-07-15 22:27:49 -04:00
Isaiah Odhner
26cf8c3e64 Annotate instruction from stransi 2023-07-15 22:26:41 -04:00
Isaiah Odhner
d5669f434f Fix type mismatch in unused code
error: Incompatible types in assignment (expression has type "None", variable has type "bool")  [assignment]
2023-07-15 21:52:47 -04:00
Isaiah Odhner
0a6fb29e10 Reorder None case for mypy
While Pyright can narrow down the type of format_id from `str | None` to `str` based on `format_id in Image.SAVE` (where `Image.SAVE` is `dict[str, Any]`), mypy does not.
2023-07-15 21:47:43 -04:00
Isaiah Odhner
641a46e368 Add type hints for mypy 2023-07-15 21:43:50 -04:00
Isaiah Odhner
3ff0b47650 Fix strange default for Window.title reactive var 2023-07-15 21:29:59 -04:00
Isaiah Odhner
eb81d5e934 Add missing annotations, needed for mypy 2023-07-15 21:22:25 -04:00
Isaiah Odhner
1c737fada2 Avoid shell=True and fix mypy errors about mismatching type for args 2023-07-15 21:09:08 -04:00
Isaiah Odhner
1ce0487a52 Fix reportOptionalMemberAccess errors for width/height 2023-07-15 21:09:08 -04:00
Isaiah Odhner
87f1f50f06 Fix some stupid pyright errors 2023-07-15 20:27:20 -04:00
Isaiah Odhner
f50aef18e7 None pizza with left beef 2023-07-15 19:44:05 -04:00
Isaiah Odhner
16f4bc0a88 Fix some mypy errors (and a couple pyright errors) 2023-07-15 19:44:05 -04:00
Isaiah Odhner
dd4fea1e78 Add py.typed for mypy 2023-07-15 19:44:05 -04:00
Isaiah Odhner
4fc5a6e8e5 Clarify a comment
"optional" is ambiguous, between optional arguments (i.e. parameters with a default value), and a union with `None` (i.e. `Optional`, or `| None`)
2023-07-15 19:44:05 -04:00
Isaiah Odhner
cbcf22c4d7 Clean up old _expanding_directory_tree flag, and logging 2023-07-15 19:44:05 -04:00
Isaiah Odhner
54f29eabf1 Fix false positives and false negatives for when to populate file name
When opening the Open dialog, it shouldn't populate the file name input,
but when clicking a file, it should fill in the clicked file's name.

The `_expanding_directory_tree` flag gave false positives:
- When opening a file in a directory the program doesn't have permissions to via the CLI,
  such as with `python -m src.textual_paint.paint /root/nonexistent`,
  opening the Open dialog, and clicking a file, it wasn't populating the filename input,
  because the flag was never cleared if it couldn't find (access) the
  directories and file matching any of the path parts, working down the directory structure.
  
  This was broken in [b3ca55a3b1] "Use new callback to remove race condition"
  but before, it just cleared the flag after a delay, so it wasn't a good solution,

It also gave false negatives:
- When opening the Open dialog, it was populating the name input field
  with the file selected programmatically with `expand_to_path`,
  instead of leaving it blank.
  
  The automatic expansion was broken in [e9755637d6] "Update Textual to 0.26.0"
  due to changes 0.25.0, since directory contents are now loaded in a worker.
  This flag's behavior was broken since rewriting the code to handle asynchronous directory loading in
  [4e1f11ab23] "Fix expanding directory tree to current folder, in file dialogs"

An alternative I considered was to create a new message such as `EnhancedDirectoryTree.NodeHighlighted`, but let's call it `EnhancedNodeHighlighted`, then to have `on_tree_node_highlighted` in `EnhancedDirectoryTree` which sends `EnhancedNodeHighlighted` always with `from_expand_to_path=False`, and then do:

    | # Suppress EnhancedNodeHighlighted with from_expand_to_path=False
    | with self.prevent(self.EnhancedNodeHighlighted):
    | 	self.select_node(node)
    | # Send it with the flag set
    | self.post_message(self.EnhancedNodeHighlighted(..., from_expand_to_path=True))

The solution I settled on was to add an `on_tree_node_highlighted` method to my `EnhancedDirectoryTree` for the purpose of clearing the flag, with still a further delay so that the app's `on_tree_node_highlighted` can use the flag before its cleared.

(I left `_expanding_directory_tree` in at this commit for comparison of the behavior. For a fair estimate of the complexity of this change, include the following cleanup in the diff.)
2023-07-15 19:44:05 -04:00
Isaiah Odhner
1b8b07def9 Move callback outside try block 2023-07-14 00:08:08 -04:00
Isaiah Odhner
f6607195e8 Clarify docstring association 2023-07-13 22:19:55 -04:00
Isaiah Odhner
c97203e882 Add more error handling to Get Colors 2023-07-13 20:03:23 -04:00
Isaiah Odhner
489bd95a20 Ignore permission errors when deleting backup
and improve error message in the general (fallback) case
2023-07-13 19:43:15 -04:00
Isaiah Odhner
6a4351d824 Handle arbitrary exceptions when deleting backup 2023-07-13 19:35:25 -04:00
Isaiah Odhner
67b4ec8ac4 Return to custom zoom level when zooming out and back in 2023-07-12 02:16:24 -04:00
Isaiah Odhner
9876a3c15c Repeat first color in palette when loading a palette
This ensures all colors are part of the palette.
It would be better to allow the number of color wells to change.
2023-07-12 01:51:57 -04:00
Isaiah Odhner
3713e9ed00 Switch color palette to mIRC's palette when saving/opening as mIRC code format 2023-07-12 01:51:57 -04:00
Isaiah Odhner
618fe00d81 Simplify IRC palette data structure, to match regular palette 2023-07-12 01:51:57 -04:00
Isaiah Odhner
967801cf17 Prevent digits in document from merging with mIRC color codes
If digits were present in the document, they were concatenated after
the color codes, and they ran together indistinguishably.
This changed the color index numbers that were read back, to potentially
invalid color indices, and lost the digits as part of the document.
It needs the delimiter of the ending escape code to separate the digits.
2023-07-12 01:51:57 -04:00
Isaiah Odhner
878bf45ea3 Fix nearest color finding 2023-07-11 18:51:12 -04:00
Isaiah Odhner
0eea55e7f6 Make saved mIRC files openable 2023-07-11 18:25:49 -04:00
Isaiah Odhner
645f1ec127 Add missing duplicate error handling for Paste From 2023-07-11 17:19:08 -04:00
Isaiah Odhner
da85d319e4 Add mIRC code export support 2023-07-11 04:00:22 -04:00
Isaiah Odhner
b885436966 Fix drag and drop of files with CharInput focused 2023-07-11 02:02:18 -04:00
Isaiah Odhner
85ba439cbd Fix pasting into CharInput not affecting brush 2023-07-11 02:02:18 -04:00
Isaiah Odhner
2c1069d619 Fix contrast of fieldsets in dark mode 2023-07-11 00:02:39 -04:00
Isaiah Odhner
da0abcbf1e Add stretch/skew icons to dialog 2023-07-10 23:57:48 -04:00
Isaiah Odhner
2d9ba1ae5f Implement stretch/skew 2023-07-10 21:32:17 -04:00
Isaiah Odhner
b5e52a1463 Conditionally enable angle radio buttons 2023-07-10 19:30:18 -04:00
Isaiah Odhner
f979090b42 Fix layout (Container caused contents to collapse) 2023-07-10 19:10:18 -04:00
Isaiah Odhner
7a81446558 WIP: merge flip/rotate and rotate dialogs 2023-07-10 19:10:18 -04:00
Isaiah Odhner
7d8dddb97f Implement rotate by angle 2023-07-10 18:47:11 -04:00
Isaiah Odhner
2a7d88b10c Implement flip horizontal/vertical 2023-07-10 17:28:19 -04:00
Isaiah Odhner
755a92fce0 DRY adding undos to the stack and clearing redos 2023-07-10 17:28:19 -04:00
Isaiah Odhner
5939c85ea4 Maybe this is cleaner, because it's type-checked 2023-07-10 17:28:19 -04:00
Isaiah Odhner
3a0552ada6 Fix wrapping focus within dialog windows (with Tab)
(broken in last commit)
2023-07-10 17:28:19 -04:00
Isaiah Odhner
c944a74f8d Make Ctrl+I work, distinguished from Tab heuristically 2023-07-10 17:28:19 -04:00
Isaiah Odhner
c1998c52f7 Fix lack of undo state for paste+stamp 2023-07-10 17:28:19 -04:00
Isaiah Odhner
46c52fcaf1 Fix arrow keys not moving selected data if not moved with mouse first 2023-07-10 17:28:19 -04:00
Isaiah Odhner
505cb389f2 Invert only within Free-Form Select's polygon
It turns out this isn't actually how MS Paint works (in Windows 98, my go-to reference), but, isn't it better this way?
2023-07-10 17:28:19 -04:00
Isaiah Odhner
a3e7a2d8b9 Extract method for selection extraction 2023-07-08 01:31:02 -04:00
Isaiah Odhner
54c9f6a500 Implement Image > Invert Colors 2023-07-08 01:14:40 -04:00
Isaiah Odhner
71dd8b50df Implement Image > Clear Image 2023-07-08 00:24:51 -04:00
Isaiah Odhner
2f7182d8c3 Fix structural validity of saved HTML 2023-06-30 21:49:41 -04:00
Isaiah Odhner
6c7d48e49f Disable saving in ICNS format, and update format support list 2023-06-30 21:00:42 -04:00
Isaiah Odhner
6c51b8fba0 Refactor format disabling
- confirm_information_loss and encode_to_format no longer need syncing
- other formats can be disabled easily
2023-06-30 20:10:24 -04:00
Isaiah Odhner
d886e31930 Configure ICO format saving 2023-06-30 19:42:16 -04:00
Isaiah Odhner
f64d75df3c Fix unnecessary backup saving due to reload_after_save 2023-06-30 19:05:06 -04:00
Isaiah Odhner
a2000e7374 Recover from backup file after Save As; fix backup files left behind
Note: "the backup file will be deleted on close" was no longer true since making it check `self.backup_checked_for`.
2023-06-30 18:49:50 -04:00
Isaiah Odhner
12d579592e Fix exception handler catching wrong exception 2023-06-30 17:14:42 -04:00
Isaiah Odhner
2e022bdfe1 Disable saving as JPEG because of low quality 2023-06-30 16:52:13 -04:00
Isaiah Odhner
b419b8ec7d Remove unused import
I had to use base64 instead of html.escape
2023-06-30 16:26:11 -04:00
Isaiah Odhner
5f3a7f259d Fix type signature 2023-06-30 16:23:09 -04:00
Isaiah Odhner
cd1161d454 Disable writing debug.svg 2023-06-30 14:19:39 -04:00
Isaiah Odhner
46e7e9bb30 Embed ANSI data in SVG for perfect round-trip 2023-06-30 14:04:45 -04:00
Isaiah Odhner
46017aca7b Show how to exit in status bar if you hit Ctrl+C with no selection 2023-06-29 21:48:12 -04:00
Isaiah Odhner
b6bea36590 Simplify: avoid passing fake format ID for unknown format case 2023-06-29 00:17:12 -04:00
Isaiah Odhner
6b9c01f196 Fix handling of read-only formats (like .cur)
When attempting to save in a format only supported for opening,
it tripped the assertion here, which I'm removing.
(This code was a little complicated to reason about, and I thought I was
oversimplifying, when restructuring to handle the overlap of warnings,
but I couldn't place what case I was missing, until testing this.)
2023-06-29 00:17:12 -04:00
Isaiah Odhner
e43eb7149c Clarify return value / callback argument 2023-06-28 21:35:19 -04:00
Isaiah Odhner
4750c1212d Handle overlap of warnings (information loss and write-only warnings) 2023-06-28 21:35:19 -04:00
Isaiah Odhner
f194583760 Fix error due to trying to reload after saving non-openable format 2023-06-28 21:32:30 -04:00
Isaiah Odhner
53a484f978 WIP: confirm saving into non-openable formats 2023-06-27 23:36:39 -04:00
Isaiah Odhner
9525ddc583 Handle NoScreen during auto-restart 2023-06-27 20:28:12 -04:00
Isaiah Odhner
87e2ff9b5f Move one-off scripts outside of package
(breaking relative paths)
2023-06-27 18:58:47 -04:00
Isaiah Odhner
ee2fce3166 Implement View Bitmap 2023-06-27 17:15:54 -04:00
Isaiah Odhner
2334e168be Disable tracking untranslated strings 2023-06-27 15:33:56 -04:00
Isaiah Odhner
ca68cb54a7 Move fonts inside of package folder 2023-06-27 15:15:00 -04:00
Isaiah Odhner
0ce80396a8 Handle NoScreen when window closed immediately upon opening 2023-06-27 13:41:24 -04:00
Isaiah Odhner
b3ca55a3b1 Use new callback to remove race condition 2023-06-27 13:37:08 -04:00
Isaiah Odhner
38a31bd1e4 Now that's what I call... back! (the functionality AND the function) 2023-06-27 13:27:03 -04:00
Isaiah Odhner
6db2b53830 No future for this approach... 2023-06-27 13:26:21 -04:00
Isaiah Odhner
e1111a24c6 Consolidate timers when scrolling to and selecting a node 2023-06-27 12:58:06 -04:00
Isaiah Odhner
14475154b9 If you type a folder's path in a file dialog, expand it 2023-06-27 12:29:18 -04:00
Isaiah Odhner
d0385556d1 Allow ~user and env var substitutions in file dialogs
(The todo removed was already satisfied, as it turns out.)
2023-06-20 00:38:53 -04:00
Isaiah Odhner
99b598c0dc Improve window constraints 2023-06-19 22:15:02 -04:00
Isaiah Odhner
7c420416c3 Prevent prepopulating file name in Copy To and Paste From dialogs 2023-06-19 22:15:02 -04:00
Isaiah Odhner
75928bc1da Clean up 2023-06-19 22:14:06 -04:00
Isaiah Odhner
27e1bbe264 Refactor: use new autofocus handling for file dialogs 2023-06-19 22:14:06 -04:00
Isaiah Odhner
e62eb42bd9 Set default focus in Attributes, Custom Zoom, and Edit Colors windows 2023-06-19 22:14:06 -04:00
Isaiah Odhner
3600bea25d Load/save color palettes 2023-06-17 19:41:00 -04:00
Isaiah Odhner
93f98a89e7 Add todos and clarifying notes 2023-06-15 17:46:19 -04:00
Isaiah Odhner
7b32452066 Abort if error occurred when reloading to show information loss during save
I'm not sure about this...
2023-06-14 00:15:53 -04:00
Isaiah Odhner
572d60076f Duplicate error handling for reloading after information loss on save 2023-06-14 00:13:30 -04:00
Isaiah Odhner
faa41d07b2 Confirm discarding information during Save/Open/New, not just Save As 2023-06-13 23:46:30 -04:00
Isaiah Odhner
29e9e7a384 Refactor some encode_based_on_file_extension into encode_to_format
This avoids duplicately detecting the format from the file extension
in one case, and in the other case, avoids using a bogus file name to
implement a default fallback file format.
2023-06-13 19:44:08 -04:00
Isaiah Odhner
737115a00b Refactor confirming information loss 2023-06-13 19:25:44 -04:00
Isaiah Odhner
0a176fc1a4 Prevent unloading document if save fails 2023-06-13 19:14:35 -04:00
Isaiah Odhner
f2facf8a68 Rename is_resize -> is_full_update 2023-06-13 18:27:24 -04:00
Isaiah Odhner
2ed803631b Allow undoing color or character information loss
Of course, this highlights the need to prompt during Save as well,
not just Save As, or to make creating color or character information
impossible depending on the type of file that is open.
2023-06-13 14:50:08 -04:00
Isaiah Odhner
17b4a67455 Fix reloading file after losing color or character information
Can't use self.open_from_file_path because:
1. it short-circuits if the file is already open
2. it clears the undo history*
3. it does stuff with the backup file
4. plus it's not as efficient to use the FS, and it uses a callback,
   which is a pain.

*TODO: make the reload undoable
2023-06-13 14:50:08 -04:00
Isaiah Odhner
3a3a554857 Confirm losing color or character information 2023-06-13 14:50:08 -04:00
Isaiah Odhner
a598f83047 Add source column to key bindings table 2023-06-13 01:56:11 -04:00
Isaiah Odhner
d1318e696b Center checkmarks in the boolean columns 2023-06-13 01:46:55 -04:00
Isaiah Odhner
8ec9056bdf Fix "Nothing selected" text getting pushed down in Keys tab
This is just a workaround.
2023-06-13 01:38:19 -04:00
Isaiah Odhner
a690a45a98 Show key bindings in a DataTable in the inspector
This now shows bindings from ancestors DOM nodes as well.
2023-06-13 01:38:19 -04:00
Isaiah Odhner
adc21a1ef4 Prevent "(edited)" mark for unchanged values (again!)
I implemented this previously in 8278e5da94
and had to redo it after changing it to use merge()
2023-06-12 22:38:49 -04:00
Isaiah Odhner
750c77b0ed Fix editing inline styles after first time 2023-06-12 22:20:01 -04:00
Isaiah Odhner
d69334c102 Fix "(edited)" marks
Update style traces when styles are changed with `merge`/`merge_rules`.

I wish `merge` used `merge_rules` so I could define just one extra
instrumentation point. I guess I could make my `merge` use my version of
`merge_rules`, but that feels weird, even if it's probably not any more
fragile to implement it that way.
2023-06-12 21:54:25 -04:00
Isaiah Odhner
8911c406be Add error handling for inline style editing, breaking "(edited)" marks
Using .merge() isn't tracked by the call stack recording (yet), so it
can no longer attribute inline styles to editing with the inspector,
but this lack of tracking was already a problem, it just highlights it.
2023-06-12 20:48:55 -04:00
Isaiah Odhner
8278e5da94 Prevent "(edited)" mark when value was left unchanged 2023-06-12 20:06:53 -04:00
Isaiah Odhner
61eb8631b2 Edit inline styles in CSS tab of inspector 2023-06-12 20:02:29 -04:00
Isaiah Odhner
52c26ade26 Update import in an unused module 2023-06-12 00:43:42 -04:00
Isaiah Odhner
bf675e4c51 Fix two related type checking errors 2023-06-12 00:43:42 -04:00
Isaiah Odhner
0f5193dc50 Move auto restart code to a module 2023-06-12 00:23:51 -04:00
Isaiah Odhner
6946669a41 Update screenshot, and screenshot methodology, and remove table wrapper
The old screenshot was generated by Select All and Copy As HTML in
Ubuntu's Terminal app (using a keyboard shortcut that had to be set up
first), and post-processed using code included in screenshot.svg, which
I'm now deleting.

The new screenshot is generated using Textual's built-in SVG export.
It displays nicer, with less artifacts (seams between cells).
It doesn't need such silly explanation of the nature of the screenshot,
and was also sizing to the width of the text, so I removed the wrapper
table which was imitating (standing in for) figure/figcaption elements.

The new screenshot also includes a window border, macOS-styled, which is
a little weird since it's a remake of MS Paint (Windows software)
developed entirely on Ubuntu (Linux distro).
2023-06-11 22:59:37 -04:00
Isaiah Odhner
a0f626a339 Poke around the UI to find untranslated strings
(This is generally inferior to source code analysis.)

There's also the Help / About Paint dialogs.
2023-06-11 17:42:52 -04:00
Isaiah Odhner
1d089db36b Fix localization support (--language option)
Broken in "Move package files to folder src/textual_paint/" c55620dd35
2023-06-11 17:28:49 -04:00
Isaiah Odhner
1291fd1d47 Add a few todos for the inspector 2023-06-11 16:55:59 -04:00
Isaiah Odhner
e28c7a3c7e Remove paint palette emoji, superseded by logo text art 2023-06-11 02:37:14 -04:00
Isaiah Odhner
07395517ea Update remaining command lines to run the app as a module 2023-06-10 21:20:17 -04:00
Isaiah Odhner
6fae6e501e Expand default target directory (if you Open/Save from a New file) 2023-06-10 21:09:02 -04:00
Isaiah Odhner
4e1f11ab23 Fix expanding directory tree to current folder, in file dialogs
- This regressed due to updates in Textual 0.25.0,
  because DirectoryTree now loads directory contents in a worker:
  https://github.com/Textualize/textual/issues/2456
- Directory tree expansion may be more robust now, although it's using
  more internals now, and it still needs timers for whatever reason.
2023-06-10 21:05:19 -04:00
Isaiah Odhner
9f7f198518 Ignore backup file not existing when comparing file identity 2023-06-10 18:14:56 -04:00
Isaiah Odhner
58cfbfae0a Fix discarding Untitled.ans~ on startup 2023-06-10 18:13:35 -04:00
Isaiah Odhner
1b5d1ce988 Disable most print statements 2023-06-10 02:21:53 -04:00
Isaiah Odhner
3fe9fed6ad Clean up some things 2023-06-09 21:58:46 -04:00
Isaiah Odhner
bb9042a6c0 Fix extraneous space 2023-06-09 21:39:30 -04:00
Isaiah Odhner
9f283458bf Fix color highlight for border properties where it's not the whole value 2023-06-09 21:37:20 -04:00
Isaiah Odhner
3f55179ef7 Fix color highlight for some color syntax 2023-06-09 21:21:25 -04:00
Isaiah Odhner
dfcdd33a7a Highlight color values also within rule sets
This also removes an extraneous newline for an empty inline styles block (by accident)
2023-06-09 21:03:42 -04:00
Isaiah Odhner
675cee043f Clean up 2023-06-09 20:02:52 -04:00
Isaiah Odhner
f677a3337c Highlight color values in inline styles in inspector 2023-06-09 18:17:09 -04:00
Isaiah Odhner
7bae717df1 Mark *args/**kwargs as Any for RuleSet instrumentation 2023-06-09 17:43:04 -04:00
Isaiah Odhner
812d628c42 Add tooltips to tool buttons 2023-06-09 15:13:29 -04:00
Isaiah Odhner
2bc8d33079 Disable DOM inspector when --inspect-layout isn't passed
In the future I could make this more flexible, since you don't always
need the instrumentation in order to benefit from the inspector.
2023-06-09 02:02:36 -04:00
Isaiah Odhner
ca1780ce0d Remove special handling for textual run that's no longer needed
No that it's a run as a module, the arguments are separated:

$ textual run --dev "src.textual_paint.paint --language en --clear-screen --inspect-layout --restart-on-changes samples/ship.ans"
	__name__: src.textual_paint.paint
	sys.argv: ['-c', '--language', 'en', '--clear-screen', '--inspect-layout', '--restart-on-changes', 'samples/ship.ans']

$ python -m "src.textual_paint.paint" --language en --clear-screen --inspect-layout --restart-on
-changes samples/ship.ans
	__name__: __main__
	sys.argv: ['/home/io/Projects/textual-paint/src/textual_paint/paint.py', '--language', 'en', '--clear-screen', '--inspect-layout', '--restart-on-changes', 'samples/ship.ans']

$ python src/textual_paint/paint.py --language en --clear-screen --inspect-layout --restart-on-changes samples/ship.ans
	__name__: __main__
	sys.argv: ['src/textual_paint/paint.py', '--language', 'en', '--clear-screen', '--inspect-layout', '--restart-on-changes', 'samples/ship.ans']

$ src/textual_paint/paint.py --language en --clear-screen --inspect-layout --restart-on-changes 
samples/ship.ans
	__name__: __main__
	sys.argv: ['src/textual_paint/paint.py', '--language', 'en', '--clear-screen', '--inspect-layout', '--restart-on-changes', 'samples/ship.ans']
2023-06-09 01:27:13 -04:00
Isaiah Odhner
178e4c0689 Fix name of program in help text
Originally it was `paint.py`, but after switching to running as a module
(needed to use Python's relative imports for some reason) it became "-c"
when running with the `textual` CLI.
2023-06-09 01:27:13 -04:00
Isaiah Odhner
c15e8ce427 Handle "ValueError: No closing quotation" on paste with MMB
I'm not sure what I had in the clipboard that triggered this,
but it reproduces easily enough with `"unbalanced`
2023-06-09 01:27:13 -04:00
Isaiah Odhner
beefe9f560 Tweak Paint icon (the cup, and shading of the cup and folded corner) 2023-06-08 23:54:56 -04:00
Isaiah Odhner
c83efb4ddf Tweak Paint icon, using heavy slashes
- Use very heavy solidus for paint brushes. This renders in a strange
  overlapped way in Ubuntu Terminal and VS Code's terminal, which
  actually works really well here. I just hope it doesn't become
  a wide character in the future, or isn't treated as such on other
  terminals.
- Add brush tips to the other brushes, each using a different character.
- Remove top border, since it conflicts with brush tips.
2023-06-08 23:54:56 -04:00
Isaiah Odhner
7e30f39374 Add Paint icon ANSI art to Help > About Paint 2023-06-08 23:54:56 -04:00
Isaiah Odhner
349f87c3e7 Disable automatic updating of CLI info on the readme
This caused an error when running from the console entry point,
as it's not intended to work in production/release.
2023-06-08 23:54:56 -04:00
Isaiah Odhner
512fe69e9e Get console entry point working 2023-06-08 23:53:33 -04:00
Isaiah Odhner
3364e11b5d Convert to relative imports
It no longer runs except with `python -m src.textual_paint.paint`
2023-06-07 22:38:09 -04:00
Isaiah Odhner
c4c1572dac Add meta data to inspector module 2023-06-07 16:12:26 -04:00
Isaiah Odhner
c17e1a905d Ignore more stack frames for framework style setter shortcuts
This lets it jump directly to `my_widget.display = False`, rather than
the `display` setter method in dom.py, for example.
2023-06-07 16:01:26 -04:00
Isaiah Odhner
3dfc1985b1 This is done (basically) 2023-06-07 15:38:26 -04:00
Isaiah Odhner
e414e46400 Fix inline styles left by inspector after resetting highlight
`widget.styles.tint` will return a default transparent (#00000000)
value, rather than None, when not set.

`border` doesn't work the same as the others here, but I'm not using it,
so I can just disable the styles I'm not using.
2023-06-07 15:31:22 -04:00
Isaiah Odhner
789f1776cb Fix linking to code that set inline styles for hyphenated/shorthand properties 2023-06-07 15:01:06 -04:00
Isaiah Odhner
2a8395581a Improve source code link formatting 2023-06-07 03:26:35 -04:00
Isaiah Odhner
ddcff5c955 DRY source code location info formatting 2023-06-07 03:05:30 -04:00
Isaiah Odhner
d10d5d33ba Fix opening file without a known line number 2023-06-07 02:55:44 -04:00
Isaiah Odhner
9f84b6206c Link to source code for CSS rule sets 2023-06-07 02:55:44 -04:00
Isaiah Odhner
3409992ae6 Link to source code that set inline styles
Impossible? No! Just add a little instrumentation magic... 🪄
2023-06-07 01:27:40 -04:00
Isaiah Odhner
10491e3d16 Show actual CSS rule sets in the inspector, not just a style dump 2023-06-06 22:28:43 -04:00
Isaiah Odhner
79ff919e14 Fix aborting picking when closing inspector with F12 2023-06-06 18:46:49 -04:00
Isaiah Odhner
b1e1a5ea4d Make resize handles subtle (invisible until hover)
I surveyed `def render_line` in the Textual codebase to find the right
property to get the `color` CSS property working for ResizeHandle:

- `self.styles`: wrong type
- `self.get_component_rich_style()`: would overcomplicate things
- `self.text_style`: wrong
- `self.rich_style`: right

Now I can use `:hover` styles, and restore some of the elegance of the
look of the inspector by hiding the resize handles until mouse over.
2023-06-06 18:33:27 -04:00
Isaiah Odhner
5e6bdbf323 Add internal resize handle to inspector 2023-06-06 18:16:44 -04:00
Isaiah Odhner
1620f3b5d3 Fix tab underline in inspector
It was an overly general CSS rule, confusingly applying to Tab,
because it's a *subclass* of Static.

Inspector features that would make this easier to understand would be:
- Showing what rules apply to a given widget, instead of just a CSS dump
- Showing better why exactly it was invisible
2023-06-06 17:40:08 -04:00
Isaiah Odhner
5ddb5c22a8 Found another good candidate for crosshair symbol 2023-06-05 15:58:23 -04:00
Isaiah Odhner
ce1b26543d Add resize handle to inspector panel 2023-06-04 20:04:51 -04:00
Isaiah Odhner
3071a34b0e Focus DOM tree after picking an element 2023-06-04 18:20:52 -04:00
Isaiah Odhner
636b3f6869 Add emoji for visual clarity (like bullet points)
and replacing "Listener on DOM node:" which was verbose for something repeated potentially many times.
2023-06-04 16:58:57 -04:00
Isaiah Odhner
a735443acc Color file paths for visual clarity
This helps a LOT, but putting it in a tooltip might still be better.
2023-06-04 16:20:14 -04:00
Isaiah Odhner
f727a3c08d Refactor: prefer Text.styled() in most cases 2023-06-04 16:17:52 -04:00
Isaiah Odhner
c525ff3e26 Link to source code for the message class 2023-06-04 15:50:38 -04:00
Isaiah Odhner
89dadbf4b1 Refactor to use Text.styled instead of Text.from_markup and escape
This is much more readable, and presumably more performant.
2023-06-04 15:47:20 -04:00
Isaiah Odhner
cfe4104b6f Only look upwards for handlers if the event bubbles 2023-06-04 15:34:05 -04:00
Isaiah Odhner
38dcdde2b9 Fix event handler method names checked for
Updating to Textual 0.27.0 broke this code, but it looks like they
made it way easier! It's now available statically on the class.
2023-06-04 15:28:14 -04:00
Isaiah Odhner
55c2ab1e4d Fix message: list both method names checked 2023-06-04 15:28:14 -04:00
Isaiah Odhner
605a048fc7 Launch code editor from inspector panel
Disable stdout which crashes when run in Textual due to StdoutRedirector
2023-06-04 15:28:13 -04:00
Isaiah Odhner
99b4dfc10f Rename env var for explicit editor config
This is a little bit weird, since it sounds like it's the opposite of "VISUAL", but it's the name of the TUI framework.
2023-06-04 13:46:18 -04:00
Isaiah Odhner
d3c060a2f3 Accept spellings 2023-06-04 13:36:05 -04:00
Isaiah Odhner
bae5eceb51 Narrow exception catching 2023-06-04 13:36:05 -04:00
Isaiah Odhner
ef107b0da3 Add types, and workaround list[str | None] return type 2023-06-04 13:36:05 -04:00
Isaiah Odhner
bbb7550763 Fix the ported editor launching code 2023-06-04 13:22:50 -04:00
Isaiah Odhner
e9494ddf4b Port launchEditor.js (from CRA) to Python with ChatGPT 2023-06-04 02:54:53 -04:00
Isaiah Odhner
f5074d836f Link to nodes in DOMTree from NodeInfo panel 2023-06-04 02:28:42 -04:00
Isaiah Odhner
0c05e17223 Move expansion of nested nodes to method of DOMTree 2023-06-04 02:28:42 -04:00
Isaiah Odhner
e7d0d7280a Clean up 2023-06-04 01:06:44 -04:00
Isaiah Odhner
1c1fb8994e Hide inspector highlight when closing the inspector 2023-06-03 23:38:23 -04:00
Isaiah Odhner
fc279f0574 Fix type checker errors and ignore one 2023-06-03 20:08:27 -04:00
Isaiah Odhner
62fb218a1a Remove obsolete visibility reset
I made sure to leave a comment here because I thought I might leave this in by accident.
I changed how it works in 79ae7e1b7b.
2023-06-03 19:50:57 -04:00
Isaiah Odhner
336414d786 Prevent highlights from overlapping the inspector panel 2023-06-03 19:30:27 -04:00
Isaiah Odhner
545642f5d5 Prevent lingering highlight after picking with Inspect Element 2023-06-03 18:57:55 -04:00
Isaiah Odhner
8e930030c2 Make DOM tree hovering behavior more robust
Regarding "it seems to be reset anyways": I believe it was simply
highlighting an incorrect node, often, by chance, an invisible one.
`self._get_node(-1)` doesn't return None.
2023-06-03 18:00:22 -04:00
Isaiah Odhner
8acc079faa Clean up empty lists of highlight boxes 2023-06-03 16:14:06 -04:00
Isaiah Odhner
c2ddf4b88e Fix removing old highlight boxes
It was clearning (replacing) the dictionary, and thus losing track
of old highlights that should be removed.
2023-06-03 16:14:06 -04:00
Isaiah Odhner
79ae7e1b7b Fix ignoring of inspector highlight boxes when picking 2023-06-03 15:49:53 -04:00
Isaiah Odhner
89ff582c3d Remove highlight boxes associated with an old DOM node 2023-06-03 15:32:10 -04:00
Isaiah Odhner
377a883d3b Handle NoWidget
Why did this get dom_node = Container(classes={'inspector_highlight'}, pseudo_classes={'enabled'})?
2023-06-03 15:24:57 -04:00
Isaiah Odhner
892d12e8fb Add a worse option for the Polygon tool icon (a hieroglyph) 2023-06-03 15:24:56 -04:00
Isaiah Odhner
beaccf1be8 Optimize highlighting clipped region by reusing widgets 2023-06-03 15:24:56 -04:00
Isaiah Odhner
6e3bb4167e Highlight clipped region when hovering a DOM node 2023-06-03 15:04:12 -04:00
Isaiah Odhner
55c495ffa5 Cancel highlight when mouse leaves DOM tree view 2023-06-03 15:04:12 -04:00
Isaiah Odhner
bab98d051c Remove unused import 2023-05-29 23:52:08 -04:00
Isaiah Odhner
247f78d657 Ignore two type checker errors 2023-05-29 23:50:19 -04:00