Commit Graph

6285 Commits

Author SHA1 Message Date
Rodrigo Girão Serrão
a9c38793de Merge pull request #2546 from Textualize/footer-css
Use footer--description component class.
2023-05-11 15:01:01 +01:00
Rodrigo Girão Serrão
58cf825eb4 Use footer--description component class.
Related issues: #2544.
2023-05-11 12:19:29 +01:00
Dave Pearson
c45126b21c Update the ChangeLog 2023-05-11 11:19:30 +01:00
Dave Pearson
9b41b743fe Remove the artificial slowdown 2023-05-11 11:13:19 +01:00
Dave Pearson
05eeaa7679 Tidy up _load_directory
Explain some about the decisions made, and also throw in a bit of
over-cautious worker cancellation checking.
2023-05-11 10:53:07 +01:00
Dave Pearson
82a08177af Cancel any loads when resetting the tree 2023-05-11 09:59:57 +01:00
Dave Pearson
9ae8e47c6c Add a method for cancelling all of the load jobs
This marks all current jobs as cancelled and also removes all pending jobs.
2023-05-11 09:59:18 +01:00
Dave Pearson
08246d84ac Don't post the finished message if we've been cancelled 2023-05-11 09:57:30 +01:00
Dave Pearson
791f2ea189 Ensure we don't create a job for a node that's already being loaded 2023-05-11 09:16:54 +01:00
Dave Pearson
ce7a78db69 Have the reset method take part in background loading
One instance of a call to _load_directory that I missed.
2023-05-11 09:12:10 +01:00
Dave Pearson
4ead43c149 Set up the job tracking before setting the path
Setting the path to anything other than "." is going to result in a reset
happening, so we need the tracking support in place first.
2023-05-11 09:10:55 +01:00
Dave Pearson
df0f73ba3b Remove debug logging 2023-05-11 08:35:36 +01:00
Dave Pearson
05dc877a24 Check for the worker being cancelled
So far this is working fine, but there was an issue where, if the load of a
very large directory was started, and then the application was cancelled
right away, the application would close down but there would be a long pause
until the shell prompt came back, the cause presumably being that we were
waiting for that particular thread to end.

So here I make sure I check the cancelled state of the worker. This would
also suggest that, while I turned the use of iterdir into a loop so I could
throw the sleep in to emulate a slow directory load, I *actually* want to do
this in a loop so I can test the cancelled state as we stream in the
directory content.
2023-05-11 08:31:01 +01:00
Will McGugan
0dc89dc2a8 wrong axis 2023-05-10 22:25:04 +02:00
Will McGugan
5a02f7335e fix docstrings 2023-05-10 22:21:30 +02:00
Dave Pearson
39971876d0 WiP: Throttle back the number of concurrent loads of a DirectoryTree
Having got the initial version of background loading of nodes in the
directory tree working, this moves to a gentler approach where only so many
loads run at once, and a queue of jobs that need to be completed is kept.

This is an end-of-coding-session WiP commit; there's more to come on this.
But at the moment I'm happy with the way it's going.
2023-05-10 16:26:36 +01:00
Dave Pearson
cd05d6cad6 Merge branch 'main' into directory-tree-work-in-worker 2023-05-10 14:22:36 +01:00
Dave Pearson
2d75ca0d77 Merge pull request #2536 from davep/expand-tree-expand-messages
Ensure that `TreeNode` messages are posted when via-API changes are made
2023-05-10 14:18:24 +01:00
Rodrigo Girão Serrão
70e97c6703 Merge pull request #2532 from Textualize/sub-title-str
Allow setting (sub)title of any type.
2023-05-10 13:20:47 +01:00
Rodrigo Girão Serrão
8dd627b0f4 Merge branch 'main' into sub-title-str 2023-05-10 13:10:48 +01:00
Dave Pearson
8b9a8e4174 Simplify _load_directory
Move the node population code into its own method, the idea here being that
the update happens in one call to call_from_thread rather than spawning lots
of calls to it.
2023-05-10 12:06:11 +01:00
Dave Pearson
d673175e62 Experimenting with placing _load_directory in a worker
This isn't the final form, not even close, this is more to help test out the
idea and how well it will work. Note the very deliberate sleep in the code
that's there to emulate loading from a slow blocking source.

This will be removed and tidied up before a final PR, of course. The main
aim here is to emulate a worst-case scenario so that the use of a worker can
be tried out with some confidence.

See #2456.
2023-05-10 11:17:02 +01:00
Dave Pearson
28be54d10d Merge branch 'main' into expand-tree-expand-messages 2023-05-10 10:12:58 +01:00
Dave Pearson
f19f46bba0 Merge pull request #2519 from davep/cygnus-x-1
Fix for `resolve_fraction_unit` zero division error (#2502)
2023-05-10 10:10:55 +01:00
Dave Pearson
c7fc66fa6c Ensure that TreeNode messages are posted when via-API changes are made
Until now the Tree.NodeExpanded and Tree.NodeCollapsed messages were only
sent out when changes were made to the tree by user interaction. This meant
that if any changes were made with the TreeNode expand, expand_all,
collapse, collapse_all, toggle or toggle_all API calls no messages would be
sent.

This PR corrects this.

The work here is, in part, required for #2456 (DirectoryTree lazy-loads
directory information on node expansion so if someone is expanding nodes
under code control the DirectoryTree never gets to know that it should load
a directory's content) and will build on #1644, essentially adding a missing
aspect to the latter PR.
2023-05-10 09:24:07 +01:00
Dave Pearson
0eeadf9ae9 Update the CHANGELOG 2023-05-09 21:01:31 +01:00
Rodrigo Girão Serrão
41466be007 Add docstrings. 2023-05-09 17:10:08 +01:00
Rodrigo Girão Serrão
fcf9806f6b Add clarifying comment. 2023-05-09 17:00:07 +01:00
Rodrigo Girão Serrão
17af473558 Annotate no-op. 2023-05-09 16:58:56 +01:00
Rodrigo Girão Serrão
e8baf52bdd Allow setting (sub)title of any type.
Related issues: #2521.
2023-05-09 16:56:56 +01:00
Rodrigo Girão Serrão
3245eb38bb Make auto-focus a class var.
Related comments: https://github.com/Textualize/textual/pull/2527\#discussion_r1188776849
2023-05-09 16:44:37 +01:00
Dave Pearson
30a20ac8da Break iterdir out into a method of its own for easy testing
As I work on what's to come (loading DirectoryTree with a worker), I'm going
to want to try and construct slow loads so I can test the effectiveness of
the changes. This means a desire to fake a very slow source of directory
information. So let's drop this into its own method so we can then do silly
things like add a sleep to really show stuff down.
2023-05-09 16:41:17 +01:00
Rodrigo Girão Serrão
eafe6b1786 Moving child before/after self is a no-op.
Related issues: #1743.
2023-05-09 15:57:23 +01:00
Dave Pearson
8855471125 Merge pull request #2522 from davep/move-widget-enhanced-testing
Make the widget moving tests more granular and add more tests
2023-05-09 15:07:59 +01:00
Rodrigo Girão Serrão
8d3f69a04d Add auto_focus attribute to screens. 2023-05-09 14:57:50 +01:00
Rodrigo Girão Serrão
ed4d811451 Add tests for Screen auto focus.
Related issues: #2457.
2023-05-09 14:55:18 +01:00
Dave Pearson
a0558e87d8 Merge branch 'main' into cygnus-x-1 2023-05-09 13:38:16 +01:00
Dave Pearson
8d7ae4d1fb Ensure that remaining fraction is always above zero 2023-05-09 13:36:32 +01:00
Dave Pearson
ee70713002 Simplify the resolver zero division bug unit test 2023-05-09 13:35:55 +01:00
Dave Pearson
d3de6d1587 Make the widget moving tests more granular and add more tests
Adds two (currently xfail) tests to illustrate #1743
2023-05-09 11:19:00 +01:00
Dave Pearson
a77dbf4bee Tentative fix for resolve_fraction_unit ZeroDivision error
I'll admit to not really following what the code does, so will really need
someone with a better understanding of the aim of this code to look over the
proposed fix; but based on a bunch of runs and hand-debugging, this seems to
do the job.

This passes all existing tests and also removes the reported error.

On the other hand I'm not confident that I'm *not* just masking an
underlying issue with this function.
2023-05-09 10:38:09 +01:00
Dave Pearson
a5cc96cbc7 Make a pass of the #2502 test a fail
If/when I get this actually passing, I want the test to appear to fail so I
know things have changed for the better.

This makes sense, trust me.
2023-05-09 09:44:51 +01:00
Dave Pearson
052ec83b7a Make the test as small as possible 2023-05-09 09:44:30 +01:00
Dave Pearson
089dce1b41 Add a unit test for #2502
Currently marked as xfail, but this gets it down to the most basic level.
2023-05-09 09:39:12 +01:00
Kim van Wyk
dea21a00ca minor typo (#2515) 2023-05-08 20:01:45 +01:00
Will McGugan
e3115c50bf fix for code browser type error (#2514) v0.24.1 2023-05-08 18:42:10 +01:00
Will McGugan
cf7e8a9cb1 update roadmap 2023-05-08 18:10:40 +01:00
Will McGugan
dc102563e9 changelog and release post (#2513)
* changelog and release post

* fix version

* link Select

* remove superfluous css

* Update docs/blog/posts/release2-24-0.md

Co-authored-by: darrenburns <darrenburns@users.noreply.github.com>

* Update docs/blog/posts/release2-24-0.md

Co-authored-by: darrenburns <darrenburns@users.noreply.github.com>

---------

Co-authored-by: darrenburns <darrenburns@users.noreply.github.com>
v0.24.0
2023-05-08 17:45:06 +01:00
Rodrigo Girão Serrão
855c90d4f0 Extend @on decorator to filter matchable attributes (#2498)
* Add tests for #2484.

* Implement @on extension.

[skip ci]
Related issues: #2484.

* Changelog.

* Add missing @on test.

* Remove debug prints.

* Document changes.

* Update tests.

Test now fully works, as of #2490.

* Cache parsed selectors.

* Streamline exit condition.

* Fix typing.

* More succint wording.

* Document 'on' kwargs.

* Update src/textual/_on.py

Co-authored-by: Will McGugan <willmcgugan@gmail.com>

* Update docs/guide/events.md

Co-authored-by: Will McGugan <willmcgugan@gmail.com>

* Change 'on' API.

* Remove example code.

* Address feedback.

* Update src/textual/_on.py

Co-authored-by: Will McGugan <willmcgugan@gmail.com>

* Address review feedback.

* Fix #2499.

* don't require control to be manually specified

* update docstring

* deleted words

---------

Co-authored-by: Will McGugan <willmcgugan@gmail.com>
2023-05-08 17:30:07 +01:00
Will McGugan
dd7e768887 merged changelog sections 2023-05-08 12:51:50 +01:00