Commit Graph

1450 Commits

Author SHA1 Message Date
Isaiah Odhner
11939b6603 Resize screenshots for some tests 2023-09-07 17:46:48 -04:00
Isaiah Odhner
7d88cbe44f Rename test to match 2023-09-07 17:23:35 -04:00
Isaiah Odhner
f8f2d5ea01 Add snapshot tests for more keyboard-accessible dialogs 2023-09-07 17:22:34 -04:00
Isaiah Odhner
ca23a7712c Remove clock from gallery app
I don't feel like trying to figure out how to spoof the time for snapshot testing.
2023-09-07 16:53:31 -04:00
Isaiah Odhner
690b969fa4 Run "Organize Imports" on all files
I used a very dangerous extension that has a lot of include/exclude
options that are unclear how they interact, and it doesn't apparently
respect your gitignore settings, and it has no no preview or warning.

  "commandOnAllFiles.excludeFolders": ["node_modules", "out", ".vscode-test", "media", ".git", ".history", ".venv", ".venv*", ".*"],
  "commandOnAllFiles.commands": {
    "Organize Imports": {
      "command": "editor.action.organizeImports",
      "includeFileExtensions": [".py"],
      "includeFolders": ["src"]
    }
  },
2023-09-07 16:41:59 -04:00
Isaiah Odhner
580da11949 Check if running in pytest instead of ignoring a specific argument 2023-09-07 16:41:59 -04:00
Isaiah Odhner
569ff8b58d Add info about pytest-textual-snapshot to readme 2023-09-07 16:41:59 -04:00
Isaiah Odhner
bcfddbe2fa Add first baseline for visual regression testing
It works!
2023-09-07 16:41:59 -04:00
Isaiah Odhner
95256a411a Kludge: ignore --snapshot-update argument 2023-09-07 15:38:23 -04:00
Isaiah Odhner
f1da33ca8e Convert relative imports to absolute
They honestly seem like a half-baked language feature.

- Relative imports don't allow running a script via shebang line.
- Relative imports don't work without a package, which means they
  don't work in situations other than when absolute imports also work,
  as far as I understand it.
- Relative imports don't work with pytest-textual-snapshot currently,
  so I'm changing it to absolute imports in order to set up testing.
2023-09-07 15:19:10 -04:00
Isaiah Odhner
ed97f0afb0 WIP: set up snapshot testing 2023-09-07 15:19:10 -04:00
Isaiah Odhner
f81e5d8250 Bump textual to 0.28.0, needed for pytest-textual-snapshot 2023-09-07 15:13:47 -04:00
Isaiah Odhner
4d61aa3a17 Make horizontal scrollbar go above caption
Before, the horizontal scrollbar went below the caption, offsetting it,
although the caption didn't scroll with the content, to be clear.
At any rate, it looks much better for the caption to stay in one place,
and be grouped outside the scrollable container which doesn't scroll it.
2023-09-06 23:10:57 -04:00
Isaiah Odhner
938fc2a8ef Clean up 2023-09-06 22:40:28 -04:00
Isaiah Odhner
4456455c4d Fix usage of incorrect index
The dict is sparse, so its indices are not always the gallery's indices.
This fixes the behavior when passing a file as an argument.

(I already fixed this code and must've undone it somehow! I was losing my mind over here!)
2023-09-06 22:38:08 -04:00
Isaiah Odhner
39f6eca27a Prevent automatic incorrect color highlighting 2023-09-06 22:08:51 -04:00
Isaiah Odhner
cd48ba9015 Rename dict
`path_to_gallery_item` is ambiguous.
2023-09-06 22:08:51 -04:00
Isaiah Odhner
2a2292537a WIP: allow passing a file to show in the gallery 2023-09-06 22:05:27 -04:00
Isaiah Odhner
f9911987af Show position in the gallery in the header 2023-09-06 22:05:27 -04:00
Isaiah Odhner
b73b681610 Add --no-animation flag to gallery app
Also add --version flag. Might as well, I guess.
2023-09-06 21:05:06 -04:00
Isaiah Odhner
9a0a2c4f29 Virtualize scrolling in gallery
- Make it more efficient by loading files progressively.
- Remove the HorizontalScroll, and instead position items absolutely, animating offsets to imitate the movement of scrolling horizontally.
  - This fixes the left/right bindings not showing in the footer, due to ScrollableContainer's hidden left/right bindings.
  - This also removes the possibility of scrolling half-way away from an item.
  - This also fixes a problem where you could lose track of the currently viewed item when resizing the terminal, due to the 100% width of gallery items not jiving with the absolute notion of scroll position. (If the scroll position were stored as a fraction, it wouldn't have been a problem.)
- Simplify the keyboard navigation logic by storing an index into the gallery, instead of having to figure out what item is centered.
2023-09-06 20:50:44 -04:00
Isaiah Odhner
1df201ae62 Check earlier for if no paths were matched
This could make debugging less confusing if the nearby debugging code were enabled and there were no paths found, but also I'm planning on changing how gallery items are loaded, making it load progressively, and decoupling this logic from the UI helps prepare for that.
2023-09-06 18:17:18 -04:00
Isaiah Odhner
70afa25c4b Hide junk from gallery by default 2023-09-06 17:45:51 -04:00
Isaiah Odhner
2bbee95142 Sort so folders are grouped together 2023-09-06 17:23:46 -04:00
Isaiah Odhner
25a4b0826b Filter by file extension earlier 2023-09-06 17:20:08 -04:00
Isaiah Odhner
947534df3e Replace complex bash one-liner with the new gallery app 2023-09-06 15:09:18 -04:00
Isaiah Odhner
349f94f69e Add more docstrings
I think that's all the module docstrings.
2023-09-06 14:57:04 -04:00
Isaiah Odhner
769ccee30e Auto-organize imports
I don't really like the style of wrapping to different points depending
on where the opening parenthesis is, especially when it wraps for just
one item, and these changes may remove some semantic grouping or
ordering (i.e. by importance), but I don't think I put THAT much thought
into it, and I think I can accept some lack of control, to freely use
the Organize Imports command in VS Code, which does nicely automate
grouping imports of different types.
2023-09-06 14:15:42 -04:00
Isaiah Odhner
179cceed57 Avoid global statement for ID counter 2023-09-06 13:57:12 -04:00
Isaiah Odhner
ea0d90952a Add some docstrings 2023-09-06 13:48:13 -04:00
Isaiah Odhner
f1d6b266aa Fix multiple error cases reached
With `textual run --dev "src.textual_paint.gallery foobar"` it output:

    Folder not found: foobar
    Not a folder: foobar
    No ANSI art (*.ans, *.txt) found in folder: foobar

    NOTE: 3 errors shown above.

Now it correctly outputs only:

    Folder not found: foobar
2023-09-06 13:34:35 -04:00
Isaiah Odhner
5441c0d3b0 Extract AnsiArtDocument and friends to files
This fixes the gallery app's --help, because before it was importing the "paint" module, which imported "args", which parsed arguments for the paint app instead of the gallery app.

This is also a refactor I've been meaning to do — since the very beginning, really — and it would've been a lot less trouble if I could've done it from the beginning, but I couldn't get imports to work. Yeah, really. Sounds pretty stupid 'cause it is. Python's module system is terrible.
2023-09-06 13:27:47 -04:00
Isaiah Odhner
9c2b48ec21 Fix --restart-on-changes
This fixes "NameError: name 'PaintApp' is not defined"

PaintApp is only defined during type checking (i.e. if TYPE_CHECKING).
It would be nice if the type checker warned about usage of such vars outside of type annotations.
2023-09-06 13:27:47 -04:00
Isaiah Odhner
d8bc66d610 Clean up gallery styles 2023-09-06 13:27:47 -04:00
Isaiah Odhner
220509f33f Sort files in gallery, taking into account X.Y numbers 2023-09-06 13:27:47 -04:00
Isaiah Odhner
bf8b60f5e0 Show directory better in case of error 2023-09-06 13:27:47 -04:00
Isaiah Odhner
ce3def0ec5 Include .txt files 2023-09-06 13:27:47 -04:00
Isaiah Odhner
ace77e04a9 Recursively find the .ans files 2023-09-06 13:27:47 -04:00
Isaiah Odhner
23f7aa0703 Allow scrolling when ANSI art is larger than the viewport 2023-09-06 13:27:47 -04:00
Isaiah Odhner
5dca142d6e This doesn't show up, though, if left/right are first
I believe the scrollable container's left/right bindings are winning
in terms of display in the Footer, even though mine have priority
in terms of functionality.
2023-09-06 13:26:53 -04:00
Isaiah Odhner
8cde322a3d Get keyboard navigation working in gallery 2023-09-06 13:26:53 -04:00
Isaiah Odhner
eeef27e99b Disable ugly debug styles 2023-09-06 11:50:38 -04:00
Isaiah Odhner
3e2ded8abd Hide dev feature key bindings from footer, clean up 2023-09-06 11:50:38 -04:00
Isaiah Odhner
652e18f76c Center image vertically 2023-09-06 11:48:23 -04:00
Isaiah Odhner
0c725d5217 Fix Quit binding in gallery 2023-09-06 11:48:23 -04:00
Isaiah Odhner
988a82addb Get the image centered
This is somewhat mysterious, but it's working finally!
2023-09-06 11:48:23 -04:00
Isaiah Odhner
d90f83de21 Ignore lack of discard_backup on GalleryApp 2023-09-06 11:46:32 -04:00
Isaiah Odhner
59feafc309 WIP: bindings for gallery app
Why are the bindings not working? Ctrl+Q doesn't work, left/right don't even show up!
2023-09-06 11:45:44 -04:00
Isaiah Odhner
32a10ab1d1 Try to center image (not working) 2023-09-06 11:45:01 -04:00
Isaiah Odhner
9140d14405 Set up development features for gallery app 2023-09-06 11:44:16 -04:00