From 3c84dd08f36c8368ea7371c1d3f152f1dda6cb71 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 12 Jan 2026 23:34:53 -0800 Subject: add mouse support --- osd.lua | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'osd.lua') diff --git a/osd.lua b/osd.lua index 72d56cb..d54362c 100644 --- a/osd.lua +++ b/osd.lua @@ -61,12 +61,8 @@ function mt:resize(w, h) end function mt:menu_lines(state) - if state.depth > 1 then - -- leaves an extra line for padding between titles and options - return self.lines - state.depth - else - return self.lines - end + -- leaves an extra line for padding between titles and options + return self.lines - state.depth - 1 end function mt:menu_title(menu) @@ -94,7 +90,7 @@ function mt:menu_title(menu) str = colours.icon_sorted .. '⇅ ' .. col .. str end - return col .. ' » ' .. str + return col .. '» ' .. str end function mt:option_icons(opt, info) @@ -364,12 +360,10 @@ function mt:redraw(state) -- navigation which moves the viewport. local out_max = {} - if state.depth > 1 then - for i = 2, state.depth do - out[#out+1] = self:menu_title(state.menus[i]) - end - out[#out+1] = ' ' -- space character for correct line height + for i = 1, state.depth do + out[#out+1] = self:menu_title(state.menus[i]) end + out[#out+1] = ' ' -- space character for correct line height local menu = state:menu() @@ -469,4 +463,13 @@ function mt:is_hidden() return self.fg.hidden end +function mt:get_mouse_line(mpos) + local y = mpos.y / self.scale + local line = math.floor((y - self.padding) / config.font_size) + 1 + if line < 1 or line > self.lines then + return + end + return line +end + return osd -- cgit v1.2.3-70-g09d2