drmargarido / TodoTreeView

Todo View for https://github.com/rxi/lite
MIT License
28 stars 3 forks source link

Toggle Focus #11

Closed itmitica closed 6 months ago

itmitica commented 6 months ago

Is it possible to add Toggle Focus, as TreeView has? I copied the function from TreeView but I was not able to make select element function work.

drmargarido commented 6 months ago

Searched a bit but didn't find the specific functionality with that name. Can you send some description and maybe screenshots of what is the expected behaviour from Toggle Focus?

itmitica commented 6 months ago

https://github.com/lite-xl/lite-xl/blob/master/data/plugins/treeview.lua#L660

Edit: Basically, a TodoTreeView: Toggle Focus command would put the focus on the TodoTreeView panel.

From there, using the UP and DOWN arrow keys, it would be possible to navigate the TODOs. Pressing ENTER when a TODO element has focus is the same with clicking the element when using the mouse.

If the focused element is a file, using the LEFT and RIGHT keys would Expand or Collapse the TODO entries for that file.

drmargarido commented 6 months ago

Got the main behaviour working in a branch with this commit https://github.com/drmargarido/TodoTreeView/commit/728dbcb5cc33aa23466c271ed9c75b4207d6094a. Still have to do some extra testing to fix some small issues and make sure everything works as expected. Will continue with that tomorrow.

drmargarido commented 6 months ago

Focus mode implemented and released in master for the TodoTreeView in the commit https://github.com/drmargarido/TodoTreeView/commit/e222f7074cae607dec82fb191a4fb077e75886e2

itmitica commented 6 months ago

There are two improvements to be made, from my tests.

The selected TODO entry remains visually distinct after pressing ENTER and after TodoTreeView loses focus. I think the entry should revert to the same color as the others in the list.

Pressing UP and DOWN does not scroll the list to keep up with the selected TODO when the list extends beyond screen height.

drmargarido commented 6 months ago

Ok, both issues solved in the most recent version. Commits https://github.com/drmargarido/TodoTreeView/commit/c4b951b66e0f7258b5f8c8458dc448d80b83d1b8 and https://github.com/drmargarido/TodoTreeView/commit/b06b893422ba1339f8d4eaf44dafafd3cca1723f

itmitica commented 6 months ago

Confirmed working as described.

One more enhancement I think should be added.

Right now, to shift focus away, the user must select a TODO, call TodoTreeView: ToggleFocus to return focus to the previous view, or just simply click away.

I suggest pressing ESC when TodoTreeView has focus, should also return the focus to the previous view.

drmargarido commented 6 months ago

Most people that will use the focus mode will probably bind some keys to the focus toggle command, so they will use that to return the focus to the previous view. But with that said it still makes sense to have the ESC key return the focus so I added it anyway with this commit https://github.com/drmargarido/TodoTreeView/commit/1a8b6cbe7d423ddb9a2cd29bca83a311e13ea28b

drmargarido commented 6 months ago

BTW, thanks for the feature idea and the tests to make sure everything works well :+1:

itmitica commented 6 months ago

Working as described.

Thank you for incredibly fast responses!