Steps to generalize toolbar and treeview. (#1088)

This commit is contained in:
Adam
2022-08-09 14:53:30 -04:00
committed by GitHub
parent 77cebd8341
commit 6ccc5f6dde
4 changed files with 47 additions and 41 deletions
+18 -13
View File
@@ -527,6 +527,23 @@ local commands = {
doc():set_selection(line2, col2, line1, col1)
end,
["doc:create-cursor-previous-line"] = function()
split_cursor(-1)
doc():merge_cursors()
end,
["doc:create-cursor-next-line"] = function()
split_cursor(1)
doc():merge_cursors()
end
}
command.add(function(x, y)
if x == nil or y == nil or not doc() then return false end
local x1,y1,x2,y2 = dv().position.x, dv().position.y, dv().position.x + dv().size.x, dv().position.y + dv().size.y
return x >= x1 + dv():get_gutter_width() and x < x2 and y >= y1 and y < y2
end, {
["doc:set-cursor"] = function(x, y)
set_cursor(x, y, "set")
end,
@@ -553,20 +570,8 @@ local commands = {
doc():add_selection(line, col, line, col)
end
dv().mouse_selecting = { line, col, "set" }
end,
["doc:create-cursor-previous-line"] = function()
split_cursor(-1)
doc():merge_cursors()
end,
["doc:create-cursor-next-line"] = function()
split_cursor(1)
doc():merge_cursors()
end
}
})
local translations = {
["previous-char"] = translate,
+4 -3
View File
@@ -1109,9 +1109,10 @@ function StatusView:draw()
if self.message and system.get_time() <= self.message_timeout then
self:draw_items(self.message, false, 0, self.size.y)
elseif self.tooltip_mode then
self:draw_items(self.tooltip)
else
if self.tooltip_mode then
self:draw_items(self.tooltip)
end
if #self.active_items > 0 then
--- draw left pane
core.push_clip_rect(
@@ -1121,7 +1122,7 @@ function StatusView:draw()
for _, item in ipairs(self.active_items) do
local item_x = self.left_xoffset + item.x + style.padding.x
local hovered, item_bg = get_item_bg_color(self, item)
if item.alignment == StatusView.Item.LEFT then
if item.alignment == StatusView.Item.LEFT and not self.tooltip_mode then
if type(item_bg) == "table" then
renderer.draw_rect(
item_x, self.position.y,