diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-04-15 21:03:06 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-04-15 21:08:50 +0200 |
| commit | d33040e87f89e7e8eb9a7442003bda6429f9c1a9 (patch) | |
| tree | 019451536bc75649e043423cb793d1f19cef07c5 /vis-lua.c | |
| parent | 472c559a273d3c7b0f5ee92260c5544bc3d74576 (diff) | |
| download | vis-d33040e87f89e7e8eb9a7442003bda6429f9c1a9.tar.gz vis-d33040e87f89e7e8eb9a7442003bda6429f9c1a9.tar.xz | |
vis-lua: add file.newlines to detect type of new lines
Diffstat (limited to 'vis-lua.c')
| -rw-r--r-- | vis-lua.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -637,10 +637,26 @@ static int file_index(lua_State *L) { lua_pushstring(L, file->name); return 1; } + if (strcmp(key, "lines") == 0) { obj_ref_new(L, file->text, "vis.file.text"); return 1; } + + if (strcmp(key, "newlines") == 0) { + switch (text_newline_type(file->text)) { + case TEXT_NEWLINE_NL: + lua_pushstring(L, "nl"); + break; + case TEXT_NEWLINE_CRNL: + lua_pushstring(L, "crnl"); + break; + default: + lua_pushnil(L); + break; + } + return 1; + } } return index_common(L); |
