Indicating whether a tab is "zoomed" (in the stack layout) #8051
Answered
by
kovidgoyal
thisisrandy
asked this question in
Q&A
Replies: 1 comment
-
do tab.relayout() after setting must_draw_borders
…On Thu, Nov 14, 2024 at 09:11:00PM -0800, thisisrandy wrote:
I was looking around for a way to visually indicate whether a given tab is in stack mode and came across [this PR](#2533). The kitten code isn't functional, but given @kovidgoyal's comment and the spirit of what @franco was trying to do, I ended up with the following:
```python
from kittens.tui.handler import result_handler
def main(args):
pass
@result_handler(no_ui=True)
def handle_result(args, answer, target_window_id, boss):
tab = boss.active_tab
if tab is not None:
if tab.current_layout.name == "stack":
tab.last_used_layout()
tab.current_layout.must_draw_borders = False
else:
try:
tab.goto_layout("stack")
tab.current_layout.must_draw_borders = True
except Exception:
pass
```
Which works great... except for the first time I swtich layouts in a new tab. If I have `map kitty_mod+z kitten zoom_toggle.py` in my `kitty.conf`, pressing `C-Shift-z` in a new tab successfully enters the `stack` layout but fails to display the border. If I open a new window in the same tab, the border appears, and if I instead `C-Shift-z` twice more to toggle off/on, it likewise appears, and in both cases it continues to work as expected for the lifetime of the tab.
The implementation of `Layout.must_draw_borders` is dead simple and seems correct, but I can't see what I might be doing wrong, either. Help would be much appreciated.
--
Reply to this email directly or view it on GitHub:
#8051
You are receiving this because you were mentioned.
Message ID: ***@***.***>
--
_____________________________________
Dr. Kovid Goyal
https://www.kovidgoyal.net
https://calibre-ebook.com
_____________________________________
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
thisisrandy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was looking around for a way to visually indicate whether a given tab is in stack mode and came across this PR. The kitten code isn't functional, but given @kovidgoyal's comment and the spirit of what @franco was trying to do, I ended up with the following:
Which works great... except for the first time I swtich layouts in a new tab. If I have
map kitty_mod+z kitten zoom_toggle.py
in mykitty.conf
, pressingC-Shift-z
in a new tab successfully enters thestack
layout but fails to display the border. If I open a new window in the same tab, the border appears, if I insteadC-Shift-z
twice more to toggle off/on, it likewise appears, and in both cases it continues to work as expected for the lifetime of the tab.The implementation of
Layout.must_draw_borders
is dead simple and seems correct, but I can't see what I might be doing wrong, either. Help would be much appreciated.Beta Was this translation helpful? Give feedback.
All reactions