Skip to content
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

Show window titles #4110

Closed
xiangpeng2008 opened this issue Oct 10, 2021 · 52 comments
Closed

Show window titles #4110

xiangpeng2008 opened this issue Oct 10, 2021 · 52 comments

Comments

@xiangpeng2008
Copy link

xiangpeng2008 commented Oct 10, 2021

Hi Kovid,

I'm just coming to kitty from tmux, because tmux doesn't currently support image printing while kitty could https://sw.kovidgoyal.net/kitty/graphics-protocol/.

Very often, I have multiple similar windows under same tab, which serve for similar but not exactly same jobs. And it's important for me to know which is which. With tmux (https://stackoverflow.com/a/37602055) I usually set each of the window a unique name. And show them on the bottom like below (I named them as "python 1" and "python 2"):
Screenshot 2021-10-10 at 9 09 57 PM

But I didn't find this option in Kitty, do you think it worths to have this ?

Thanks,

Xiangpeng

@kovidgoyal
Copy link
Owner

No, I dont think so. In tmux it makes sense to do this as in tmux the
dividers use a cell height worth of pixels. In kitty they are only a few
pixels high so you cant have titles in them. You can however set window
titles, and the currently focused window's title will be show in the tab
bar.

@xiangpeng2008
Copy link
Author

Thanks for your quick reply.

I see. So we can't put them on the dividers.

But to get all window titles from tab bar requires me to loop the focus on all windows, which is not very practical.

It would work out if there's a command to print all window title on top of each window. Like this, but not just number

Screenshot 2021-10-10 at 10 08 39 PM
Or even if we could print the number, I could get the title by mapping "kitty @ ls" info.

Do you think it's worth to be able to show window title or window number on top of each window ?

Thanks

@kovidgoyal
Copy link
Owner

kovidgoyal commented Oct 10, 2021 via email

@xiangpeng2008
Copy link
Author

How would you know the number of a specific window ?

@kovidgoyal
Copy link
Owner

kovidgoyal commented Oct 10, 2021 via email

@xiangpeng2008
Copy link
Author

I fully understand that it may not worth the effect to you as you may never need this.

On tmux press a key to display the numbers, then press the number "immediately" would focus the window, so it'
s still OK in terms of efficiency.

I find that the numbers could be a bit mixed if I do some

Move window forward ctrl+shift+f
Move window backward ctrl+shift+b

Which I do have to do so some times as I need to put the major working window in the biggest pane, and the major working window could change.

Thanks again for your help. Maybe I need to work around "Control kitty from scripts" to find another approach of my practice.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Oct 10, 2021 via email

@kovidgoyal
Copy link
Owner

I had a little time so I decided to implement the numbers over windows to select function.

@xiangpeng2008
Copy link
Author

what a great surprise !

Showing number together with window title would be best of best :)

But showing number alone is also the best

@xiangpeng2008
Copy link
Author

Is this implementation integrated in latest release that I could download and experiment ?

@kovidgoyal
Copy link
Owner

@xiangpeng2008
Copy link
Author

It's so strange, I got

iMac /Users/xiangpeng/Downloads $ curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin     installer=nightly dest=/Users/xiangpeng/Downloads/kitty
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  8606  100  8606    0     0   420k      0 --:--:-- --:--:-- --:--:--  420k
Using python executable: /usr/local/bin/python3
Could not read from: /Users/xiangpeng/Downloads/nightly

Screenshot 2021-10-12 at 10 12 47 PM

@kovidgoyal
Copy link
Owner

that's because the released version of the installer has not been
updated for nightly builds yet, use

https://github.com/kovidgoyal/kitty/raw/master/docs/installer.sh

as the installer url instead

@xiangpeng2008
Copy link
Author

xiangpeng2008 commented Oct 12, 2021

great, this url works to install a new kitty
what should I do to show the window numbers and press key to focus ?
I'm too bad, I looked at your commit but I don't know how let kitty run "focus_visible_window" ...

I tried Ctrl+Shift+f7, which didn't work.

Actually I have a general question:
this is the mapping for previous_window
map ctrl+shift+[ previous_window
Is there anyway I just type "previous_window" to go to previous window ? In case I don't know the keyboard shortcut.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Oct 12, 2021 via email

@xiangpeng2008
Copy link
Author

ctrl+shift+f7 doesn't work ...
But cursor is well changed
I remembered it was fatter block
Screenshot 2021-10-12 at 11 35 27 PM

@kovidgoyal
Copy link
Owner

You need to have more than one visible window for it to work. And read the changelog for all the other changes. #3948

@xiangpeng2008
Copy link
Author

wow, so nice

I see for kitty @ send-text --match option, we could match "num" as well.
I tried several times on different tab, and I saw it would match the num on same tab, this is always the case right ?
( This is what I want )

There's another small thing that I observed that the "num" starts from 0, while window number with Ctrl+Shift+F7 starts from 1, is this intended ?

Screenshot 2021-10-12 at 11 41 12 PM

@kovidgoyal
Copy link
Owner

kovidgoyal commented Oct 12, 2021 via email

@xiangpeng2008
Copy link
Author

yes because of the layout of the number keys on the keyboard, you dont want first window to be at the right end and second to be at the left.

Understood, as long as we have always num == nb_window - 1, it's totally fine for me, I will wrap that on my side

But I just saw something strange, the

Move window forward ctrl+shift+f

doesn't look to work properly, or maybe my understanding is wrong.

First:
Screenshot 2021-10-13 at 12 02 48 AM

After pressing 1 time ctrl+shift+f

Screenshot 2021-10-13 at 12 03 24 AM

We could see the window number changed as expected, but the window didn't change, as we see "echo 1" is still on top-left and "echo 2" is still on bottom-left. Is this expected ? I thought the window should move together with window_number before.

@kovidgoyal
Copy link
Owner

The number doesnt refer to a window, it refers to a slot in the layout.

@xiangpeng2008
Copy link
Author

I'm not with my personal machine right now, but I remember with Tall layout "Move window forward" moves really window, not just the number, but the Splits layout here is not the case. I will confirm that this night.

@page-down
Copy link
Contributor

I'm not with my personal machine right now, but I remember with Tall layout "Move window forward" moves really window, not just the number, but the Splits layout here is not the case. I will confirm that this night.

I cannot reproduce the problem you are describing.

  • move_window_forward will move the window correctly.
  • The order of the numbers in each layout is fixed in all cases. Logically, it does not change due to any operation.

I tried this feature and it is very convenient. Is it possible to support numeric keypad? I quite like the separate numeric keypad on my left hand side. :)

@page-down
Copy link
Contributor

Sorry, is this a little off topic? Since it's already been discussed here, I'll make two more suggestion.

If the focus is switched using a mouse click while the numbers are displayed, can we assume that the user has made a selection and hide the number display? Although no keyboard keys are pressed.

It would be nice to be able to use this function to also learn about the windows in the layout of the stack type. For example, a quick preview of the windows (maybe titles only) present in the stack and displaying the numbers.

I can understand the need for the title proposed in this post. It would be convenient to list the titles of the windows in stack mode and switch between them with numbers.

@xiangpeng2008
Copy link
Author

If the focus is switched using a mouse click while the numbers are displayed, can we assume that the user has made a selection and hide the number display? Although no keyboard keys are pressed.

what's the point to mouse click while the numbers are displayed ? You could mouse click without number are displayed. It would be more convenient to type number key in my opinion.

@xiangpeng2008
Copy link
Author

But the stack thing do sound interesting, especially when we work on laptop. We want stack layout as screen is single and so small

@page-down
Copy link
Contributor

If the focus is switched using a mouse click while the numbers are displayed, can we assume that the user has made a selection and hide the number display? Although no keyboard keys are pressed.

what's the point to mouse click while the numbers are displayed ? You could mouse click without number are displayed. It would be more convenient to type number key in my opinion.

It just refines the UX that for overlays that expect user input, a mouse click is also an input. For the case of expecting keyboard input only, it (mouse click) can be considered equivalent to ESC.

This overlay should disappear after a mouse click. The current situation is that the focus is switched after the mouse click (not due to this feature), but the overlay is still there.

@xiangpeng2008
Copy link
Author

I just checked
When layout is "Tall", ctrl+shift+f only change window position, the number for same position ( but not for same window) doesn't change.

Screenshot 2021-10-13 at 9 58 53 PM
after ctrl+shift+f: "echo 1" goes from left to right top, but numbers are not changed for same position.
Screenshot 2021-10-13 at 10 00 52 PM

@kovidgoyal
Copy link
Owner

The point of this feature is, you press the number for the position you want to go to. It doesnt matter what the number is. If you want to always go to some specific window use its id or title.

@kovidgoyal
Copy link
Owner

See 533b0ed

@page-down
Copy link
Contributor

See 533b0ed

Thanks, that works great, and the stack layout now allows for quick window selection as well. The numeric keypad also works fine.

However I have noticed a difficulty, how can I turn the page of this list? When the list exceeds the height of the window. Currently, pressing the page down key, etc. does not turn the page.

kitty --config=NONE -o initial_window_height=5c -o remember_window_size=no -o allow_remote_control=yes bash -c "kitty @ goto-layout stack; for i in {1..7}; do kitty @ launch; done"

After starting kitty at a shorter height, create multiple windows under the stack layout and press ctrl+shift+f7

@kovidgoyal
Copy link
Owner

There isn't any way to do that, if you want to do that you will need to
implement a proper kitten to do it instead of using the hints kitten as
is done now.

@xiangpeng2008
Copy link
Author

The point of this feature is, you press the number for the position you want to go to. It doesnt matter what the number is. If you want to always go to some specific window use its id or title.

This works for me. I can try wrap on my side to get ID by inputting window number and stick to ID.

As showed here : #4110 (comment)
Move window forward doesn't work for "Splits" layout, (only num is moved, not window) is there any existing method to move window on "Splits" layout like the way on "Tall" layout ?

IMO "Splits" is the most flexible layout that it could make up any other layouts (maybe not Stack) by properly splitting and resizing.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Oct 14, 2021 via email

@xiangpeng2008
Copy link
Author

xiangpeng2008 commented Oct 14, 2021

On Tue, Oct 12, 2021 at 08:23:47AM -0700, xiangpeng2008 wrote: great, this url works to install a new kitty what should I do to
Actually I have a general question: this is the mapping for previous_window map ctrl+shift+[ previous_window Is there anyway I just type "previous_window" to go to previous window ? In case I don't know the keyboard shortcut.
no

Do you think it make sense to enable kitty remote control to do jobs which could only been currently done with Shortcut ?
For example when I'm focusing window num 2, I could send a system command like
kitty @ action --match num: 3 move_window_to_top
which eventually does

  1. I focus num 3
  2. I press ctrl+shift+`
  3. I focus back to num 2

This could enable more automation and customizing on kitty control to do which could only been done previously with Keyboard Shortcut.
For example, if I need to do above action a lot, then I could just map a new shortcut like
map ctrl+p>3 kitty @ action --match num: 3 move_window_to_top

@xiangpeng2008
Copy link
Author

See https://sw.kovidgoyal.net/kitty/layouts/#the-splits-layout

Is there a specific reason
only move_window + [ left, right, up, down ] works for "splits", while move_window_forward or backward doesn't ?

It seems we are separating "splits" and other layouts here:
https://github.com/kovidgoyal/kitty/blob/master/kitty/tabs.py#L562-L567

But seeing any layouts except "stack" could be constructed by "splits" would it make sense to make "splits" as super class of all other layouts except "stack" ?

Also currently "move_window_to_top" doesn't work with "splits" layouts. Besides could we make swap_windows https://github.com/kovidgoyal/kitty/blob/master/kitty/layout/splits.py#L70 operable with keyboard shortcuts ? Like swap_window 1 2 would swap windows 1 and 2.

@kovidgoyal
Copy link
Owner

Because there is no forward and backward in a split. Nor is there a top.

@xiangpeng2008
Copy link
Author

Because there is no forward and backward in a split. Nor is there a top.

Could we give the windows order according to order of creations ?

@kovidgoyal
Copy link
Owner

You could, but what would be the point? Unless you memorise the order of
creation, it will just jump to random places.

@page-down
Copy link
Contributor

Sorry I haven't looked at the code closely enough, but is the structure of splits a tree? If it is a tree, and each branch may be vertical or horizontal, then just move the leaf nodes between the different tree nodes in a logical order.

For example, if it is horizontal, it moves the position back and forth horizontally first, and if it is already in the first place and still moves backward, it moves to the node in the upper level. Vertical ones move up and down.

For top, it is possible to move to a node on the upper tree level, moving up one level for each execution.

If the structure is not tree-like, then there is really no meaningful way to do it.

@kovidgoyal
Copy link
Owner

It is tree like, but I don't see navigating the branches of a tree in
that fashion as being meaningful. The problem is that windows are visual
things, and forward/backward/top make some sense for linear visual
structures (which the other layouts are) but not really for tree like visual structures.

You typically move focus to get to some place. In the splits it is not
at all obvious what sequence of movements will get you to a window,
unless you have the tree structure in front of you, which you dont in
kitty, since a given visual window layout can correspond to many
different underlying tree structures.

@xiangpeng2008
Copy link
Author

xiangpeng2008 commented Oct 16, 2021

You could, but what would be the point? Unless you memorise the order of creation, it will just jump to random places.

Sorry, order of creations may not be good.

But what @page-down said makes sense to me. It would be quite natural for a user to know which window comes first.

For example :

Below image is already a complex splits, but when we move window 2 forward, it's very natural to know that it would go to window3, and window 3 goes to 4, etc.

image

@page-down
Copy link
Contributor

page-down commented Oct 16, 2021

it's very natural to know that it would go

Not really, because any window can be split in two in kitty. And those hidden virtual groups are not visible and have no borders.

Because the current structure of splits is so free, it doesn't make sense to move nodes around. And it's a visual problem.

Unless a very simple structure is introduced, that is, when doing a split, the window is actually added to the parent virtual group.
A new virtual group is created only when the direction of the split is different from the parent.

- group[v]
  - window-1
  - group[h]
    - window-2
    - window-3 <-- hsplit

- group[v]
  - window-1
  - group[h]
    - window-2
    - window-3
    - window-4 <-- (new)

When creating windows with different directions, create a new virtual group and set the split direction.

- group[v]
  - window-1
  - group[h]
    - window-2
    - window-3 <-- vsplit (does not match parent group "horizontal")

- group[v]
  - window-1
  - group[h]
    - window-2
    - group[v] <-- (new)
      - window-3
      - window-4 <-- (new)

Yet this still does not solve the visual problem.

For example, if you have a layout of 4 windows, how do you know how they will move when you execute move forward? The split direction and virtual group boundaries are not shown on the screen.

- group[h]
  - group[v]
    - window-1
    - window-2
  - group[v]
    - window-3
    - window-4

So to solve this problem is not something that can be done by simply moving. Because the result after pressing the shortcut is probably not what the user expects. The visual interface problem has to be solved first, otherwise it is meaningless to move blindly.

@xiangpeng2008
Copy link
Author

For example, if you have a layout of 4 windows, how do you know how they will move when you execute move forward? The split direction and virtual group boundaries are not shown on the screen.

- group[h]
  - group[v]
    - window-1
    - window-2
  - group[v]
    - window-3
    - window-4

So to solve this problem is not something that can be done by simply moving. Because the result after pressing the shortcut is probably not what the user expects. The visual interface problem has to be solved first, otherwise it is meaningless to move blindly.

This is a very special case, when there's a + shape cross on border. It's true that it's hard to tell between 1 and 2. But the point here it's not random for the user, and if user used to split windows in same way, like always h->2v or v->2h, then he knows the order of windows.
image
Besides above case could also appear like this, whose order is very clear
image

Btw instead of simply moving, switch could be more convenient on some user case, for example, when I have 3 monitors, and I want to use window 0 on left screen to view output, window 1 on middle screen for vim editing, and some opened window on right window. And when I want to read outputs of window 5, it would be convenient to just switch between window 0 and window 5.
image

@page-down
Copy link
Contributor

Btw instead of simply moving, switch could be more convenient on some user case, ..., it would be convenient to just switch between window ...

Yes, the current numeric overlay can clearly indicate the windows, so it is more efficient to swap with the current focus window instead.

I personally think this suggestion is more constructive. No more pressing the move forward and backward shortcuts multiple times either.

@kovidgoyal
Copy link
Owner

I have nothing against a visual switch, it's trivial to implemnent using
the same infra as for visual select.

@kovidgoyal
Copy link
Owner

this is now implemented in master

@page-down
Copy link
Contributor

Wow! This is a piece of art. Many thanks for your work. For the better, I have some suggestions for a different point of view and I hope you don't mind.

I really like the seven-segment numeric display. However, there are some balance and word weight issues from a typographic perspective. For example, the number 1 is not centered. (And it is also not appropriate to force centering in a seven-segment numeric display, as it is not logical.) Also the number 4 looks smaller than the other numbers because of the lack of top and bottom LEDs. In a world of monospaced fonts, is there a better way to display them? I don't know if there is a better way to display it with the least amount of effort.

When trying different layouts, I sometimes want to limit the layout used by the tab and the layout cycled by ctrl+shift+l. It would be more convenient to have a remote control command to set the layout that can be used on-the-fly.

We already have KeyAction('set_tab_title'), would you consider adding a KeyAction('set_window_title') to complement this functionality? Thanks.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Oct 17, 2021 via email

@page-down
Copy link
Contributor

...
You could obviously render the musing a font rather than a seven segment display, but I like the seven segment display. ...
...
I have no objection, though I also don't really have a need for it ...

Understand. I respect your valuable time. It is better to focus on more important things than to deal with these insignificant details.

@xiangpeng2008
Copy link
Author

wow, we have title now

Screenshot 2021-10-30 at 2 27 36 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants