zellij icon indicating copy to clipboard operation
zellij copied to clipboard

utils/actions: Add user-friendly docs to `Action` variants

Open har7an opened this issue 3 years ago • 13 comments

that explain what every action does, what it serializes to in the config.yaml and whether it is meant for direct user-interaction in the first place.

Related to: #1562

har7an avatar Jul 07 '22 15:07 har7an

Some actions still lack documentation because I didn't know what they do... They have a ??? in the code now, I'd be happy to change that if someone explains to me what they do.

har7an avatar Jul 07 '22 15:07 har7an

What do you mean by direct user interaction?

a-kenji avatar Jul 10 '22 10:07 a-kenji

What do you mean by direct user interaction?

Users mostly interact with zellij by means of mouse clicks or key bindings. All key bindings execute one or more Actions. I for example added a shortcut to Scrollmode (G) that scrolls to the bottom of the scrollback. Trying to figure out how to scroll to the top I thought maybe ScrollAtPoint (or what it was called) may help me, but it doesn't cause any reaction. Reading the code I found out that this Action related to mouse clicks, but I don't think it can be expected by anyone wanting to play with this to read the source code.

Edit: I mean: The default key bindings are really just "suggestions". Nothing keeps me from adding my own, removing the ones that exist, rebinding them, adding more actions to them or removing actions, etc...

har7an avatar Jul 10 '22 16:07 har7an

Thanks for clarifying @har7an,

In that case I would say that Write and WriteChars are very handy for direct user interaction.

Also thanks for doing this, I think this can be valuable. I also think we shouldn't merge new actions, that don't have any documentation at all - in general.

I am not sure yet, if I like that we document the serialization here itself.

a-kenji avatar Jul 10 '22 17:07 a-kenji

In that case I would say that Write and WriteChars are very handy for direct user interaction.

Okay, I couldn't think of a direct usecase. But I can of course remove the "hints".

I am not sure yet, if I like that we document the serialization here itself.

Hm, I understand that, it looks "odd". But I wouldn't know where else to put it to keep it at least somewhat in sync with the code.

I would also offer to open a separate PR against the zellij docs repo that adds some explanations and examples so users know what to do with it. If you want that, of course. :)

har7an avatar Jul 10 '22 17:07 har7an

Okay, I couldn't think of a direct usecase. But I can of course remove the "hints".

It is for example used to send the prefix key in the default configuration. So if you are in a nested zellij session, you can use in the outer session ^b-^b to send ^b to the inner session.

Edit: Oops didn't mean to close it.

I would also offer to open a separate PR against the zellij docs repo that adds some explanations and examples so users know what to do with it.

I would like that, yes.

Hm, I understand that, it looks "odd". But I wouldn't know where else to put it to keep it at least somewhat in sync with the code.

I don't think it looks that odd, it just seems unnecessary. Just keep it that way for now, if it becomes a problem we can still remove it at some point.

a-kenji avatar Jul 10 '22 17:07 a-kenji

So if you are in a nested zellij session, you can use in the outer session ^b-^b to send ^b to the inner session.

Aha, I see. That's a clever idea, I never thought about nesting zellij sessions.

@a-kenji Would you mind explaining to me what the following actions do and maybe how to use them?

  • ScrollUpAt(Position)
  • ScrollDownAt(Position)
  • NewTab(Option<TabLayout>) - Here in particular I wonder whether the user can influence the TabLayout somehow? Or is this usable in keybindings only as NewTab(None)?
  • ToggleTab,
  • Copy

Then I can complete the code documentation and start working on the user documentation with examples etc.

har7an avatar Jul 11 '22 07:07 har7an

* `ScrollUpAt(Position)`

* `ScrollDownAt(Position)`

They fall under your definition of not likely to be used by most direct user interaction. This allows to scroll while selecting with the mouse.

* `NewTab(Option<TabLayout>)` - Here in particular I wonder whether the user can influence the TabLayout somehow? Or is this usable in keybindings only as `NewTab(None)`?

This takes a tab layout as an argument, meaning anything you can specify in the tab section of a layout. For example you can open a new tab that runs htop, bound to ^b-8.

https://zellij.dev/documentation/actions.html#newtab-tablayout

* `ToggleTab`,

This toggles between the two most recently used tabs. https://zellij.dev/documentation/actions.html#toggletab

* `Copy`

This copies the selection.

a-kenji avatar Jul 11 '22 12:07 a-kenji

@a-kenji Thanks for clarifying!

It seems that Run does execute a command but it doesn't open a new pane... Tried it with:

action: [Run: {cmd: "/usr/bin/ls", args: [], cwd: , direction: Right},]

I can confirm the command is executed (Used touch instead, that created a file) but I don't see any output.

har7an avatar Jul 11 '22 13:07 har7an

@har7an It opens a new pane, but if your command exits, it means there is nothing that the pane can display and it will close again.

You can try it with a command that will remain:

action: [Run: {cmd: "htop", args: [], cwd: , direction: Right},]

And if you close the command, it will also close the pane.

But you can always choose to keep a command there. For example running fish you can use:

cmd: fish
args: ["-C", "ls"]

That way you tell fish to run ls, and also open a shell. Because the shell is open the pane is open. You can try it out yourself when you have two normal panes open in zellij: Type exit into the shell of your choosing, the chance is high, that this will close your shell, that will likely also close the pane in zellij itself.

a-kenji avatar Jul 11 '22 13:07 a-kenji

@a-kenji Ah, that makes sense, thanks!

Should I also add some more detailed documentation to the types used by the Action variants? E.g. the documentation to RunCommandAction states only "Intermediate representation", but there aren't any examples or similar.

har7an avatar Jul 11 '22 14:07 har7an

Hey, what's the status of this?

imsnif avatar Sep 09 '22 07:09 imsnif

@imsnif Thanks for bumping this. Still waiting for feedback from @a-kenji on https://github.com/zellij-org/zellij-org.github.io/pull/150 which is meant to complement the changes proposed here. Completing one without the other will likely confuse a lot of users.

har7an avatar Sep 09 '22 12:09 har7an