Commit Graph

162 Commits

Author SHA1 Message Date
Darren Burns
ca496b4f56 tree-sitter upgrade (#5320)
* Using separate language packages and update lockfile

* Fixing some but not all languages

* Theme updates

* More theme fixes

* Improving the VS Code theme

* Fixes

* Fixing CSS rendering

* Fixing SQL and JavaScript highlight queries

* Update GitHub Actions to run syntax highlighting tests on 3.13, and avoid those tests on 3.8.

* Update CHANGELOG and remove `SyntaxAwareDocument.language_name` property.

* Remove unused Kotlin language syntax highlighting snapshot

* Update CHANGELOG to note that Kotlin syntax highlighting was removed

* Bail out of TextArea.language watcher early if tree-sitter is not installed

* Skip a test on 3.8 as it relates to syntax highlighting (tree-sitter) being available
2024-12-04 10:33:58 +00:00
Darren Burns
79df474d14 Fix ListView styling (#5304)
* Quick fixes to list view styles

* Updating snapshots

* Update changelog
2024-11-28 14:40:17 +00:00
Will McGugan
9ce509f120 bump textual-dev and update snapshots 2024-11-19 15:38:24 +00:00
Darren Burns
e23a0ef289 Theme examples 2024-11-06 14:23:57 +00:00
Will McGugan
8633bd27f9 depenencies 2024-10-22 13:09:15 +01:00
JaceyPenny
5f24a751ba Loosen platformdirs version requirement 2024-09-09 18:58:25 +00:00
Will McGugan
53bcdbef5c remove objgraph from dependencies 2024-09-07 17:59:18 +01:00
Darren Burns
5bbfd49b3c Remove msgpack-types dependency 2024-08-20 16:02:53 +01:00
Darren Burns
b2eddbe7a7 Remove msgpack dependency 2024-08-20 15:32:34 +01:00
Darren Burns
2adac06ce3 Move msgpack-types to dev deps 2024-08-12 14:54:39 +01:00
Darren Burns
ba0c7260a7 Handling requests for chunks from the server 2024-08-06 12:40:12 +01:00
Darren Burns
0e95c9a67e Add msgpack 2024-08-06 10:15:12 +01:00
Darren Burns
212b313166 Add platformdirs and use it to get the download dir if its not specified 2024-07-31 13:29:42 +01:00
Darren Burns
5966bf3318 Update snapshots (#4788)
* Update snapshots

* Update to use textual-snapshot v1.0.0

* Dont use xdist on CI

* Update pytest-cov to fix warnings

* Remove xdist thing from pythonpackage.yml GitHub workflow
2024-07-25 11:50:54 +01:00
Darren Burns
914b4631d8 isort minor version update, and add to development dependencies (#4727) 2024-07-11 14:32:01 +01:00
Will McGugan
c1591fca33 bump 2024-05-15 17:24:10 +01:00
Will McGugan
305ac3853d show update time 2024-05-14 17:15:05 +01:00
Rodrigo Girão Serrão
70ea75e674 Add example apps to tests. (#4036)
* Add example apps to tests.

* Add merlin, remove code browser, update snapshots.

* Fix snapshots.

* Update JSON example to use new colors.

* Fixing a snapshot

* Update lockfile

---------

Co-authored-by: Darren Burns <darrenburns@users.noreply.github.com>
Co-authored-by: Darren Burns <darrenb900@gmail.com>
2024-04-16 16:14:20 +01:00
Darren Burns
ef7cf2c9eb Merge branch 'main' of github.com:Textualize/textual into text-area-new-languages 2024-03-27 14:30:50 +00:00
Will McGugan
2282da5755 don't need useful types 2024-03-01 18:14:09 +00:00
Will McGugan
9661019178 typing 2024-03-01 17:11:20 +00:00
juftin
c8d64362db fix(text-area): tree-sitter-languages pin 2024-02-14 16:09:45 -07:00
Darren Burns
fa4f75fd25 Text area undo redo (#4124)
* Initial undo related machinery added to TextArea

* Initial undo implementation

* Basic undo and redo

* Some more fleshing out of undo and redo

* Skeleton code for managing TextArea history

* Initial implementation of undo & redo checkpointing in TextArea

* Increase checkpoint characters

* Restoring the selection in the TextArea and then restoring it on undo

* Adding docstrings to undo_batch and redo_batch in the TextArea

* Batching edits of the same type

* Batching edits of the same type

* Keeping edits containing newlines in their own batch

* Checking for newline characters in insertion or replacement during undo checkpoint creation. Updating docstrings in history.py

* Fix mypy warning

* Performance improvement

* Add history checkpoint on cursor movement

* Fixing merge conflict in Edit class

* Fixing error in merge conflict resolution

* Remove unused test file

* Remove unused test file

* Initial testing of undo and redo

* Testing for undo redo

* Updating lockfile

* Add an extra test

* Fix: setting the `text` property programmatically should invalidate the edit history

* Improving docstrings

* Rename EditHistory.reset() to EditHistory.clear()

* Add docstring to an exception

* Add a pause after focus/blur in a test

* Forcing CI colour

* Update focus checkpoint test

* Try to force color in pytest by setting --color=yes in PYTEST_ADDOPTS in env var on Github Actions

* Add extra assertion in a test

* Toggle text_area has focus to trigger checkpoint in history

* Apply grammar/wording suggestions from code review

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

* Making max checkpoints configurable in TextArea history

* Improve a docstring

* Update changelog

* Spelling fixes

* More spelling fixes

* Americanize spelling of tab_behaviour (->tab_behavior)

* Update CHANGELOG regarding `tab_behaviour`->`tab_behavior`

---------

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
2024-02-14 13:11:14 +00:00
Will McGugan
71d5f79c3f lock file 2024-01-29 17:17:25 +00:00
Darren Burns
32ea6ec2c0 Update Rich 2024-01-18 13:29:09 +00:00
Darren Burns
43ecfb66ef Dependency update 2024-01-18 13:18:35 +00:00
Darren Burns
b69d3c3da4 Merge branch 'main' of github.com:Textualize/textual into text-area-wrapping-widget-changes 2023-12-28 16:18:11 +00:00
Branch Vincent
f01d31ca01 drop importlib-metadata 2023-12-13 18:57:29 -08:00
Darren Burns
d43ed2f3a3 Merge branch 'main' of github.com:Textualize/textual into text-area-wrapping-aware-cursor-navigation 2023-12-12 11:37:39 +00:00
Will McGugan
a2a6f56cec docs fix (#3841) 2023-12-09 12:12:46 +00:00
Darren Burns
5603a4da2b Fix GH Actions, remove Python 3.7, re-enable MacOS, remove old dev dependency (#3766)
* Fixing pytest running on incorrect Python version in GitHub actions.
Also removes 3.12 from the testing matrix, and enables MacOS again.

* Dropping Python 3.7

* Update required Python version to ^3.8

* Remove 3.7 asyncio compatibility layer

* Version pinning in GitHub Action
2023-11-29 14:05:25 +00:00
Darren Burns
8cef051c51 Initial wrapping 2023-11-20 12:27:52 +00:00
Darren Burns
0a61a41c4f Add notes, update lockfile for new Rich, skeleton of WrappedDocumentView 2023-11-16 15:19:27 +00:00
Will McGugan
c0f299b593 input restriction (#3657)
* input restriction

* types

* tweak

* tests

* docstring

* fix lock

* words

* add valid empty

* another test

* fix regex

* doc

* name change

* Fix regex

* force initial value

* force reactive

* test fix

* add plus

* input type literal

* export InputType
2023-11-10 16:16:42 +00:00
Will McGugan
f0fd8d47e1 bump lock file (#3643)
* bump lock file

* pin aiohttp

* drop 3.12 for now

* try bump setup-python

* drop 3.7

* bump aiohttp

* lock

* drop macos
2023-11-07 14:37:31 +00:00
Darren Burns
d2320f11fc Move tree-sitter and tree_sitter_languages to optional extras (#3398)
* Move tree-sitter and tree_sitter_languages to optional extras

* Update docs and GitHub action for moving syntax to extras

* Updating, remake lockfile

* Update snapshots from textual-dev change

* Improve warning when a language is set but tree-sitter not available

* Update CHANGELOG

* Add note on syntax extras

* Update lock
2023-10-09 10:57:13 +01:00
Dave Pearson
f75bdc19da Upgrade to textual-dev 1.2.x 2023-09-28 14:02:27 +01:00
Darren Burns
bbde62fc57 Text area (#2931)
* Add docstring and switch to tree-sitter-languages wheels - although the wheels arent working

* Adding highlights files

* Fix index error on SyntaxAwareDocument

* Narrowing highlighting scope

* Adding basic highlights for Markdown

* Using utf-8 byte length instead of codepoint count in syntax aware doc

* Start creating an ABC defining functionality required by Document impls

* Simplify tree-sitter logic

* Extracting more ABC

* Fix width calculation, add SyntaxTheme

* Ensure the highlight line style goes right to the very end

* Updating a docstring

* Renaming, and adding document width guide

* Ensuring that line number column toggling refreshes virtual size

* Ensuring that line number column toggling refreshes virtual size

* Width guide

* Fix focus event stopping

* Use release_mouse

* Improving a docstring

* Remove bash

* TextArea language snapshot testing

* Updating snapshots for TextArea since we now highlight more nodes

* Typing fixes

* Testing

* Adding tests

* Fixing language selection

* Refresh size on indent width change

* Testing, renaming, fixing display of selection

* Fix multibyte highlight glitch

* Fix deleting right with selection at end of document in TextArea

* Fixing utf-8 multibyte character issues

* Default location of text insertion is cursor position, add cursor_location properties

* Removing some debugging code

* Cursor location tests

* Updating snapshots

* Cached utf8 encoding

* TextArea selection snapshot testing

* Tidying docstrings and queries

* Updating selection snapshot output

* Binding for ESC to shift focus

* Only build the tree-sitter query once!

* Expand cursor scroll horizontal leeway in TextArea

* Property setter for cursor_location in TextArea shouldnt return value

* Avoiding NamedTuple subclassing - using type aliasing instead

* Tidying API, docstrings etc.

* Tidying the API and docstrings

* TextArea additional cursor tests

* Testing pageup and pagedown in TextArea

* Fix a faulty test

* Docstring in a test for TextArea edit

* Stop using DEFAULT_SYNTAX_THEME

* Docstrings

* Change cursor_destination to move_cursor, add more tests

* Remove faulty assertion

* Tidying cursor movement

* Tidying up, adding docstrings for component classes

* Fix a broken selection test

* Remove some unused highlighting machinery

* Fix some Python highlighting issues

* Make HTML syntax highlight nicely

* Create tag name for mismatching HTML end tag

* Add styling for YAML, update boolean styling

* Stylising toml types

* Styling floats

* JSON syntax highlighting

* Updating snapshots

* Syntax highlighting datetimes in TOML

* Namespace TOML errors in highlighting

* Add a move_cursor_relative method

* Update TOML TextArea snapshot for datetime highlighting support

* Adjusting selections

* At TextArea widget level, delete_range is insert_range of empty string

* Refactoring

* Dunder all, docstring fix

* Fix XFAIL

* Remove unused import

* More tests, tidying up

* Cleaning the API

* Docstrings for TextArea

* A bunch of docstrings, delete unused code

* More tidying and docstrings

* Cursor origin on document load, correctly handle delete word left/right when selection is non-empty, fix delete_line when selection spans multiple lines and is in reverse direction

* Moving things around

* Fixing dunder all to export DocumentBase

* Add docstring

* Record cursor width on programmatic insert since it can result in the cursor moving

* Typing fixes

* Fixing remaining typing issues with TextArea

* Add tree-sitter-languages stubs and fix typing issues in documents

* Fixing remaining typing issues with document

* Updating Syntax themes

* Improve highlighting, add initial TextArea docs page

* Add TextArea indent note

* Start TextArea guide inside reference

* Add TextArea to widget gallery

* Fleshing out TextArea docs

* Add note

* Fix TextArea programmatic insert/cursor interaction

* Improve a test

* Testing replacement within selection

* Testing double-width character keyboard navigation and deletion keybinds with active selections

* Testing "delete to start of line" TextArea binding

* Testing TextArea delete line methods and delete to end of line

* Testing shift selecting using keyboard in vertical direction

* Expand tests for home and end keybinds in TextArea

* Renaming tests, testing empty replace and insert

* Testing delete word left via API

* Testing delete word left via API

* Testing delete_word_left with tabs, and delete_word_right

* Remove unused variables

* Remove debugging width guide

* Fix snapshot report path

* Deleting word left/right interaction with line ends fixes, ensure cursor width recorded on all edits

* Docstring fixes

* Unpin textual snapshot library dependency (issue is fixed)

* Docstring fixes

* Fix recording cursor width

* Fix a docstring

* Add select_all to TextArea

* Remove unused tree-sitter stuff from .gitignore

* Line select

* Make word pattern private in TextArea

* Add blinking cursor to TextArea

* Renaming, adding missing return typing

* Add selection bindings

* Moving cursor left/right by word while selecting

* Change escape keybind description, TextArea

* Stripping whitespace when going word left/right

* Add missing annotation

* Cursor word right and left parity with PyCharm

* Use repaint=False for cursor blink

* Improve focus/blur styling

* A whole bunch of TextArea testing

* Simplify delete_left and delete_right

* Testing hiding line numbers in snapshot

* Adding snapshot test for unfocus styling

* Create initial snapshot for text-area unfocused

* Support shift+home, shift+end

* Document shift+home, shift+end

* Add Dracula syntax highlighting theme

* Small change to delete_line behaviour when multiple lines selected to match vscode/pycharm behaviour

* Add test for new delete line logic

* Delete line improvement

* Add extra test for delete_line multiple selection

* Test cursor "smart" home behaviour

* Fix typo

* Highlight matching brackets

* Update snapshot

* Update snapshot

* Fix xfails

* Simplify delete_word_left

* Catch correct exception to ensure support for Python 3.7

* Add styling for Markdown

* Add styles for Dracula for Markdown

* Remove unused _fix_direction.py

* Add docstring to EditResult

* Use default=0 in max inside Document

* Remove redundant actions

* Use cell-width aware expand tabs implementation from @willmcgugan

* Construct strip with cell length

* Some TextArea keyword-only arguments

* Begin moving over to TextAreaTheme #skipci

* Prepare queries inside document #skip-ci

* Add comment

* Refactoring

* TextAreaTheme styling

* Setting width of blank selected lines

* Building the highlight map in the text area

* Remove unused default css from TextArea

* Moving highlighting stylize into widget

* Moving syntax highlighting into TextArea widget

* Remove unused code

* Optimise imports

* Fix highlighting when initial text supplied to TextArea

* Rebuild highlight map when the theme changes

* Extending

* Restore themes

* Remove old comment, fix docstring

* Fixing docstrings

* Fixing mypy

* Fixing mypy issues in document

* Tidying things

* Updating version

* Add theme

* Fix VSCode theme bracket matching

* Only match brackets when theres no selection

* Highlighting tidying

* Fix markdown header highlighting

* Setting theme correctly in background

* Tidying module interface

* Merging main

* Fixing a bunch of typing problems

* Fixing more typing problems

* Correctly setting theme object

* mypy

* Small fix to bracket matching

* Improve a docstring

* Fix docstring

* Testing builtin and custom languages

* Unit testing theme stuff

* Reworking themes

* Error handling

* Improve error message

* Testing new theme setting approach, error handling

* Improvements/tests for theme and language setting

* Remove unused TextArea unfocus snapshot

* Update snapshot file

* Adding theme snapshot tests

* Add `function.call` style binding in dark vscode theme

* Renaming a test file

* Making active line clearer on vscode theme

* Renaming tests

* A whole lot of docs for TextArea

* Update wording in docs

* A bit more docs

* Example on adding Java as a custom language

* More custom language docs

* Finishing up custom themeing/syntax highlighting guide for TextArea

* Add note on potential issue

* Fix wording

* Add note on Apple Silicon Python 3.7 fallback

* Add another note on Apple Silicon Python 3.7 fallback

* Fix class names in example files

* Add some documentation for useful TextArea APIs

* TextArea docs improvements

* TextArea docs typo fix

* Note about extending TextArea

* Tab-stop support when spaces used for indent

* Docs update

* Text area blog post (#3356)

* Start blog post

* Add demo script to blog post

* Continuing the blog post

* Yet more writing for TextArea blog post

* Working on closing section

* Finishing up

* Update docs/blog/posts/text-area-learnings.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/blog/posts/text-area-learnings.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Typo fix

* Update docs/blog/posts/text-area-learnings.md

Co-authored-by: Dave Pearson <davep@davep.org>

---------

Co-authored-by: Dave Pearson <davep@davep.org>

* Remove redundant pass

* Add docstring

* Docs fix

* Simplify docs

* Improve docstring

* Add links in docstrings

---------

Co-authored-by: Dave Pearson <davep@davep.org>
2023-09-21 11:10:14 +01:00
Will McGugan
26ba3b15b9 Update lockfile (#3341) 2023-09-18 13:31:45 +01:00
Dave Pearson
1fcf259e6d Merge branch 'main' into M-x 2023-09-04 16:40:32 +01:00
Will McGugan
229b8c4c7c fix updating CSS on push_screen (#3218)
* fix udpating CSS on push_screen

* changelog

* lock file
2023-09-04 10:53:45 +01:00
Dave Pearson
6a73a2dce4 Update the pytest snapshot test library 2023-08-29 11:29:15 +01:00
Dave Pearson
1b1e26cd16 Merge branch 'main' into M-x 2023-08-28 08:30:41 +01:00
Will McGugan
2519063389 version bump (#3181)
* version bump

* changelog

* snapshot update
2023-08-26 17:19:13 +01:00
Dave Pearson
67864c70ca Downgrade the snapshot test library again
Just so I can get the failure report.
2023-08-21 11:20:19 +01:00
Dave Pearson
85beb6ef48 Unpin the snapshot test library
This was pinned by Darren a wee while back, I think, due to some other
problem. But this kills coverage. Right now I want coverage so I can see
what needs testing with the command palette. So let's unpin with a view to
pinning back again (or solving the main problem I guess) once I'm done.
2023-08-14 15:47:42 +01:00
Dave Pearson
c65193cf27 Relock for textual-dev update 2023-08-06 07:57:11 +01:00
Will McGugan
879c985296 Rich log (#3046)
* log

* tests

* snapshot tests

* change to richlog

* keep raw lines

* disable highlighting by default

* simplify

* superfluous test

* optimization

* update cell length

* add refresh

* write method

* version bump

* doc fix link

* makes lines private

* docstring

* relax dev dependancy

* remove superfluous code [skip ci]

* added FAQ [skipci]

* fix code in faq [skipci]

* fix typo

* max lines fix
2023-08-03 10:11:17 +01:00
Dave Pearson
ca8eb3df7b Notifications (#2866)
* Add a notification class and a class to hold notifications

This provides the core classes for holding information on a single
notification, and then on top of that a class for managing a collection of
notifications.

* WiP: End of day/week commit to pick up post-holiday

* Ask permission rather than forgiveness

Yes, this does go against all things Pythonic, but in this case it's likely
less costly to do the check first; moreover it works around the problem I
ran in to: https://github.com/Textualize/textual/issues/2863

* Move the handling of "I've seen this" into the toast rack

This way the interface becomes "here's a bunch of notifications, you go work
this out".

* Add a notify method to all widgets

* The removal time for a toast should be the time left

When it was per-screen, it made sense that it was the timeout; now that
we're carrying them over between screens we're going to make sure they're
only around for as long as they need to be.

* Carry notifications between screens

* Remove the test code

* Drop the borders from the toasts

Except for the title, keep that.

* Provide access to the notification timeout

* Remove the title panel from a Toast if the title is empty

* Make the Toast CSS classes "private"

Prefix with a - to reduce the chance of a clash with userspace.

* Refresh a docstring

* Stop widget leakage

The Toasts were removing themselves, but they're wrapped inside a helper
container that keeps them aligned right. So the problem was that the
alignment containers were leaking. This ensures that when a Toast goes away
it takes its parent with it.

* Make the alignment container hidden

This doesn't really make any difference, but it feels like it makes sense to
hide it if there's nothing to show -- it's purely for alignment.

* 🚚 Rename the toast container

This is about getting the toasts to align correctly (even when you do align
things, they don't really align as expected due to the way that a container
aligns the bounding box of all if its children, not the individual
children). However, I had this named after where it aligned them to; someone
using the system may wish to change that, so let's make the name more
generic.

* Improve ToastRack._toast_id

Add a docstring, and also change the format of the identity somewhat so that
it's even "more internal".

* Add some initial low-level notification testing

* Add initial testing of notifications within an application

* Add tests for notifying from the 3 main levels within the DOM

* Add a toast example to the docs and a snapshot test

This might not be the final form, but it'll do for the moment. I want to get
the snapshot test in place at least.

* Add a snapshot test for notifications persisting between screens

* Add some documentation for a Toast

This isn't going into the index, just yet. This is *technically* an internal
widget so I'm not sure how and where it makes sense to document it; if at
all. But let's get some documentation in here anyway.

* Flesh out the docstrings for the notify methods

* Add a missing docstring to the Notifications __init__ method

* Add snapshot tests for persisting notifications through mode switches

* Remove unused import

Looks like eglot/pyright tried to be "helpful" at some point and I didn't
notice.

* Correct the Toast severity level classes in the docs

Originally they weren't in the "internal" namespace, then I decided that
they should be so there's less chance of a clash with dev-space code; but I
forgot to reflect this in the docs.

This fixes that.

* Make the removal of notifications/toasts a two way thing

The addition of the ability to dismiss a toast by clicking on it had a flaw:
the notification->toast code had been written with things being one way. The
expiration of notifications happened in the notification handler, and the
expiration of Toasts was done in the Toast system, on purpose (notifications
might end up being routed via elsewhere so this needs to be done).

But... this meant that hand-removed Toasts kept coming back from the dead
when a new notification was raised iff the hand-removed ones hadn't yet
expired.

So here I add the ability the remove a notification from the notification
collection.

* Remove an unhelpful comment

Sort of a hangover from what was initially looking like it was going to be a
longer body of code. It doesn't really need explaining any more.

* Add in support to the notification collection

* Change the toast rack adder to be a general "show" method

This turns the method into one that further aids making the connection
between the notifications and the toasts two way. Now it makes sense that if
there are toasts for notifications that no longer exist, they also get
removed.

This makes it easier to add all sorts of clear options later on.

* Add a method to clear notifications

* Add an App method for clearing all existing notifications

* Add a missing docstring to _refresh_notifications

* Return the notification from the notify methods

It can be seen as, and used as, a handle of sorts (see unnotify); so return
it so people can use it.

* Add some more notifications unit testing

* Add some more app-level notification unit testing

* Style tweaks

* docs

* added notifications

* snapshots

---------

Co-authored-by: Will McGugan <willmcgugan@gmail.com>
2023-07-17 11:47:17 +01:00
David
4d699c8364 Fix Toggle Buttons on a selection list (#2930)
* Fix Toggle Buttons on a selection list

* Update CHANGELOG.md

* Update dependencies

Mainly updating the now-external snapshot testing code so that the failure
report (which was to be expected) gets generated.

* Update snapshot tests

* Add testing for clicking on a SelectionList prompt or checkbox

* Cody tidy

---------

Co-authored-by: Dave Pearson <davep@davep.org>
2023-07-17 11:33:09 +01:00