aboutsummaryrefslogtreecommitdiff
path: root/editors/vi.c
AgeCommit message (Collapse)Author
2017-03-24vi: avoid touching a new file with ZZ when no editing has been doneYousong Zhou
This is the behaviour observed with standard vim and busybox vi of at least 1.22.1. It was changed with commit "32afd3a vi: some simplifications" which happened before 1.23.0. Mistyping filename on command line happens fairly often and it's better we restore the old behaviour to avoid a few unnecessary flash writes and sometimes efforts of debugging bugs caused by those unneeded stray files. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-03-13vi: don't touch file with :x when modified_count == 0Denys Vlasenko
Along with it, there are other changes - Check for uppercase X is removed as the expression will be always false and :X itself is another totally different command in standard vim - The status line will show number of written lines instead of lines requested by the colon command. This is also how the standard vim is doing, though the difference is that '!' has to be explicitly specified in vim to allow partial writes Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-29vi,fsck: do not use build timestamp unconditionally. Closes 9626Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-11libbb: consolidate the code to set termios unbuffered modeDenys Vlasenko
function old new delta set_termios_to_raw - 116 +116 count_lines 72 74 +2 powertop_main 1458 1430 -28 top_main 943 914 -29 more_main 759 714 -45 fsck_minix_main 2969 2921 -48 conspy_main 1197 1135 -62 rawmode 99 36 -63 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/6 up/down: 118/-275) Total: -157 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-01-10Big cleanup in config help and descriptionDenys Vlasenko
Redundant help texts (one which only repeats the description) are deleted. Descriptions and help texts are trimmed. Some config options are moved, even across menus. No config option _names_ are changed. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-28vi: fix '' command (goto to prev context)Denys Vlasenko
The '' command in vi doesn't currently work because after the first apostrophe is read, the next character is converted to an integer between 0 and 25 inclusive (for indexing the array of marks). The comparison of the converted character with an apostrophe therefore never succeeds, meaning that '' doesn't do anything. Based on the patch by Francis Rounds <francis.rounds@4bridgeworks.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-09-15vi: make "g<key>" error message less likely to show garbageDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2016-04-22*: slap on a few ALIGN1/2s where appropriateDenys Vlasenko
The result of looking at "grep -F -B2 '*fill*' busybox_unstripped.map" text data bss dec hex filename 829901 4086 1904 835891 cc133 busybox_before 829665 4086 1904 835655 cc047 busybox Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-10-08join some common strings, -400 bytesDenys Vlasenko
function old new delta print_intel_cstates 499 511 +12 file_insert 355 364 +9 dpkg_main 2944 2940 -4 ifenslave_main 645 640 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 21/-9) Total: 12 bytes text data bss dec hex filename 937564 932 17676 956172 e970c busybox_old 937164 932 17676 955772 e957c busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-07-13Removes stray empty line from codeManinder Singh
This patch removes stray empty line from busybox code reported by script find_stray_empty_lines Signed-off-by: Maninder Singh <maninder1.s@samsung.com> Signed-off-by: Akhilesh Kumar <akhilesh.k@samsung.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-25typo fixesManinder Singh
Signed-off-by: Maninder Singh <maninder1.s@samsung.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-05-03vi: basic undo feature shouldn't depend on yankmarkAndrew Fuller
Currently basic undo functionality with the 'u' key depends on FEATURE_VI_YANKMARK. These two features are separate, so we can remove this dependency. Signed-off-by: Andrew Fuller <abf@google.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-03-12vi: make BACKSPACE and DELETE join lines at start/end of lineDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-07vi: fix reading of file after last lineRon Yorston
If the :r command is used to read a file after the last line of the buffer the last line of the buffer and the first line of the file are joined. An extra blank line appears at the end of the buffer. file 1 file 1 file 1file 2 file 2 file 2 ~ ~ The insertion point is normally at the start of the line following the specified line. When the specified line is the last one the next_line function baulks at moving to the non-existent following line. Signed-off-by: Ron Yorston <rmy@tigress.co.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2015-01-07vi: failure to open file is not an error when initialising bufferRon Yorston
Commit 32afd3a introduced these regressions on the master branch: Starting vi with no filename on the command line gives the status message "'(null)' Bad address" instead of "- No file 1/1 100%". Starting vi with a non-existent file on the command line gives the status message "'new.txt' No such file or directory" instead of "- new.txt 1/1 100%" Signed-off-by: Ron Yorston <rmy@tigress.co.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-09-15vi: fix incorrect memory access on brace matching. Closes 7256Denys Vlasenko
While at it, fix brace matching to actually show the match (missed fflush was causing cursor positioning to be buffered); shorten brace matching code; remove unused macro indirection in indicate_error(). Custom linker script 'busybox_ldscript' found, using it function old new delta indicate_error - 61 +61 mysleep 43 56 +13 char_insert 483 486 +3 find_pair 167 124 -43 Indicate_Error 61 - -61 ------------------------------------------------------------------------------ (add/remove: 1/1 grow/shrink: 2/1 up/down: 77/-104) Total: -27 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-05vi: some simplificationsDenys Vlasenko
function old new delta file_insert 301 315 +14 init_text_buffer 179 171 -8 colon 2889 2878 -11 file_size 37 - -37 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/2 up/down: 14/-56) Total: -42 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-03vi: clear undo buffer when we change to another fileDenys Vlasenko
function old new delta init_text_buffer 156 190 +34 undo_push 360 382 +22 count_lines 74 72 -2 undo_pop 246 222 -24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/2 up/down: 56/-26) Total: 30 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-03vi: undo code shrinkDenys Vlasenko
function old new delta undo_push 414 395 -19 do_cmd 4803 4761 -42 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2014-04-02vi: undo support for vi with intermediate queuingJody Bruchon
function old new delta undo_push - 411 +411 undo_pop - 288 +288 do_cmd 4160 4426 +266 char_insert 363 483 +120 undo_queue_commit - 61 +61 text_hole_delete 108 163 +55 string_insert 94 127 +33 colon 2864 2882 +18 yank_delete 92 101 +9 vi_main 273 280 +7 dot_scroll 88 93 +5 dot_right 29 34 +5 dot_prev 20 25 +5 dot_next 20 25 +5 dot_left 24 29 +5 dot_end 20 25 +5 dot_begin 20 25 +5 init_text_buffer 154 156 +2 text_hole_make 145 142 -3 file_insert 333 318 -15 ------------------------------------------------------------------------------ (add/remove: 3/0 grow/shrink: 15/2 up/down: 1305/-18) Total: 1287 bytes (without queuing it's ~870 bytes) Signed-off-by: Jody Bruchon <jody@jodybruchon.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-04-21vi: make regexp search case-insensitive if ":set ignorecase" is activeDenys Vlasenko
Reported by Dan Moinescu <dan@moinescu.net>. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-15vi: code shrinkDenys Vlasenko
function old new delta status_line_bold_errno - 32 +32 colon 2891 2873 -18 file_insert 354 313 -41 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 0/2 up/down: 32/-59) Total: -27 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-03-15vi: fix adjustment of buffer on partial file readRon Yorston
The second argument to text_hole_delete was incorrect: it should be a pointer to the end of the hole. Signed-off-by: Ron Yorston <rmy@tigress.co.uk> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-22*: reuse more stringsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15whitespace fixes. no code changesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14whitespace cleanup. no code changesDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-11vi: save/restore screen upon invocationDenys Vlasenko
function old new delta vi_main 253 273 +20 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-11vi: nuke FEATURE_VI_OPTIMIZE_CURSORDenys Vlasenko
It is not Unicode safe, it is not saving much of I/O, and it's large: function old new delta vi_main 255 253 -2 go_bottom_and_clear_to_eol 28 26 -2 do_cmd 4194 4182 -12 show_status_line 388 374 -14 strncat 39 - -39 __GI_strncat 39 - -39 refresh 774 724 -50 place_cursor 276 83 -193 ------------------------------------------------------------------------------ (add/remove: 0/3 grow/shrink: 0/6 up/down: 0/-351) Total: -351 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-11vi: do not set autoindent by defaultDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-31vi: add ":prev" command supportDennis Groenen
function old new delta colon 2844 2891 +47 vi_main 243 255 +12 text_yank 54 56 +2 refresh 780 774 -6 Signed-off-by: Dennis Groenen <tj.groenen@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-31vi: move mark[i] pointers if text[] moves after reallocDenys Vlasenko
While at it, optimized :s/find/repl/ a bit function old new delta text_hole_make 120 150 +30 colon 2848 2844 -4 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-01-15*: better comments on termios manipulations. No code changes.Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-11-28vi: fix [end] key handlingDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-09-09vi: prevent unlimited recursion in do_cmd(). Closes 4153Denys Vlasenko
function old new delta do_cmd 4284 4194 -90 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-25less: optionally query terminal size via "ESC [ 6 n". Closes bug 2659.Denys Vlasenko
+7 bytes is not selected, +100 if selected. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-07-03vi: tweak regex.h includeDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-27vi: fix regex search, make it selectable in configWalter Harms
function old new delta char_search 134 214 +80 find_pair 187 169 -18 mycmp 37 - -37 Signed-off-by: Walter Harms <wharms@bfs.de> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-06-05*: remove "Options:" string from help textsDenys Vlasenko
function old new delta packed_usage 28706 28623 -83 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-16vi.c: remove warning: variable 'sp' set but not usedCristian Ionescu-Idbohrn
Signed-off-by: Cristian Ionescu-Idbohrn <cii@axis.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-05-13fix "variable 'foo' set but not used" warningsDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2011-04-03move help text from include/usage.src.h to debianutils/*.c e2fsprogs/*.c ↵Pere Orga
editors/*.c loginutils/*.c mailutils/*.c Signed-off-by: Pere Orga <gotrunks@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-08-16*: make GNU licensing statement forms more regularDenys Vlasenko
This change retains "or later" state! No licensing _changes_ here, only form is adjusted (article, space between "GPL" and "v2" and so on). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-21vi: fix "ask terminal" codeDenys Vlasenko
function old new delta edit_file 761 793 +32 refresh 773 780 +7 query_screen_dimensions 63 54 -9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-07-04remove some dead assignments, add a TODO commentDenys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-19vi: fix "set ic" command; code shrink while at it. closes bug 1765Denys Vlasenko
function old new delta colon 2970 2848 -122 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-16consolidate ESC sequencesDenys Vlasenko
function old new delta bell 2 - -2 CMdown 2 - -2 Ceos 4 - -4 Ceol 4 - -4 CMup 4 - -4 SOs 5 - -5 SOn 5 - -5 CMrc 9 - -9 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-05-11lineedit: change how cmdedit_set_out_char worksDenys Vlasenko
Rename two badly names functions, use "clear to end of screen" to eliminate annoying problems with clearing wide/combining chars, and such. Run tested. function old new delta put_cur_glyph_and_inc_cursor - 124 +124 put_till_end_and_adv_cursor - 24 +24 input_delete 125 130 +5 Ceos 5 4 -1 Ceol 5 4 -1 input_end 24 - -24 cmdedit_set_out_char 122 - -122 ------------------------------------------------------------------------------ (add/remove: 2/2 grow/shrink: 1/2 up/down: 153/-148) Total: 5 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-18vi: discover window size even on serial consoles. optionalDenys Vlasenko
function old new delta edit_file 671 761 +90 wh_helper - 57 +57 query_screen_dimensions 54 63 +9 ar_main 533 542 +9 refresh 767 773 +6 vi_main 242 243 +1 text_yank 56 54 -2 get_terminal_width_height 180 135 -45 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 5/2 up/down: 172/-47) Total: 125 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-18vi: remove superfluous check on filename == ""Denys Vlasenko
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2010-04-16vi: code shrinkDenys Vlasenko
function old new delta vi_main 250 242 -8 colon 2980 2970 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18) Total: -18 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>