mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-19 23:14:55 +02:00
Fix synthetic '+' tab rendering and make it always-visible as a new-tab button
- Skip user tab_title_template for synthetic tabs (tab_id < 0) so custom templates referencing layout_name no longer produce '? +' during drags - Always append the '+' drop indicator to tab_bar_data (not only during window drags), making it a persistent clickable new-tab button - Handle click on the '+' tab (tab_id == -1) in the tab bar mouse handler by calling new_tab() on left-button release
This commit is contained in:
@@ -265,6 +265,8 @@ safe_builtins = {
|
|||||||
|
|
||||||
|
|
||||||
def apply_title_template(draw_data: DrawData, tab: TabBarData, index: int, max_title_length: int = 0) -> str:
|
def apply_title_template(draw_data: DrawData, tab: TabBarData, index: int, max_title_length: int = 0) -> str:
|
||||||
|
if tab.tab_id < 0:
|
||||||
|
return tab.title # synthetic tab — render title literally, skip user template
|
||||||
ta = TabAccessor(tab.tab_id)
|
ta = TabAccessor(tab.tab_id)
|
||||||
data = {
|
data = {
|
||||||
'index': index,
|
'index': index,
|
||||||
|
|||||||
@@ -1607,15 +1607,13 @@ class TabManager: # {{{
|
|||||||
dragged_tab_id, drag_started = get_tab_being_dragged()[:2]
|
dragged_tab_id, drag_started = get_tab_being_dragged()[:2]
|
||||||
if drag_started:
|
if drag_started:
|
||||||
tab_being_dragged_from_here = self.tab_for_id(dragged_tab_id) is not None
|
tab_being_dragged_from_here = self.tab_for_id(dragged_tab_id) is not None
|
||||||
window_drag_active = get_window_being_dragged()[1]
|
|
||||||
if self.tab_being_dropped is None:
|
if self.tab_being_dropped is None:
|
||||||
wdtt = self.window_drag_target_tab_id
|
wdtt = self.window_drag_target_tab_id
|
||||||
if tab_being_dragged_from_here:
|
if tab_being_dragged_from_here:
|
||||||
tabs = tuple(t.data_for_tab_bar(t is at or t.id == wdtt) for t in self.tabs_to_be_shown_in_tab_bar if t.id != dragged_tab_id)
|
tabs = tuple(t.data_for_tab_bar(t is at or t.id == wdtt) for t in self.tabs_to_be_shown_in_tab_bar if t.id != dragged_tab_id)
|
||||||
else:
|
else:
|
||||||
tabs = tuple(t.data_for_tab_bar(t is at or t.id == wdtt) for t in self.tabs_to_be_shown_in_tab_bar)
|
tabs = tuple(t.data_for_tab_bar(t is at or t.id == wdtt) for t in self.tabs_to_be_shown_in_tab_bar)
|
||||||
if window_drag_active:
|
tabs = tabs + (self._new_tab_drop_indicator(),)
|
||||||
tabs = tabs + (self._new_tab_drop_indicator(),)
|
|
||||||
return tabs
|
return tabs
|
||||||
tmap = {t.id:t for t in self.tabs}
|
tmap = {t.id:t for t in self.tabs}
|
||||||
at = self.active_tab
|
at = self.active_tab
|
||||||
@@ -1746,7 +1744,12 @@ class TabManager: # {{{
|
|||||||
request_callback_with_thumbnail("start_tab_drag", self.os_window_id)
|
request_callback_with_thumbnail("start_tab_drag", self.os_window_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
tab = self.tab_for_id(self.tab_bar.tab_id_at(int(x)))
|
tab_id_at_x = self.tab_bar.tab_id_at(int(x))
|
||||||
|
if tab_id_at_x == -1:
|
||||||
|
if button == GLFW_MOUSE_BUTTON_LEFT and action == GLFW_RELEASE:
|
||||||
|
self.new_tab()
|
||||||
|
return
|
||||||
|
tab = self.tab_for_id(tab_id_at_x)
|
||||||
now = monotonic()
|
now = monotonic()
|
||||||
if tab is None:
|
if tab is None:
|
||||||
if button == GLFW_MOUSE_BUTTON_LEFT and action == GLFW_RELEASE and len(self.recent_mouse_events) > 2:
|
if button == GLFW_MOUSE_BUTTON_LEFT and action == GLFW_RELEASE and len(self.recent_mouse_events) > 2:
|
||||||
|
|||||||
Reference in New Issue
Block a user