vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 8b325c1851cdfe363b5cdacb31a3ed3b3befb72c parent 0cb20e1558fc3007275513eb1996225fac6f812d Author: Marc André Tanner <mat@brain-dump.org> Date: Thu, 10 Nov 2016 22:23:36 +0100 vis-lua: change misnamed attribute values of `file.newlines` Also rename underlying C code. Diffstat:
| M | README.md | | | 2 | +- |
| M | text.c | | | 10 | +++++----- |
| M | text.h | | | 4 | ++-- |
| M | vis-lua.c | | | 10 | +++++----- |
| M | vis.lua | | | 2 | +- |
5 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md @@ -612,7 +612,7 @@ At this time there exists no API stability guarantees. - `lines_iterator()` - `name` - `lines[0..#lines+1]` array giving read/write access to lines - - `newlines` type of newlines either `"nl"` or `"crnl"` + - `newlines` type of newlines either `"lf"` or `"crlf"` - `size` current file size in bytes - `modified` whether the file contains unsaved changes - `window` diff --git a/text.c b/text.c @@ -1319,17 +1319,17 @@ bool text_sigbus(Text *txt, const char *addr) { enum TextNewLine text_newline_type(Text *txt){ if (!txt->newlines) { - txt->newlines = TEXT_NEWLINE_NL; /* default to UNIX style \n new lines */ + txt->newlines = TEXT_NEWLINE_LF; /* default to UNIX style \n new lines */ const char *start = txt->block ? txt->block->data : NULL; if (start) { const char *nl = memchr(start, '\n', txt->block->len); if (nl > start && nl[-1] == '\r') - txt->newlines = TEXT_NEWLINE_CRNL; + txt->newlines = TEXT_NEWLINE_CRLF; } else { char c; size_t nl = lines_skip_forward(txt, 0, 1, NULL); if (nl > 1 && text_byte_get(txt, nl-2, &c) && c == '\r') - txt->newlines = TEXT_NEWLINE_CRNL; + txt->newlines = TEXT_NEWLINE_CRLF; } } @@ -1338,8 +1338,8 @@ enum TextNewLine text_newline_type(Text *txt){ const char *text_newline_char(Text *txt) { static const char *types[] = { - [TEXT_NEWLINE_NL] = "\n", - [TEXT_NEWLINE_CRNL] = "\r\n", + [TEXT_NEWLINE_LF] = "\n", + [TEXT_NEWLINE_CRLF] = "\r\n", }; return types[text_newline_type(txt)]; } diff --git a/text.h b/text.h @@ -121,8 +121,8 @@ bool text_sigbus(Text*, const char *addr); /* which type of new lines does the text use? */ enum TextNewLine { - TEXT_NEWLINE_NL = 1, - TEXT_NEWLINE_CRNL, + TEXT_NEWLINE_LF = 1, + TEXT_NEWLINE_CRLF, }; enum TextNewLine text_newline_type(Text*); diff --git a/vis-lua.c b/vis-lua.c @@ -53,7 +53,7 @@ static void window_status_update(Vis *vis, Win *win) { vis_macro_recording(vis) ? " @": ""); left_count++; - if (text_newline_type(txt) != TEXT_NEWLINE_NL) + if (text_newline_type(txt) != TEXT_NEWLINE_LF) strcpy(right_parts[right_count++], "␊"); int cursor_count = view_cursors_count(view); @@ -1085,11 +1085,11 @@ static int file_index(lua_State *L) { if (strcmp(key, "newlines") == 0) { switch (text_newline_type(file->text)) { - case TEXT_NEWLINE_NL: - lua_pushstring(L, "nl"); + case TEXT_NEWLINE_LF: + lua_pushstring(L, "lf"); break; - case TEXT_NEWLINE_CRNL: - lua_pushstring(L, "crnl"); + case TEXT_NEWLINE_CRLF: + lua_pushstring(L, "crlf"); break; default: lua_pushnil(L); diff --git a/vis.lua b/vis.lua @@ -393,7 +393,7 @@ vis.events.win_status = function(win) table.insert(left_parts, (file.name or '[No Name]') .. (file.modified and ' [+]' or '') .. (vis.recording and ' @' or '')) - if file.newlines ~= "nl" then + if file.newlines ~= "lf" then table.insert(right_parts, "␊") end