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

Padding between top of window (or bottom of window) and tab bar #3247

Closed
jsphnecclia opened this issue Jan 15, 2021 · 21 comments
Closed

Padding between top of window (or bottom of window) and tab bar #3247

jsphnecclia opened this issue Jan 15, 2021 · 21 comments

Comments

@jsphnecclia
Copy link

Is there a way to configure a padding/margin between the top of the window and the tab bar (alternatively the bottom of the window and the tab bar, depending on the setting)?

@kovidgoyal
Copy link
Owner

@jsphnecclia
Copy link
Author

The tab bar ignores that setting. I mean space between the edge of the window and the tab bar, not the tab bar and the edge of the content of the window (i.e. the text).

@kovidgoyal
Copy link
Owner

Ah, in that case, no, there is no such setting.

@jsphnecclia
Copy link
Author

Ah. Well do you have any idea where a beginner programmer would look to make that change (making the tab bar be affected by the window_margin_width)?

@kovidgoyal
Copy link
Owner

this will be fairly involved. The tab bar is actually a kitty screen.
Margins around it would need to be rendered in the border OpenGL shader,
and the positioning of the tab bar window would need to be adjusted.

@jsphnecclia
Copy link
Author

Ah. Then could you point me to where the code for the set tab_bar_min_tabs option lies? And/Or the code for the tab bar in general?

@kovidgoyal
Copy link
Owner

tab_bar.py

@jsphnecclia
Copy link
Author

Duh, of course. Thank you

@jsphnecclia
Copy link
Author

How does one add a rc like set-background-opacity, set-window-title, etc? I thought it would be as simple as duplicating one file already in the rc folder, changing it, and then rebuilding -- but that doesn't seem to work. I get the error that the command is an unknown command

@kovidgoyal
Copy link
Owner

Adding a file to the RC folder is all you need to do. See the code in
rc/base.py for how they are loaded.

@jsphnecclia
Copy link
Author

Thats what I thought, but I can't get even a simple duplicate command recognized. I copied the file detach_window.py to toggle_tab_bar.py, and changed only the name - but kitty @ toggle-tab-bar returns command not found. Here is my toggle_tab_bar.py (detach_window.py duplicate with only the name changed):

from typing import TYPE_CHECKING, Optional, Union

from .base import (
    MATCH_TAB_OPTION, MATCH_WINDOW_OPTION, ArgsType, Boss, MatchError,
    PayloadGetType, PayloadType, RCOptions, RemoteCommand, ResponseType,
    Window
)

if TYPE_CHECKING:
    from kitty.cli_stub import DetachWindowRCOptions as CLIOptions


class ToggleTabBar(RemoteCommand):

    '''
    match: Which window to detach
    target: Which tab to move the detached window to
    self: Boolean indicating whether to detach the window the command is run in
    '''

    short_desc = 'Detach a window and place it in a different/new tab'
    desc = (
        'Detach the specified window and either move it into a new tab, a new OS window'
        ' or add it to the specified tab. Use the special value :code:`new` for --target-tab'
        ' to move to a new tab. If no target tab is specified the window is moved to a new OS window.'
    )
    options_spec = MATCH_WINDOW_OPTION + '\n\n' + MATCH_TAB_OPTION.replace('--match -m', '--target-tab -t') + '''\n
--self
type=bool-set
If specified detach the window this command is run in, rather than the active window.
'''
    argspec = ''

    def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType:
        return {'match': opts.match, 'target': opts.target_tab, 'self': opts.self}

    def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType:
        windows = self.windows_for_match_payload(boss, window, payload_get)
        match = payload_get('target_tab')
        target_tab_id: Optional[Union[str, int]] = None
        newval: Union[str, int] = 'new'
        if match:
            if match == 'new':
                target_tab_id = newval
            else:
                tabs = tuple(boss.match_tabs(match))
                if not tabs:
                    raise MatchError(match, 'tabs')
                target_tab_id = tabs[0].id
        kwargs = {'target_os_window_id': newval} if target_tab_id is None else {'target_tab_id': target_tab_id}
        for window in windows:
            boss._move_window_to(window=window, **kwargs)


toggle_tab_bar = ToggleTabBar()

@kovidgoyal
Copy link
Owner

Works for me by adding the above to to the toggle_tab_bar.py. Are you sure you are running kitty from modified sources? Remember to invoke kitty as kitty/launcher/kitty

@jsphnecclia
Copy link
Author

Strange. I added the above to toggle_tab_bar.py, and couldn't get it to run through either kitty/launcher/kitty or the compiled kitty.app... I guess I'll have to try a non-rc solution

@kovidgoyal
Copy link
Owner

What happens when you do

kitty/launcher/kitty @ toggle-tab-bar -h

@jsphnecclia
Copy link
Author

jsphnecclia commented Jan 21, 2021

Very dumb mistake on my part, sorry for wasting so much time. I was running kitty through kitty/launcher/kitty, yet doing the remote command kitty @ toggle-tab-bar instead of kitty/launcher/kitty @ toggle-tab-bar. Now the latter works as expected.

Hopefully this will help someone if they make the same mistake

@jsphnecclia
Copy link
Author

Is it possible to use the function pt_to_px (defined on line 1003 of state.c) in a function in state.c itself (specifically os_window_regions on line 448)?

@kovidgoyal
Copy link
Owner

Sure it is.

@jsphnecclia
Copy link
Author

How so? When I try to use pt_to_px there I get the error that implicit declaration of function 'pt_to_px' is invalid in C99

@kovidgoyal
Copy link
Owner

Just move it up in the file.

@jsphnecclia
Copy link
Author

I tried that - It results in many more errors. I tried moving os_window_regions down after pt_to_px too, with no luck

@kovidgoyal
Copy link
Owner

There you go: af9da2e

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

2 participants