diff options
author | liquid600pgm <liquidekgaming@gmail.com> | 2020-12-06 17:04:41 +0100 |
---|---|---|
committer | liquid600pgm <liquidekgaming@gmail.com> | 2020-12-06 17:04:41 +0100 |
commit | b65e25e67ed3300fc03bcbb15b7e6bf7ab8a2796 (patch) | |
tree | 6f3f93aab91e28c7fdbc8dc05ffd3b3adcff9dbb | |
parent | ac84d33ab234f1419b85028c735e1f970924abdb (diff) | |
download | lite-xl-plugins-b65e25e67ed3300fc03bcbb15b7e6bf7ab8a2796.tar.gz lite-xl-plugins-b65e25e67ed3300fc03bcbb15b7e6bf7ab8a2796.zip |
added tabnumbers.lua
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | plugins/tabnumbers.lua | 27 |
2 files changed, 28 insertions, 0 deletions
@@ -80,6 +80,7 @@ Plugin | Description [`selectionhighlight`](plugins/selectionhighlight.lua?raw=1) | Highlights regions of code that match the current selection *([screenshot](https://user-images.githubusercontent.com/3920290/80710883-5f597c80-8ae7-11ea-97f0-76dfacc08439.png))* [`sort`](plugins/sort.lua?raw=1) | Sorts selected lines alphabetically [`spellcheck`](plugins/spellcheck.lua?raw=1) | Underlines misspelt words *([screenshot](https://user-images.githubusercontent.com/3920290/79923973-9caa7400-842e-11ea-85d4-7a196a91ca50.png))* *— note: on Windows a [`words.txt`](https://github.com/dwyl/english-words/blob/master/words.txt) dictionary file must be placed beside the exe* +[`tabnumbers`](plugins/tabnumbers.lua?raw=1) | Displays tab numbers from 1–9 next to their names *([screenshot](https://user-images.githubusercontent.com/16415678/101285362-007a8500-37e5-11eb-869b-c10eb9d9d902.png)) [`theme16`](https://github.com/monolifed/theme16)* | Theme manager with base16 themes [`titleize`](plugins/titleize.lua?raw=1) | Titleizes selected string (`hello world` => `Hello World`) [`todotreeview`](https://github.com/drmargarido/TodoTreeView)* | Todo tree viewer for annotations in code like `TODO`, `BUG`, `FIX`, `IMPROVEMENT` 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 |