Commit Graph

340 Commits

Author SHA1 Message Date
Isaiah Odhner
058d54643b Wire up luminosity ramp, color field, and color preview state 2023-05-24 22:18:44 -04:00
Isaiah Odhner
ddf40c5b81 Fix size for inputs in Edit Colors 2023-05-24 22:18:44 -04:00
Isaiah Odhner
fc1536fd8e Start wiring up numeric color value inputs to state 2023-05-24 22:18:44 -04:00
Isaiah Odhner
cf979114a9 Refactor: remove class LabeledInput so it's easy to get at the Inputs
Now that I'm creating the inputs dynamically, it doesn't help to have a class for labeled inputs.
And `self._inputs_by_letter[component_letter] = labeled_inputs[-1].query_one(Input)` failed, because it's not mounted yet.
2023-05-24 00:56:45 -04:00
Isaiah Odhner
0fdbce1f77 Refactor: create numeric inputs dynamically 2023-05-24 00:54:23 -04:00
Isaiah Odhner
eee0d17916 Add color preview 2023-05-24 00:54:23 -04:00
Isaiah Odhner
d2ac30615a Fix scaling of HSL ramps so that the cursor is visible at the maximums 2023-05-24 00:05:07 -04:00
Isaiah Odhner
8680c364dd Clamp values 2023-05-23 23:52:45 -04:00
Isaiah Odhner
edaf7fb17a Make ColorField and LuminosityRamp interactive 2023-05-23 23:52:45 -04:00
Isaiah Odhner
a515999937 Scaffold visual color inputs (Hue/Sat field and Lum slider) 2023-05-23 03:00:08 -04:00
Isaiah Odhner
272bcb3217 Scaffold numeric color value inputs 2023-05-23 03:00:08 -04:00
Isaiah Odhner
4c73395c0c Tweak border 2023-05-23 00:06:02 -04:00
Isaiah Odhner
4d676409c0 Separate focused and selected states in Edit Colors 2023-05-22 23:51:34 -04:00
Isaiah Odhner
9ada90e92d Fix behavior when navigating with arrows on duplicate color 2023-05-22 23:37:10 -04:00
Isaiah Odhner
2aea62bff5 Fix NoMatches crash if you tab to the color grid and then use arrows 2023-05-22 01:49:56 -04:00
Isaiah Odhner
d88885419c Make color grid focusable, keyboard navigable; require clicking OK button 2023-05-22 01:43:23 -04:00
Isaiah Odhner
85ec3627cd Fix Path vs str type error
It didn't actually cause an error at runtime because
format_from_extension just uses os.path.splitext, which uses os.fspath
which converts Path objects to path strings.
2023-05-22 00:22:36 -04:00
Isaiah Odhner
0edd171233 Clean up imports
I had kept these around because several of these I'll want to use,
and the auto-import feature wasn't working, but I've since found a fix
for that (in 453111269e).
I'm also adding rich here to fix auto-imports from rich.
2023-05-22 00:22:36 -04:00
Isaiah Odhner
ab45f40e15 Use Iterator instead of Generator for consistency and conciseness 2023-05-21 20:18:06 -04:00
Isaiah Odhner
3f9d1a5c37 Prefer "| None" to Optional 2023-05-21 20:04:22 -04:00
Isaiah Odhner
0bf1841d0d Use tuple instead of Tuple from typing module 2023-05-21 20:04:22 -04:00
Isaiah Odhner
8a97c1394f Use dict instead of Dict from typing module 2023-05-21 19:50:09 -04:00
Isaiah Odhner
7b15a580ab Use list instead of List from typing module 2023-05-21 19:49:22 -04:00
Isaiah Odhner
9dab42f9c9 Add max_width param, syncing with ansi-art-thumbnailer 2023-05-21 19:43:40 -04:00
Isaiah Odhner
c3d6c24596 Optimize SVG opening: ignore most rects when measuring grid
This brings it down from around 20 seconds to less than a second,
for moderately sized documents (i.e. default size).
For larger documents, it can still be slow.
2023-05-20 02:05:02 -04:00
Isaiah Odhner
dae8e809c4 Update from_svg docstring 2023-05-20 00:49:01 -04:00
Isaiah Odhner
cd2498c151 Refactor: use size_attrib 2023-05-20 00:29:21 -04:00
Isaiah Odhner
445d29268f Fix type checker error 2023-05-20 00:23:37 -04:00
Isaiah Odhner
322391544b Parse <style> tags when loading SVG 2023-05-19 15:48:42 -04:00
Isaiah Odhner
f2ac4dc98b Perf: Make rects_to_ignore into a set
Checking membership in a set is O(1), as compared to O(n) for a list.
2023-05-19 01:27:22 -04:00
Isaiah Odhner
56badad238 Optimize rectangle containment checking loop a bit (theoretically)
It's still O(n^2) complexity, but more specifically, it's
(n^2 - n) / 2 iterations instead of n^2.
I don't know much about the performance of `enumerate()` or slicing.
2023-05-19 01:19:32 -04:00
Isaiah Odhner
81720d51e6 Safety 2023-05-19 00:53:19 -04:00
Isaiah Odhner
14725279c9 Got it working
It handles the pathological character grid test case SVG I devised,
as well as loading the SVG as saved by the app.

It's a little weird that I managed to get the pathological case working
before the simple rigid grid, but it was what I was shooting for,
and the main problem with the rigid grid was the spanned rects,
which I didn't think of when making the test case SVG.

It does have one problem left; characters that are wider than a cell,
when saved as SVG, take up two cells, but in my SVG loading code,
they're just placed in one cell, so, when saving and loading,
it shifts content to the right of the wide character rightwards,
expanding the region of the background from the wide character's cell.
But it converges now.
2023-05-19 00:53:19 -04:00
Isaiah Odhner
ee224d1a82 Tweak 2023-05-18 22:46:21 -04:00
Isaiah Odhner
3487bed274 Tweak 2023-05-18 22:38:38 -04:00
Isaiah Odhner
c0d87437df Visualize gaps 2023-05-18 22:34:08 -04:00
Isaiah Odhner
4d82706890 Tweak 2023-05-18 22:23:20 -04:00
Isaiah Odhner
f842a7b2cb WIP 2023-05-18 22:14:32 -04:00
Isaiah Odhner
93312627d7 WIP 2023-05-18 22:10:37 -04:00
Isaiah Odhner
d8b95c9f65 Correct shortcut to toggle color palette 2023-05-18 22:10:20 -04:00
Isaiah Odhner
788d8389a2 Visualize tracks 2023-05-18 21:52:22 -04:00
Isaiah Odhner
599ec68b2b Fix that 2023-05-18 21:38:04 -04:00
Isaiah Odhner
fdb54dc01e WIP 2023-05-18 21:30:39 -04:00
Isaiah Odhner
f1ea73d811 WIP 2023-05-18 20:58:27 -04:00
Isaiah Odhner
4e1a1fd1ea Fill in multiple cells for spanned rects 2023-05-18 19:56:15 -04:00
Isaiah Odhner
768e55f795 Change name of file created through automation 2023-05-18 19:47:44 -04:00
Isaiah Odhner
ee03ee08b6 Rename terminal wallpaper script to snake case 2023-05-18 14:37:05 -04:00
Isaiah Odhner
da861e4a2c Rename pathological test case SVG 2023-05-18 14:34:25 -04:00
Isaiah Odhner
1dbbbdfdfe Tweak logs/comments 2023-05-17 23:28:32 -04:00
Isaiah Odhner
4fc5efd34e Use minimum rect size to define character cell size 2023-05-17 23:02:43 -04:00
Isaiah Odhner
56f8d47036 Fix string comparison for "none"/"" fill values 2023-05-17 23:00:10 -04:00
Isaiah Odhner
4a9ffbbacd Clean up: remove old outlier removal code 2023-05-17 22:54:14 -04:00
Isaiah Odhner
d323c25ed4 Add debug markers for grid bounds (min/max) 2023-05-17 22:54:14 -04:00
Isaiah Odhner
d618cab0c9 Make debug visuals line up when grid origin is not at (0,0)
as is the case with the pathological SVG test case (combative_character_grid.svg)
2023-05-17 22:54:14 -04:00
Isaiah Odhner
8faaac8cf8 Note useful automation for testing SVG loading 2023-05-17 22:54:14 -04:00
Isaiah Odhner
5a72f5efc2 Don't close any existing message box when opening a new one 2023-05-17 22:54:06 -04:00
Isaiah Odhner
fd6e75abe7 Start handling varying background rect sizes
It turns out the background rects can span multiple cells, so I have to
pivot strategy here.

Instead of removing any outliers, remove any containers, i.e. rects that
visually (not structurally) contain other rects.

This doesn't yet fill in multiple cells when a rect is spanned.
2023-05-17 22:53:37 -04:00
Isaiah Odhner
902de786dc Handle invalid colors more laxly 2023-05-17 20:41:13 -04:00
Isaiah Odhner
8f78ce662a Fix cell bucketing of text elements, basically 2023-05-17 20:41:13 -04:00
Isaiah Odhner
8458ccf3c9 Visualize cell bucketing for debug 2023-05-17 20:40:46 -04:00
Isaiah Odhner
f17b180546 Adjust cell size based on document size guess 2023-05-17 20:40:11 -04:00
Isaiah Odhner
b9f5f00480 Loosen 2023-05-17 17:38:31 -04:00
Isaiah Odhner
3892dc503e WIP: open SVG files saved with the app
Progress!

print
2023-05-17 12:34:09 -04:00
Isaiah Odhner
55419d671e Fix API breakage from changes in textual 0.23.0 2023-05-17 12:16:47 -04:00
Isaiah Odhner
6a3ab712a5 Include error traceback in message boxes, shown by clicking Show Details 2023-05-17 10:47:48 -04:00
Isaiah Odhner
601e50d5b5 Give error if you try to load HTML/SVG
- DRY: Make decode_based_on_file_extension use format_from_extension.
- If you try to load .html, .htm, .svg, (or ._rich_console_markup) file,
  show an error instead of loading as text. The text would be much
  larger than a document you saved in this format, and it wouldn't give
  you what you expect, unless you're wanting to load an arbitrary text
  file for viewing, and for some reason choose this program to do it.
2023-05-17 00:57:23 -04:00
Isaiah Odhner
259ce5f311 Remove redundant assignment 2023-05-17 00:30:55 -04:00
Isaiah Odhner
51125cc08a Improve documentation of FIGletFontWriter 2023-05-17 00:26:59 -04:00
Isaiah Odhner
6316513cd3 Document Layout enum values 2023-05-17 00:11:58 -04:00
Isaiah Odhner
97bcdbc344 Add validation to FIGletFontWriter 2023-05-16 23:53:45 -04:00
Isaiah Odhner
4589d9a147 Clarify _fixFigChars with comments
Within the span of like a day I forgot that FIGlet fonts can be
proportional and came back to this code and was confused why charWidth
needs to be a dictionary. Well it doesn't NEED to be, it could be
implemented differently, for instance by fixing the height first,
it wouldn't need to calculate a number of spaces for the blank lines —
but how it's implemented, the width fixup could be disabled, and the
height fixup would still work. So even though the code would be a little
simpler, I'm not sure it would be better that way.
2023-05-16 23:53:45 -04:00
Isaiah Odhner
ca5a51bb6c Dissolve blankLines function 2023-05-16 23:45:02 -04:00
Isaiah Odhner
a833fc3be8 Dissolve spacePad function 2023-05-16 23:45:02 -04:00
Isaiah Odhner
33aa786d9f Mark missed method as private 2023-05-16 23:45:02 -04:00
Isaiah Odhner
425a15293c Use an enum for layout options 2023-05-16 23:45:02 -04:00
Isaiah Odhner
e17aeae948 Move license text and add dunders 2023-05-16 22:18:56 -04:00
Isaiah Odhner
323503884f Move FIGletFontWriter to a file 2023-05-16 20:48:53 -04:00
Isaiah Odhner
8c69e5a8ef Add MIT license to FIGletFontWriter
I obtained permission from the author over email :)

Now I can go ahead and merge this code in.
2023-05-16 20:45:09 -04:00
Isaiah Odhner
7f6a6211ad Add Open Font License to NanoTiny 2023-05-16 20:14:18 -04:00
Isaiah Odhner
a4c0fd7546 Clarify docstring 2023-05-16 20:14:18 -04:00
Isaiah Odhner
6c3c34d3ac Move font files to folder 2023-05-16 20:14:18 -04:00
Isaiah Odhner
b74914e841 Don't pass parameters that are auto-calculated 2023-05-16 20:14:18 -04:00
Isaiah Odhner
a65192d49c Make all parameters of FIGletFontWriter() optional 2023-05-16 20:14:18 -04:00
Isaiah Odhner
93ef354ec6 Remove fontName parameter, since it's unused 2023-05-16 20:14:18 -04:00
Isaiah Odhner
78d0c5fae7 Add version number to font comments 2023-05-16 20:14:18 -04:00
Isaiah Odhner
13e59cacc1 Improve NanoTiny FIGlet fonts for standalone usage 2023-05-16 20:14:18 -04:00
Isaiah Odhner
27df15487e Mark methods as private 2023-05-16 20:14:17 -04:00
Isaiah Odhner
e2c5fc9af5 Add docstrings to FIGletFontWriter 2023-05-16 20:14:17 -04:00
Isaiah Odhner
f89a2353ec Minimize vRule list length 2023-05-16 20:14:17 -04:00
Isaiah Odhner
838fb5d540 Make caseInsensitive a parameter 2023-05-16 20:14:17 -04:00
Isaiah Odhner
e1245aa9e9 Load FIGlet font format 2023-05-16 20:14:17 -04:00
Isaiah Odhner
8b6a1586ef Remove irrelevant code 2023-05-16 20:14:00 -04:00
Isaiah Odhner
024120bc42 Generate FIGlet fonts of NanoTiny 2023-05-16 20:14:00 -04:00
Isaiah Odhner
400c6b4251 Automatically add .ans file extension when bare filename is entered
This applies to Save As and Copy To dialogs, but not the CLI.
2023-05-16 14:43:01 -04:00
Isaiah Odhner
cdf30c49f9 Fix 103 type checker errors by annotating height (and not width) 2023-05-16 14:43:01 -04:00
Isaiah Odhner
e045e6e9f9 Handle backup files (*~) when guessing format from file extension 2023-05-16 14:42:23 -04:00
Isaiah Odhner
9f9974fc48 Generalize --recode-samples to look for files of all types, recursively 2023-05-16 14:42:23 -04:00
Isaiah Odhner
1a9c079f7e Use format IDs for custom formats; show "Unknown file extension" instead of assuming ANSI 2023-05-16 14:35:00 -04:00
Isaiah Odhner
004700ad57 Add more unicode alternatives 2023-05-16 02:30:10 -04:00
Isaiah Odhner
7bc86bc483 Fix error handling for decode_based_on_file_extension
- UnicodeDecodeError was caught in a more general error handler;
  now it's allowed to reach the more specific handler.
- UnidentifiedImageError and FormatReadNotSupported were missing return;
  now it's not caught there so it doesn't need to, as the exception will
  interrupt the control flow.
2023-05-15 16:05:10 -04:00