vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 7570f1559b34f6ed3331c0bbabf333e156f42c32 parent a670b75622941fdc87ace904db804089328f1a74 Author: Marc André Tanner <mat@brain-dump.org> Date: Fri, 15 Apr 2016 21:13:41 +0200 vis-lua: add file.size to return file size in bytes Diffstat:
| M | README.md | | | 1 | + |
| M | vis-lua.c | | | 5 | +++++ |
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md @@ -594,6 +594,7 @@ At this time there exists no API stability guarantees. - `name` - `lines[0..#lines+1]` array giving read/write access to lines - `newlines` type of newlines either `"nl"` or `"crnl"` + - `size` current file size in bytes - `window` - `file` - `syntax` lexer name used for syntax highlighting or `nil` diff --git a/vis-lua.c b/vis-lua.c @@ -657,6 +657,11 @@ static int file_index(lua_State *L) { } return 1; } + + if (strcmp(key, "size") == 0) { + lua_pushunsigned(L, text_size(file->text)); + return 1; + } } return index_common(L);