diff options
Diffstat (limited to 'vis.lua')
| -rw-r--r-- | vis.lua | 51 |
1 files changed, 51 insertions, 0 deletions
@@ -282,3 +282,54 @@ vis.events.win_highlight = function(win, horizon_max) token_start = token_end end end + +local modes = { + [vis.MODE_NORMAL] = '', + [vis.MODE_OPERATOR_PENDING] = '', + [vis.MODE_VISUAL] = 'VISUAL', + [vis.MODE_VISUAL_LINE] = 'VISUAL-LINE', + [vis.MODE_INSERT] = 'INSERT', + [vis.MODE_REPLACE] = 'REPLACE', +} + +vis.events.win_status = function(win) + local left = {} + local right = {} + local file = win.file + local cursor = win.cursor + local delim_len = 1 + + local mode = modes[vis.mode] + if mode ~= '' then + table.insert(left, mode) + end + + table.insert(left, (file.name or '[No Name]') .. + (file.modified and ' [+]' or '') .. (vis.recording and ' @' or '')) + + if file.newlines ~= "nl" then + table.insert(right, "␊") + end + + if #win.cursors > 1 then + table.insert(right, cursor.number..'/'..#win.cursors) + end + + local size = file.size + table.insert(right, (size == 0 and "0" or math.ceil(cursor.pos/size*100)).."%") + + if not win.large then + local col = cursor.col + table.insert(right, cursor.line..', '..col) + if size > 33554432 or col > 65536 then + win.large = true + end + end + + local left_str = ' ' .. table.concat(left, " » ") .. ' ' + local right_str = ' ' .. table.concat(right, " « ") .. ' ' + local delim_count = math.max(#left-1, 0) + math.max(#right-1, 0) + local spaces = string.rep(' ', win.width - #left_str - #right_str + delim_count*delim_len) + local status = left_str .. spaces .. right_str + win:status(status) +end |
