aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-04-15 21:13:41 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-04-15 21:13:41 +0200
commit341b490b5981de164958eaf83fdf1ade9f85c764 (patch)
treea3f1f75e8a3113a3484f75523383c7fc3ae1597c
parentd33040e87f89e7e8eb9a7442003bda6429f9c1a9 (diff)
downloadvis-341b490b5981de164958eaf83fdf1ade9f85c764.tar.gz
vis-341b490b5981de164958eaf83fdf1ade9f85c764.tar.xz
vis-lua: add file.size to return file size in bytes
-rw-r--r--README.md1
-rw-r--r--vis-lua.c5
2 files changed, 6 insertions, 0 deletions
diff --git a/README.md b/README.md
index 7878c8a..dbde617 100644
--- 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
index f3ec125..b21bca6 100644
--- 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);