Commit Graph

1486 Commits

Author SHA1 Message Date
Isaiah Odhner
a51ffa4a8e Simplify Color Eraser logic (color comparison) 2023-09-21 21:59:14 -04:00
Isaiah Odhner
3130acb6b0 DRY textbox color updating 2023-09-21 21:34:17 -04:00
Isaiah Odhner
4b5ee59758 Add to comment 2023-09-21 21:27:35 -04:00
Isaiah Odhner
7933ae67a8 Convert document model to use 2D array of Style objects directly
This brings it back to a single source of truth for the color values.
2023-09-21 21:27:35 -04:00
Isaiah Odhner
7ce6459a27 Fix fill tool 2023-09-21 20:36:09 -04:00
Isaiah Odhner
2b1b40fc12 Fix unbound var 2023-09-21 20:36:09 -04:00
Isaiah Odhner
3cc4d9ff5d Cache Style objects for each cell in the document
This is not worth the complexity. It would be better to just change the document model to replace fg and bg with a 2D array of Style objects, so there's still a single source of truth.

This touches a LOT of code, and cache invalidation is classically known as a hard problem in programming.
2023-09-21 20:36:09 -04:00
Isaiah Odhner
d4e08e136c Simplify initializing textbox colors 2023-09-21 20:36:09 -04:00
Isaiah Odhner
64e63f5cf3 Optimize meta glyph rendering? 2023-09-21 20:36:09 -04:00
Isaiah Odhner
22635bc007 Optimize show_grid state access in Canvas 2023-09-21 20:36:09 -04:00
Isaiah Odhner
7aa256e8df Optimize magnification state access in Canvas
The reactive attribute `magnification` was a performance bottleneck.
Avoid calling the getter (`reactive.__get__`) multiple times,
by storing the value, and passing it to `big_ch` as an argument.

It's still very slow when zoomed in.
2023-09-21 20:36:09 -04:00
Isaiah Odhner
fae2c216f0 Optimize Color and Style construction in Canvas
This does not change anything visually, but the snapshots are changed
because the IDs use a hash which includes color names, and the color
names changed from rgb() style to hex.
2023-09-21 20:36:09 -04:00
Isaiah Odhner
ccbd6cf5ce Remove outdated comment 2023-09-21 20:36:09 -04:00
Isaiah Odhner
4ae90dcb11 Fix missing new scope parameter to parse 2023-09-21 20:34:03 -04:00
Isaiah Odhner
71060ecd70 Use new :light/:dark pseudo classes 2023-09-21 16:17:05 -04:00
Isaiah Odhner
dd982f18b2 Update textual to 0.38.1 2023-09-21 16:14:02 -04:00
Isaiah Odhner
f2f4da73dc Sync setup.cfg with requirements.txt
Write everything twice!

I was thinking the last release was published with textual 0.28.0,
but since I didn't update setup.cfg, it would have been with 0.27.0.
2023-09-21 16:10:58 -04:00
Isaiah Odhner
4cb9b96ce3 Update rich to 13.4.2
The next version, 13.5.0, affects the centering of tool icons.
2023-09-19 00:01:17 -04:00
Isaiah Odhner
cd3137a737 Use new Collapsible widget for error details 2023-09-18 23:43:59 -04:00
Isaiah Odhner
2162ddd125 Update textual to 0.37.1 2023-09-18 22:44:55 -04:00
Isaiah Odhner
268380a0c6 Update textual to 0.36.0
All tests pass... but pyright shows the signature for app.exit changed.
2023-09-18 22:37:01 -04:00
Isaiah Odhner
e435e0a53f Update textual to 0.35.0
All tests are passing, moving on...
2023-09-18 11:50:54 -04:00
Isaiah Odhner
40220e22d2 Fix flaky CharacterSelectorDialogWindow test (hopefully)
This should fix this failure:

    FAILED tests/test_snapshots.py::test_paint_character_picker_dialog[dark_unicode] - textual.css.query.NoMatches: No nodes match <DOMQuery query='CharacterSelectorDialogWindow'>

I noticed this first in a Windows VM, and am now seeing it in Ubuntu,
so it might have to do with the test running slowly.
This was back on textual 0.28.0 by the way; it doesn't have to do with
the recent updates (as far as I know; at least, not entirely.)

I've never had it reproduce when running in isolation with
    pytest tests/test_snapshots.py::test_paint_character_picker_dialog

I tried adding a delay right before the query, and that DIDN'T work,
I got the failure at least once with that in place, so I think it was
failing to detect a double click, rather than querying while the window
was in the process of opening, and so I decided to try increasing the
double click threshold. The click() method of pilot has a cumulative
artificial delay of 0.3s, so two clicks is at least 0.6s and it's not
hard to imagine the event processing pushing that over 0.8s.
I actually created the `DOUBLE_CLICK_TIME` to allow overriding it in
tests, and I'm not sure if this actually works to override it.
2023-09-18 02:00:58 -04:00
Isaiah Odhner
0225ea8780 Update textual to 0.34.0
Tests all pass.
2023-09-18 01:18:49 -04:00
Isaiah Odhner
35a6845ab5 Update textual to 0.33.0
I had to fix the layout of a few dialogs where elements decided they
wanted to start expanding a lot more than before.
I'm guessing this has to do with the changelog entry:
    "Fixed relative units not always expanding auto containers"
    https://github.com/Textualize/textual/pull/3059

The snapshot changes are basically bogus. The before and after are
visually identical, with the difference view showing all black.

Since there were a lot of switches to toggle and I had to wait for the
snapshot tests to run (slow!), I wrote a little automation to toggle
"Show difference" for all the results:

    document.querySelectorAll("#flexSwitchCheckDefault").forEach((element)=> element.click())

It would be good to have this ability in the snapshot report UI itself,
maybe even replacing the individual toggles, although I'm not sure about
that, especially since it might be laggy toggling the blend modes with
a lot of test results. (I suppose if that was really an issue, it could
toggle all the visible test results and then toggle others as they come
into view, though that's a bit more complex.)

As for understanding the structural changes to the snapshots, I tried
making a visualization using hue, coloring according to the position
of a rect within the list of rects:

    const richTerminals = document.querySelectorAll(".rich-terminal");
    
    richTerminals.forEach(function(terminal) {
        const rectElements = terminal.querySelectorAll("rect");
        
        rectElements.forEach(function(rect, index) {
            const fraction = index / (rectElements.length - 1);
            const cycles = 40;
            const hue = fraction * cycles * 360;
            rect.style.fill = `hsl(${hue}, 100%, 50%)`;
        });
    });

This shows some difference, but it isn't very elucidating, since the
structural changes only show as gradual shifts in the hue, and affect
other rects even if said rects are identical, so it's subtle and messy.

Coloring based on a hash proves to actually highlight differences:

    const richTerminals = document.querySelectorAll(".rich-terminal");
    
    richTerminals.forEach(function(terminal) {
        const rectElements = terminal.querySelectorAll("rect");
        
        rectElements.forEach(function(rect, index) {
            const hash = hash(rect.outerHTML);
            const hue = (hash % 360 + 360) % 360;
            rect.style.fill = `hsl(${hue}, 100%, 50%)`;
        });
    });
    
    function hash(s) {
        let hash = 0;
        for (let i = 0; i < s.length; i++) {
            const char = s.charCodeAt(i);
            hash = (hash << 5) - hash + char;
        }
        return hash;
    }

As for analyzing the differences now visible, eh, "maybe later."
2023-09-18 01:08:22 -04:00
Isaiah Odhner
dd9da9cfb1 Update textual to 0.32.0
No changes seem to be needed here.
I'm updating textual-dev too just because it's compatible now.
2023-09-17 00:57:00 -04:00
Isaiah Odhner
3944a6e404 Update textual to 0.31.0
DataTable now has `max-height: 100%` by default, which breaks my layout.
2023-09-17 00:56:49 -04:00
Isaiah Odhner
938a320391 Update textual to 0.30.0
This seems fine.
2023-09-17 00:56:41 -04:00
Isaiah Odhner
28d9a2ff04 Update textual to 0.29.0
This only slightly affects the exact lightness of the grayed out radio button labels, at least as far as the tests cover.
2023-09-17 00:56:21 -04:00
Isaiah Odhner
a0247a0870 Prepare 0.3.0 2023-09-16 23:32:02 -04:00
Isaiah Odhner
99a5441a10 Ignore private access specifically; don't mask future removals/renames
Found these with regexp: /\._.+ type: ignore/
I also looked for: /import (\w+,\s*)*_/
And: /^from (\w+\.)*_/
2023-09-16 23:31:08 -04:00
Isaiah Odhner
06344fb8de Silence type checker warnings (reportOptionalMemberAccess) 2023-09-16 23:31:08 -04:00
Isaiah Odhner
7f9243167c Remove obsolete "type: ignore" comments 2023-09-16 23:31:08 -04:00
Isaiah Odhner
0791b1c080 Satisfy the type checker
`PYRIGHT_PYTHON_FORCE_VERSION=1.1.327 pyright` now gives 0 errors

(before this commit it was 16 errors)
2023-09-16 23:31:08 -04:00
Isaiah Odhner
a6b5cb31be Clean up mocked method FigletFont.preloadFont 2023-09-16 23:31:08 -04:00
Isaiah Odhner
62ee8c2fcf Add publishing section to readme 2023-09-16 23:31:08 -04:00
Isaiah Odhner
3e9f1dd94b Tidy imports 2023-09-15 23:44:22 -04:00
Isaiah Odhner
22ce654579 Move method next to other ColorsBox event handler 2023-09-15 23:36:08 -04:00
Isaiah Odhner
82e0fbada7 Re-optimize ColorsBox palette updating 2023-09-15 23:31:29 -04:00
Isaiah Odhner
0647e7be8b Decouple ColorsBox from PaintApp
There's no practical utility in this unless I want to make the palette size variable,
and this makes performance worse updating the screen when the palette changes,
but I'm on a mission to remove `from textual_paint.paint import PaintApp`
since it can't be at top level due to cyclic imports, and it has
side effects when importing `textual_paint.args` in turn.
2023-09-15 23:25:21 -04:00
Isaiah Odhner
a2cf93ae99 Update palette reactively 2023-09-15 23:00:29 -04:00
Isaiah Odhner
f1d288d79c Make palette immutable 2023-09-15 22:53:40 -04:00
Isaiah Odhner
b34c03e788 Tweak changelog entry wording 2023-09-15 22:29:19 -04:00
Isaiah Odhner
80d9f38318 Move ThemedIcon to a separate file 2023-09-15 22:07:04 -04:00
Isaiah Odhner
0f617dd8c4 Dynamically theme message box icons 2023-09-15 22:03:34 -04:00
Isaiah Odhner
7a13659d48 Fix "Show Details" not changing to "Hide Details" when expanding error 2023-09-15 20:44:40 -04:00
Isaiah Odhner
0c44759b28 Refactor to avoid using negative coords to mean "no mouse position"
My TODO comment said "add an attribute to ToolPreviewUpdate or make it's x/y Optional", which is both bad grammar ("it's" vs "its") and a bad idea, since the Canvas isn't involved in this update, so its event definition shouldn't have to be complicated by it.

I like this much better, just splitting the event handler into two functions, giving room to express the optional nature of the coordinate in the signature, and avoiding constructing two message objects at both of the callsites.
2023-09-15 20:21:19 -04:00
Isaiah Odhner
fc1baa9815 Move imports so that Organize Imports doesn't break it
Before, if I ran Organize Imports in VS Code, it reordered things such that `sys.path.insert` was after the import that needed it.
Now it's stable.
2023-09-15 19:56:27 -04:00
Isaiah Odhner
b6e2c245a2 Get file dialog snapshot tests passing on Windows
Now it's just a few round trip tests failing, and maybe a flaky snapshot test for the character selector dialog.
2023-09-15 17:13:15 -04:00
Isaiah Odhner
8cd164bb37 Fix preventing icon swaps during pytest, for Windows Terminal and Kitty
If git blame tools were smarter/easier to use, or if I was using a node-based programming paradigm, I would've never made this mistake. I would have done the natural and correct thing in the first place, but instead, I tried to avoid indenting a large block of code, which generates a noisy commit, and a barrier when using git blame.
2023-09-15 17:08:13 -04:00