diff options
author | rxi <rxi@users.noreply.github.com> | 2021-01-09 15:57:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-09 15:57:11 +0000 |
commit | 345e49ce2635107a55f53050ee44f7a92822b117 (patch) | |
tree | ce6d64b1df4e7d43041d0b8962b3a3d1462f2c5b /plugins | |
parent | b8ff0140caed32d9b4814b46881a696ab373af3a (diff) | |
parent | b65e25e67ed3300fc03bcbb15b7e6bf7ab8a2796 (diff) | |
download | lite-xl-plugins-345e49ce2635107a55f53050ee44f7a92822b117.tar.gz lite-xl-plugins-345e49ce2635107a55f53050ee44f7a92822b117.zip |
Merge pull request #109 from liquidev/tabnumbers
Added plugin for tab numbers
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/tabnumbers.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/plugins/tabnumbers.lua b/plugins/tabnumbers.lua new file mode 100644 index 0000000..deabbcd --- /dev/null +++ b/plugins/tabnumbers.lua @@ -0,0 +1,27 @@ +local common = require "core.common" +local core = require "core" +local style = require "core.style" + +-- quite hackish, but Node isn't normally public +local Node = getmetatable(core.root_view.root_node) +local draw_tabs = Node.draw_tabs + +function Node:draw_tabs(...) + draw_tabs(self, ...) + + for i, view in ipairs(self.views) do + if i > 9 then break end + + local x, y, w, h = self:get_tab_rect(i) + local number = tostring(i) + local color = style.dim + local title_width = style.font:get_width(view:get_name()) + local free_real_estate = + math.min(math.max((w - title_width) / 2, style.padding.x), h) + if view == self.active_view then + color = style.accent + end + -- renderer.draw_rect(x, y + h - 1, free_real_estate, 1, color) + common.draw_text(style.font, color, tostring(i), "center", x, y, free_real_estate, h) + end +end |