Fix "hard" indent column info on status view. (#1078)
* Fix "hard" indent column info on status view. * Update tabs calculation and add "byte" number info * Add config.show_char_byte_info * Add show char byte toggle command. it should be added on the commands/statusbar.lua, but there is no config module loaded before and i won't to add it. * Update config.lua * Update statusview.lua
This commit is contained in:
parent
e4bef5c5b6
commit
2667f9476b
|
@ -222,6 +222,20 @@ function StatusView:register_docview_items()
|
||||||
get_item = function()
|
get_item = function()
|
||||||
local dv = core.active_view
|
local dv = core.active_view
|
||||||
local line, col = dv.doc:get_selection()
|
local line, col = dv.doc:get_selection()
|
||||||
|
local _, indent_size = dv.doc:get_indent_info()
|
||||||
|
-- Calculating tabs when the doc is using the "hard" indent type.
|
||||||
|
local ntabs = 0
|
||||||
|
local last_idx = 0
|
||||||
|
while last_idx < col do
|
||||||
|
local s, e = string.find(dv.doc.lines[line], "\t", last_idx, true)
|
||||||
|
if s and s < col then
|
||||||
|
ntabs = ntabs + 1
|
||||||
|
last_idx = e + 1
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
col = col + ntabs * (indent_size - 1)
|
||||||
return {
|
return {
|
||||||
style.text, line, ":",
|
style.text, line, ":",
|
||||||
col > config.line_limit and style.accent or style.text, col,
|
col > config.line_limit and style.accent or style.text, col,
|
||||||
|
@ -1159,5 +1173,4 @@ function StatusView:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return StatusView
|
return StatusView
|
||||||
|
|
Loading…
Reference in New Issue