Add keyboard shortcut to tooltips in `ToolbarView` (#1880)

This commit is contained in:
Adam 2024-10-01 23:41:12 -04:00 committed by GitHub
parent de118ab82a
commit 5b6c666652
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -3,6 +3,7 @@ local core = require "core"
local common = require "core.common" local common = require "core.common"
local command = require "core.command" local command = require "core.command"
local style = require "core.style" local style = require "core.style"
local keymap = require "core.keymap"
local View = require "core.view" local View = require "core.view"
local ToolbarView = View:extend() local ToolbarView = View:extend()
@ -120,7 +121,9 @@ function ToolbarView:on_mouse_moved(px, py, ...)
y_min, y_max = y, y + h y_min, y_max = y, y + h
if px > x and py > y and px <= x + w and py <= y + h then if px > x and py > y and px <= x + w and py <= y + h then
self.hovered_item = item self.hovered_item = item
core.status_view:show_tooltip(command.prettify_name(item.command)) local binding = keymap.get_binding(item.command)
local name = command.prettify_name(item.command)
core.status_view:show_tooltip(binding and { name, style.dim, " ", binding } or { name })
self.tooltip = true self.tooltip = true
return return
end end