Commit graph

1065 commits

Author SHA1 Message Date
Will McGugan
45520f2da1
color tests to 100% (#2078)
* color tests to 100%

* tweak

* remove overly complex code
2023-03-16 11:42:51 +00:00
Will McGugan
de692aaf07
fix for remove nodes (#2080)
* fix for remove nodes

* added test
2023-03-16 11:36:10 +00:00
Will McGugan
43253f5d80
fix border issue (#2074)
* fix border issue

* add PR to changelog
2023-03-16 09:03:02 +00:00
Rodrigo Girão Serrão
1246934643
Merge pull request #2030 from Textualize/add-containers
Add containers
2023-03-15 10:37:01 +00:00
Rodrigo Girão Serrão
285de4b0fa Merge branch 'main' into add-containers 2023-03-14 14:35:23 +00:00
Dave Pearson
8220af4bfe
Add some initial rules to a "mega stylesheet"
The start of what will hopefully become a one-stop comprehensive test of all
the fun corners of stylesheet parsing. While not intended to replace all the
other unit tests for CSS, this test should help to quickly and easily be
sure that nothing breaks any valid CSS.

Influenced by #1253 and #1836 this code starts the process of implementing
the requirement outlined in #1838.

Adding more rules -- simple and/or weird -- that are expected and known to
parse without a problem is encouraged.
2023-03-14 14:11:32 +00:00
Dave Pearson
cfb8219e44
Merge pull request #2039 from davep/new-disabled-snapshot-test
Simplify the disabled widgets snapshot test
2023-03-14 08:48:40 +00:00
Rodrigo Girão Serrão
f9a1e27c6f Merge branch 'main' into add-containers
[skip ci]
2023-03-13 16:21:46 +00:00
Rodrigo Girão Serrão
f81dd4071c Merge branch 'main' into message-namespaces 2023-03-13 16:08:50 +00:00
Dave Pearson
cf62a4a76a
Update the snapshots 2023-03-13 15:37:45 +00:00
Dave Pearson
dd49a723ee
Simplify the disabled snapshot test
Initially this was "throw most if not all widgets at the display and disable
everything" test; but in #2028 it was requested that this be simplified,
just using the same widget, in enabled and disabled states.

Button seems like a good choice here.

To ensure that things work as intended, I'm going with the approach of
disabling via a container as that's one big change that the disabled
facility brought in.
2023-03-13 15:31:29 +00:00
Rodrigo Girão Serrão
7e83acb966 Add regression test for #1814. 2023-03-13 15:14:12 +00:00
Will McGugan
b0f5c35782
tabs widget (#2020)
* tabs widget

* click underline

* color tweak

* docs

* docs update

* expose Tab

* added remove_tab and clear

* fix cycling

* add animation

* docs

* changelog

* remove recompose

* docstrings

* Update docs/guide/actions.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Rodrigoed the tabs

* Update docs/widgets/tabs.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Update docs/widgets/tabs.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* copy

* docstrings

* docstring

* docstring

* Apply suggestions from code review

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* stop click

* docstring

* auto assign consistent IDs

* Apply suggestions from code review

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Document bindings

* document bindings

* Apply suggestions from code review

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

---------

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
2023-03-13 14:39:15 +00:00
Rodrigo Girão Serrão
103c27b942 Add test for pilot pressing underscore.
The pilot pressing the underscore '_' used to be an alias for a short pause (see #2011). This test makes sure that the pilot can press the underscore '_' as any other character key.
2023-03-13 14:11:33 +00:00
Rodrigo Girão Serrão
009270cd69 Remove remaining underscore pauses.
These slipped from #2011.
2023-03-13 14:10:22 +00:00
Rodrigo Girão Serrão
3518d38d85 Update snapshot tests. 2023-03-13 12:02:36 +00:00
Rodrigo Girão Serrão
cc8f65259e Merge branch 'main' into add-containers 2023-03-13 12:00:08 +00:00
Rodrigo Girão Serrão
429c8a3649 Tweak default Center/Middle dimensions.
We set dimensions to 1fr instead of 100% (original request) or blank (previous change) for consistency with the other containers.
2023-03-13 11:48:49 +00:00
Rodrigo Girão Serrão
48ce1a149d Add snapshot test for Center/Middle. 2023-03-13 11:18:33 +00:00
Will McGugan
9c5e0336f8
Fix scrollbar (#2024)
* Fix scrollbar

* changelog PR

* fix snapshots
2023-03-13 10:39:14 +00:00
Will McGugan
198190117d
Loading indicator (#2018)
* loading indicator and tests

* docs

* snapshot

* remove snapshot

* remove debug main [skip ci]

* changelog [skip ci]

* make start time private
2023-03-11 08:36:13 +00:00
Will McGugan
d3bdaf8ae5
fix refresh on remove (#2008)
* fix refresh on remove

* changelog

* optimization

* added snapshot
2023-03-10 10:06:10 +00:00
Dave Pearson
e6f620db44
Remove underscore pauses from (hopefully) all snapshots
This seeks to remove the "_" from the key presses of snapshots and inline
runs in the documentation. The "_" no longer does anything, but got legacy
reasons at the moment we can't actually allow "_" to be an input to a
"faked" keypress in the docs and snapshots.

Removing these clears the way to letting "_" have the same status as any
other character.

See #1994.
2023-03-09 20:32:27 +00:00
Rodrigo Girão Serrão
c13308a360 Add tests for Horizontal/Vertical(Scroll) containers. 2023-03-09 17:39:05 +00:00
Rodrigo Girão Serrão
5674b4b628 Add 'Vertical'.
Related issues: #1957.
2023-03-09 15:38:31 +00:00
Rodrigo Girão Serrão
e111449856 Add container 'Middle'.
Related issues: #1957.
2023-03-09 15:24:13 +00:00
Rodrigo Girão Serrão
f91750ed3d Add container 'Center'.
This container will centre children horizontally.

Related issues: #1957.
2023-03-09 15:21:20 +00:00
Rodrigo Girão Serrão
be41797a8d Merge branch 'main' into add-containers 2023-03-09 15:19:43 +00:00
Rodrigo Girão Serrão
90dce06eae Add 'HorizontalScroll'.
Related issues: #1957.
2023-03-09 14:35:49 +00:00
Dave Pearson
97a5478bd0
Add ContentSwitcher (#1983)
* Add the basic ContentSwitcher widget

* Docstring tidy

* Add a visible_content property to the ContentSwitcher

* Clarify that children of ContentSwitcher with no IDs get ignored

* Simplify setting the display value

* Add the start of an example ContentSwitcher for the docs

* Tweak the example layout to better fit in small spaces

* Add the content switcher to the API docs

* Add a guide entry for the ContentSwitcher

This one is a wee bit more involved than most other widget entries in the
guide in that it doesn't obviously do anything itself, but needs
developer-input to make it do something useful. As such the outline here
isn't as clean as it could be, but I think it conveys everything necessary
without getting too complicated.

* Add the reactive attribute table to the ContentSwitcher guide

* Update the README

* Add a refresh after everything has been flipped in the switcher

As noted in the code, this should not be necessary and I don't believe it
has anything to do with this code. I would suspect some lower-level issue
with flipping between different widgets within a container. I need to find a
way to make an isolated reproduction that isn't about this particular
widget. Meanwhile though this works with the refresh().

* Swap current from var to reactive

This solves the explicit refresh issue, but only because the refresh is
implied due to the use of a reactive over a var. As such this sort of
addresses #1979 by ignoring the issue rather than diving into it.

I still suspect that I shouldn't need to do this, and that perhaps there's a
refresh issue when you flip display. So I'll keep #1979 kicking around and
at some point see if I can recreate in isolation.

* Add unit tests for the content switcher

* Add snapshot tests for the ContentSwitcher

* Clarify that an exception can be thrown on a bad ID

* Try and help other Pythons

* Add a pause at the end of the second switcher snapshot test

I'm getting a lot of fails in CI; none of them are actual problems.
Hopefully this will cure it.

* Paaaaaaaaause

More of a test than anything else really. My particular snapshot test is
failing but kinda randomly in each environment each time -- sometimes
Windows, sometimes GNU/Linux, different Python versions.

So... yeah, let's try this and see if it makes it through; otherwise I may
need to rethink this.

* New pause

So it turns out that _ doesn't do anything any more; and instead there's a
"wait:<n>" syntax! So let's give that a try.

* Learning my alphabet...

* Fix a typo in the docs.

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Add missing full stop.

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Add a missing word

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Try a longer wait on the switcher

I'm starting to suspect that this doesn't come down to a timing issue;
especially given that the snapshot report seems to be showing some oddity in
the length of the vertical scrollbar. But... I want to be as sure as
possible so let's double the length of the wait.

Bit a bit of me is starting to wonder if I've somehow managed to create the
perfect storm for scrollbars and you don't always get the same result every
time.

Seems unlikely, but if it's not timing it's that or lots of cosmic rays.

* Test a longer pause on the content switcher test

The idea here being that it takes 200ms for the button to pop again.

* Refresh the snapshots

This time. THIS TIME!

* Experiment: is the issue the same name for two tests?

* Experiment: drop the different source files, try terminal size

Having got over the issue of the button not ending up in the same state,
we're stuck with the scrollbar having different sizes. Having tried other
options let's go with tweaking the terminal size.

* Do a little less work when changing current

Rather than set everything invisible then the new one visible, every time
current is changed, instead just make sure everything is invisible up front
and then just swap the affected children each time.

This does mean that if someone messes with the children under the hood they
may see oddness happening, but less work while being less defensive seems
fair here.

---------

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
2023-03-09 11:39:30 +00:00
Dave Pearson
a5695edcb5
Swap out the primary Markdown bullet for one that works everywhere (#1997)
* Swap out the primary Markdown bullet for one that works everywhere

The primary bullet wasn't displaying well on Windows in the Windows
terminal.

* Refresh the snapshot tests

Imagine that, changing how something looks needs that the snapshot tests get
updated. *facepalm*
2023-03-09 11:38:58 +00:00
Rodrigo Girão Serrão
8565d3cef6 Renamed 'Vertical' to 'VerticalScroll'.
Related issues: #1957.
2023-03-08 18:31:24 +00:00
darrenburns
2ed72e1710
DataTable - fix crash when selection made in empty table (#1973) 2023-03-07 20:58:28 +00:00
darrenburns
4921a5cb43
Snapshot tests for the CLI preview apps (#1969) 2023-03-07 16:42:21 +00:00
darrenburns
b366d1d49c
Pilot - add hover and click methods (#1966)
* Delete redundant test file

* Sketch out pilot API improvements - signatures/docstrings

* Pilot click and hover

* Updating test to use new pilot hover method for DataTable

* hover and click methods for Pilot

* Update changelog

* Add docstring
2023-03-07 15:19:23 +00:00
Dave Pearson
6d23fdf4f1
Ensure the toggle button keeps any bold state (#1965)
* Ensure the toggle button keeps any bold state

Fixes #1963.

* Update snapshots
2023-03-07 15:18:36 +00:00
Dave Pearson
b7de48cca3
Border colour percentage (#1954)
* Allow setting an additional alpha on a border

See #1863.

* Update the ChangeLog

* Add snapshot tests for the border alpha value

* Extend the border snapshot tests

While this doesn't test *every* permutation, it covers enough bases that if
something were to change it should catch it.

* Tweak a typo in the border style examples

* Add border transparency percentage to the border docs

* Add a CSS example for using border transparency

* Add Color.multiply_alpha

* Update the CHANGELOG

* Multiply the alpha on a colour rather than replace it

As requested in
https://github.com/Textualize/textual/pull/1954#pullrequestreview-1328170386

(actually required while talking in person with Will, but noted in the
above)

* Multiply the alpha on a border colour rather than replace it

As requested in
https://github.com/Textualize/textual/pull/1954#pullrequestreview-1328170386

(actually requested while talking in person with Will, but noted in the
above)
2023-03-07 14:14:17 +00:00
darrenburns
fd0e0d9983
Datatable extend background (#1946)
* Extending DataTable widget horizontally

* Fading background of extended DataTable rows

* Updating DataTable snapshots

* Update CHANGELOG.md

---------

Co-authored-by: Will McGugan <willmcgugan@gmail.com>
2023-03-06 16:27:29 +00:00
Dave Pearson
6ba1905d4a
Swap the radio button character
See #1934. Simply put: the character that we were using doesn't render well
at all in Windows Terminal on Windows 10 or 11. This one isn't ideal as it
sits a little low, at least in some environments. I want to try this one on
for a wee bit and see how we feel about it.

Honestly, I'm not 100% happy with it; but right now it's the least-worst
option I've tried.
2023-03-06 13:50:28 +00:00
Dave Pearson
f59977563f
Merge branch 'main' into windows-friendly-toggle-buttons 2023-03-06 12:42:33 +00:00
Dave Pearson
f7a6981abf
Swap the checkbox character to an X
See #1934. Simply put: the character that we were doesn't render well at all
in Windows Terminal on Windows 10; while there are other options available,
few seem to work well there either. So here we go for a bold X; this should
render fine everywhere.
2023-03-06 11:19:29 +00:00
Rodrigo Girão Serrão
51a9eb4a88 Merge branch 'main' into fix-1815 2023-03-06 11:04:31 +00:00
Will McGugan
373fc95fc1
Drop explicit sender attribute from messages (#1940)
* remove sender

* removed priority post

* timer fix

* test fixes

* drop async version of post_message

* extended docs

* fix no app

* Added control properties

* changelog

* changelog

* changelog

* fix for stopping timers

* changelog

* added aliases to radio and checkbox

* Drop sender from Message init

* drop time

* drop cast

* Added aliases
2023-03-06 10:52:34 +00:00
Rodrigo Girão Serrão
b6b76025d0 Add regression test for #1815. 2023-03-02 17:21:19 +00:00
Will McGugan
41003e356c
Fix content width (#1910)
* fix calculation for scrollbars

* added snapshot

* fix for name change

* snapshot

* fix for textual colors

* remove logs

* scrollbar logic

* scroll logic

* remove dead code

* snapshot tests

* scrollbar mechanism

* tidy

* demo tweak

* preset window size

* no need for repaint

* Restore repaint

* wait for idle on pause

* colors tweak

* remove wait for idle

* snapshot

* small sleep

* change stabilizer

* debug tweaks

* remove debug

* remove debug

* snapshot test

* docstring

* changelog

* add pause
2023-03-02 14:39:31 +00:00
Dave Pearson
37208b199c
Fixes and improvements relating to scrolling
The changes here roll two issues into one change. With this commit:

- Scrolling up/down/etc using the keyboard now moves just one cell, rather
  than moving the number of cells specified by the scroll sensitivity that's
  intended for pointing devices. #1897
- Where appropriate the scrolling is done lazily; that is it is done after
  the next refresh, helping to ensure that the scroll will take into account
  any updates in the same parent call. #1774
2023-02-28 14:59:46 +00:00
Dave Pearson
8c5fb38851
Merge branch 'main' into toggle-boxen 2023-02-27 10:31:06 +00:00
darrenburns
cbe2ab87c6
Datatable labelling rows (#1868)
* Renaming some component classes in DataTable

* Some more renaming of DataTable component classes

* Separate styling for fixed rows/columns from labels

* Highlight fixed rows/cols affected by colour differently

* Tweaking styles for fixed data in DataTable

* Update DataTable snapshots

* Add row label to Row metadata

* Wiring up some labelled row logic behind flags

* Renaming variable in DataTable

* Variable renaming in DataTable

* [no ci] Labelling rows progress

* Add RenderedRow abstraction to DataTable

* Computing label widths

* Use the Column object to represent row label column

* Ability to toggle row labels reactively

* Adjust width calculation for label widths

* Add DataTable.RowLabelSelected

* Posting the RowLabelClick message

* Hovering of row labels applies new style

* Remove a print

* Ensure horizontal scrolling with column cursor accounts for row label column

* Account for possible row labels in cell cursor horizontal scrolling

* Ensure cursor highlighting is correct on row label cells

* Document component class for DataTable label hover

* Test to ensure clicking row label emits correct event

* Add snapshot test for DataTable with fixed rows/cols and row labels

* Using pilot pause instead of wait_for_idle directly

* Update CHANGELOG

* Add a docstring

* Add a note to CHANGELOG.md about RowLabelSelected
2023-02-27 10:29:17 +00:00
Dave Pearson
7bfed019c9
Improve the wording of a test description 2023-02-27 10:08:45 +00:00
Dave Pearson
445e29ff26
Improve the wording of a test description 2023-02-27 10:07:59 +00:00