Commit graph

21 commits

Author SHA1 Message Date
Kovid Goyal
b692122f22
Allow selecting text drawn in the tab bar outside the tabs
Dragging the mouse over text drawn in the tab bar outside the tabs, such
as text a custom tab_bar.py draws below the tabs of a vertical tab bar,
selects it, and releasing the button copies it like a window selection
(primary selection, then copy_on_select). Clicks and double clicks on
empty space and presses on tabs behave as before.

Based on the draft in #10870, with these additions:

- Movement within drag_threshold selects nothing, so a slightly jittery
  double click on text still opens a new tab.
- A selection whose release was lost does not keep capturing the
  mouse: it is cancelled by a press outside the tab bar (which then goes
  to its normal target), by motion with no button held, by any press in
  the tab bar, and by the OS window losing focus.
- The pointer shape is reset after the press or release that starts or
  ends a selection, instead of being left as the drag shape.

Fixes #10869
Closes #10870
2026-11-15 09:32:37 +05:30
Kovid Goyal
bdbf9f5af5
Fix #10810
Some checks are pending
CI / Linux (python=3.14 cc=clang sanitize=1) (push) Waiting to run
CI / Linux (python=3.12 cc=gcc sanitize=0) (push) Waiting to run
CI / Linux (python=3.13 cc=gcc sanitize=1) (push) Waiting to run
CI / Linux package (push) Waiting to run
CI / Bundle test (macos-latest) (push) Waiting to run
CI / Bundle test (ubuntu-latest) (push) Waiting to run
CI / macOS Brew (push) Waiting to run
CI / Test ./dev.sh and benchmark (push) Waiting to run
CodeQL / CodeQL-Build (actions, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, macos-latest) (push) Waiting to run
CodeQL / CodeQL-Build (c, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (go, ubuntu-latest) (push) Waiting to run
CodeQL / CodeQL-Build (python, ubuntu-latest) (push) Waiting to run
Depscan / Scan dependencies for vulnerabilities (push) Waiting to run
2026-11-05 20:46:52 +05:30
Kovid Goyal
bea239edb1
Allow narrower vertical tab bars
When tab_title_max_length is set, size the vertical tab bar to fit the
decorations drawn by the current tab_bar_style instead of always adding
eight cells. Also allow powerline tabs in vertical tab bars to show a
title in a narrow tab bar, since the separator has a column of its own.

Fixes #10680
2026-10-17 11:35:23 +05:30
Kovid Goyal
0e408d502a
Speed up laying out the horizontal tab bar
Laying out the tab bar draws each tab several times, so cache evaluated
title templates for the duration of a single update, unless the template
depends on the length available for the title. Also skip measuring the
overhang of truncated tabs once there is no free space left, as then it
cannot change the layout.
2026-10-10 09:03:43 +05:30
Kovid Goyal
1576898315
Cleanup previous PR
Leave custom draw_tab functions a cell of slack per truncated tab, as
their overhang may grow with the space they are given. Add fade style
tests and a shared helper for horizontal tab bar tests.
2026-10-10 09:03:28 +05:30
Alistair Pattison
094b1a66a5 use all free space in the tab bar for truncated tab titles 2026-10-09 19:59:40 -04:00
Kovid Goyal
d63d7ef643
Drag and drop: Fix issues in tab hover switching and insertion
- Dropping a tab on the tab bar always re-orders. Only windows are merged
  into a tab when dropped on its middle. Single window tabs still switch
  tabs on hover so they can be dropped into the content area.
- Draw the vertical insertion marker in the blank line between tabs so it
  does not hide a tab title, using a single cell only when crowded.
- Make the dropped tab active after a drop from another OS Window, instead
  of whichever tab ended up at the stale active index after re-ordering.
- Dropping the window of a single window tab at an insertion point moves
  its tab, preserving title and layout, and is a no-op next to itself.
- Do not leave an empty tab behind if moving a dropped window fails.
- Highlight the new tab button only when appending.
- Unify the window and tab drag hover state and share the tab bar drop
  hit testing code.
2026-09-26 15:50:52 +05:30
白鸽
6155d085d2 Drag and drop: Switch tabs on hover and preview tab insertion 2026-09-26 14:32:37 +05:30
Kovid Goyal
f03c454196
Cleanup previous PR handling multi line vertical tab bar entries better 2026-09-24 19:55:45 +05:30
Vincent Manapat
ec22e9b474 Vertical tabs: Fix rendering of the powerline tab bar style
draw_tab_with_powerline draws the separator right after the title and
blends it into the background of the next tab, which is correct for a
horizontal tab bar. In a vertical tab bar each tab has its own row,
pre-filled with the tab background, so the separator ended up in the
middle of the row, coloured as the tab on the row below, and tabs of the
same colour got a stray soft separator.

For vertical tab bars, pad the title with the tab background up to the
right edge and draw the separator there, blending into the tab bar
background, as is already done for the fade style.
2026-09-24 16:01:07 +02:00
Kovid Goyal
dd2c59d255
autoformat 2026-08-05 07:16:05 +05:30
Kovid Goyal
7f0b072f0d
autoformat 2026-08-05 05:32:56 +05:30
copilot-swe-agent[bot]
a31f9e52f2
Refactor kitty_tests: move __init__.py code to base.py, update all imports 2026-08-05 05:32:54 +05:30
Kovid Goyal
75bd9d7979
Improve fade style for vertical tab bar 2026-08-02 21:54:56 +05:30
Kovid Goyal
70bdd4e96e
Fix quadratic algorithms in previous PR 2026-08-02 21:14:03 +05:30
Chance Zibolski
e7d8d17755 Vertical tabs: test wrapping combined with the line limit
Wrapping and tab_title_max_lines already compose, since wrapping runs before the
line limit is applied. Cover the combinations that were only checked by hand:
explicit newlines wrapped independently of each other, a wrap width wider than
the tab bar being clamped to it, and wrapped tabs packing by the lines they use
until the overflow ellipsis takes over.
2026-08-01 09:18:15 -07:00
Chance Zibolski
51ebfe4912 Vertical tabs: add tab_title_wrap to wrap long titles
A tab title too wide for the sidebar could only be truncated, which is wasteful
now that a title may use several lines. Add tab_title_wrap, accepting no (the
default, truncate as before), yes to wrap at the width of the tab bar, or a
number to wrap at that many cells.

Wrapping happens on grapheme boundaries so a line break can never land inside a
multi-codepoint grapheme, and SGR escapes are treated as zero width so colors
from tab_title_template neither consume cells nor get split in half. Wrapping is
bounded by tab_title_max_lines, and when a title needs more lines than it is
allowed the last line it gets is truncated with an ellipsis, which also makes
dropped lines visible for titles containing explicit newlines.

Only vertical tab bars are affected, since wrapping requires more than one row.
2026-08-01 09:18:15 -07:00
Chance Zibolski
4ccb98058b Vertical tabs: fill the tab background for the full width of the tab bar
Each line of a vertical tab was only painted as far as its text reached, so the
tab background ended mid row and the sidebar showed a ragged right edge. This
was already the case for single line titles, but multi-line titles make it
obvious, since the lines of one title rarely have the same length.

Paint the tab's full width before drawing the title over it, so every line a tab
occupies is filled in that tab's colors.
2026-08-01 09:18:15 -07:00
Chance Zibolski
26032a4802 Vertical tabs: support multi-line tab titles
Newlines in tab_title_template were drawn as a linefeed without a carriage
return, so each line started where the previous one ended, staircasing to the
right. Titles also collided with the tab below them after two lines, because
update_vertical assumed a fixed two line stride per tab.

Set LNM on the tab bar screen so a newline returns to the start of the next
line, measure how many lines each title actually occupies, and pack tabs at
cumulative offsets.

The blank line between tabs is preserved: one is inserted between tabs while
there is room, and dropped automatically once the tabs need the space, as
before. Previously this fell out of every tab reserving two lines, which is no
longer true now that a tab occupies only as many lines as its title needs.

The number of lines a title may use is limited by the new tab_title_max_lines
option, defaulting to 1 so existing configurations render as before. Lines
beyond the limit are dropped rather than bleeding into the next tab, and a title
is never allowed to use more lines than remain below it, since drawing past the
last line would scroll the tab bar and lose the tabs already drawn.

Only vertical tab bars are affected; horizontal tab bars share a single row.
2026-08-01 09:17:55 -07:00
Bruno Volpato
8d935486ef tabbar: address vertical alignment feedback 2026-04-25 15:21:50 -04:00
bvolpato
19ea73f047 Add vertical tab bars on the left and right
Teach tab_bar_edge about left and right sidebars and route tab layout,
hit-testing, and drag/drop through the vertical axis when needed.
2026-04-25 15:08:15 -04:00