Added in double-clicking on emptyview and tab bar. (#1478)

* Added in double-clicking on emptyview and tab bar.

* Fixed issue with split tabs.

* Early exit if no overlapping node.

* Changed category of command to tabbar.

* Additional cleanup.

* Changed for whether we should show tabs.

* Fixed erroneous hover.
This commit is contained in:
Adam 2023-04-22 13:24:54 -04:00 committed by George Sokianos
parent c77b69a21c
commit 4f26fd1cf7
4 changed files with 28 additions and 8 deletions

View File

@ -176,3 +176,18 @@ command.add(function()
end
}
)
-- double clicking the tab bar, or on the emptyview should open a new doc
command.add(function(x, y)
local node = x and y and core.root_view.root_node:get_child_overlapping_point(x, y)
return node and node:is_in_tab_area(x, y)
end, {
["tabbar:new-doc"] = function()
command.perform("core:new-doc")
end
})
command.add("core.emptyview", {
["emptyview:new-doc"] = function()
command.perform("core:new-doc")
end
})

View File

@ -371,7 +371,7 @@ keymap.add_direct {
["shift+1lclick"] = "doc:select-to-cursor",
["ctrl+1lclick"] = "doc:split-cursor",
["1lclick"] = "doc:set-cursor",
["2lclick"] = "doc:set-cursor-word",
["2lclick"] = { "doc:set-cursor-word", "emptyview:new-doc", "tabbar:new-doc" },
["3lclick"] = "doc:set-cursor-line",
["shift+left"] = "doc:select-to-previous-char",
["shift+right"] = "doc:select-to-next-char",

View File

@ -308,7 +308,7 @@ function Node:tab_hovered_update(px, py)
if px >= cx and px < cx + cw and py >= y and py < y + h and config.tab_close_button then
self.hovered_close = tab_index
end
else
elseif #self.views > self:get_visible_tabs_number() then
self.hovered_scroll_button = self:get_scroll_button_index(px, py) or 0
end
end
@ -615,6 +615,13 @@ function Node:is_empty()
end
function Node:is_in_tab_area(x, y)
if not self:should_show_tabs() then return false end
local _, ty, _, th = self:get_scroll_button_rect(1)
return y >= ty and y < ty + th
end
function Node:close_all_docviews(keep_active)
local node_active_view = self.active_view
local lost_active_view = false

View File

@ -291,16 +291,14 @@ function RootView:on_mouse_moved(x, y, dx, dy)
if last_overlapping_node and last_overlapping_node ~= self.overlapping_node then
last_overlapping_node:on_mouse_left()
end
if not self.overlapping_node then return end
local div = self.root_node:get_divider_overlapping_point(x, y)
local tab_index = self.overlapping_node and self.overlapping_node:get_tab_overlapping_point(x, y)
if self.overlapping_node and self.overlapping_node:get_scroll_button_index(x, y) then
if self.overlapping_node:get_scroll_button_index(x, y) or self.overlapping_node:is_in_tab_area(x, y) then
core.request_cursor("arrow")
elseif div and (self.overlapping_node and not self.overlapping_node.active_view:scrollbar_overlaps_point(x, y)) then
elseif div and not self.overlapping_node.active_view:scrollbar_overlaps_point(x, y) then
core.request_cursor(div.type == "hsplit" and "sizeh" or "sizev")
elseif tab_index then
core.request_cursor("arrow")
elseif self.overlapping_node then
else
core.request_cursor(self.overlapping_node.active_view.cursor)
end
end