Skip to content

Tree updates #5023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Sep 23, 2024
Merged

Tree updates #5023

merged 14 commits into from
Sep 23, 2024

Conversation

willmcgugan
Copy link
Collaborator

@willmcgugan willmcgugan commented Sep 19, 2024

  • Updates to the Tree control
  • Additional ansi colors styles for tree / screen

@willmcgugan
Copy link
Collaborator Author

@darrenburns This isn't ready for a full review, but could you give your thoughts on this? It adds more keybindings to navigate the tree.

Copy link
Member

@darrenburns darrenburns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some thoughts

@@ -484,8 +519,23 @@ class Tree(Generic[TreeDataType], ScrollView, can_focus=True):
ICON_NODE_EXPANDED = "▼ "

BINDINGS: ClassVar[list[BindingType]] = [
Binding("shift+left", "cursor_parent", "Cursor to parent", show=False),
Binding("shift+right", "cursor_parent_next_sibling", "Cursor out", show=False),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cursor_next_ancestor maybe?

I'm not understanding "Cursor out" here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of something like a debugger, when you step in , step out.

I like cursor_next_ancestor for an internal name. Maybe "move the cursor to the next ancestor" for the description?

Binding("enter", "select_cursor", "Select", show=False),
Binding("space", "toggle_node", "Toggle", show=False),
Binding("x", "toggle_expand_all", "Expand or collapse all", show=False),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we added a single character keybind previously we quickly received feedback that it was clashing with apps and we removed it.

Is "toggle expand all" a common enough action in the real world to justify this binding? Maybe we should leave it unbound?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe. I actually wanted "shift+space", but I can't seem to bind that. If I can get shift+space working, I feel that would be better. Its still toggling, but a larger scope.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed shift+space. Turned out to be an issue with the inline driver.

@TomJGooding
Copy link
Contributor

I hope you don't mind me also chiming in. Perhaps this isn't a major concern, but I just wanted to mention that some terminal emulators might not support the new Shift and arrow key bindings. For example, looking back at the previous review of keys and escape sequences, shift+up/down in the Apple Terminal might simply send up/down instead (but I don't have access to a Mac to test this on the latest version of Textual).

@willmcgugan
Copy link
Collaborator Author

I tested in terminal.app and it supports them. Of course that's no guarantee they are supported everywhere, but I can test some others.

@darrenburns
Copy link
Member

I think shift plus arrow keys are well supported (tested that during the TextArea stuff as it also uses them).

@willmcgugan willmcgugan changed the title WIP tree updates Tree updates Sep 23, 2024
@willmcgugan willmcgugan merged commit 065ca29 into main Sep 23, 2024
20 checks passed
@willmcgugan willmcgugan deleted the tree-tweaks branch September 23, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants