summaryrefslogtreecommitdiff
path: root/editors/vi.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-10-24 05:00:29 +0000
committerEric Andersen <andersen@codepoet.org>2001-10-24 05:00:29 +0000
commitbdfd0d78bc44e73d693510e70087857785b3b521 (patch)
tree153a573095afac8d8d0ea857759ecabd77fb28b7 /editors/vi.c
parent9260fc5552a3ee52eb95823aa6689d52a1ffd33c (diff)
downloadbusybox-w32-bdfd0d78bc44e73d693510e70087857785b3b521.tar.gz
busybox-w32-bdfd0d78bc44e73d693510e70087857785b3b521.tar.bz2
busybox-w32-bdfd0d78bc44e73d693510e70087857785b3b521.zip
Major rework of the directory structure and the entire build system.
-Erik
Diffstat (limited to 'editors/vi.c')
-rw-r--r--editors/vi.c450
1 files changed, 225 insertions, 225 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 8d7506d0f..ddc2edc75 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -19,13 +19,13 @@
19 */ 19 */
20 20
21static const char vi_Version[] = 21static const char vi_Version[] =
22 "$Id: vi.c,v 1.15 2001/08/02 05:26:41 andersen Exp $"; 22 "$Id: vi.c,v 1.16 2001/10/24 04:59:23 andersen Exp $";
23 23
24/* 24/*
25 * To compile for standalone use: 25 * To compile for standalone use:
26 * gcc -Wall -Os -s -DSTANDALONE -o vi vi.c 26 * gcc -Wall -Os -s -DSTANDALONE -o vi vi.c
27 * or 27 * or
28 * gcc -Wall -Os -s -DSTANDALONE -DBB_FEATURE_VI_CRASHME -o vi vi.c # include testing features 28 * gcc -Wall -Os -s -DSTANDALONE -DCONFIG_FEATURE_VI_CRASHME -o vi vi.c # include testing features
29 * strip vi 29 * strip vi
30 */ 30 */
31 31
@@ -48,21 +48,21 @@ static const char vi_Version[] =
48//---- Feature -------------- Bytes to immplement 48//---- Feature -------------- Bytes to immplement
49#ifdef STANDALONE 49#ifdef STANDALONE
50#define vi_main main 50#define vi_main main
51#define BB_FEATURE_VI_COLON // 4288 51#define CONFIG_FEATURE_VI_COLON // 4288
52#define BB_FEATURE_VI_YANKMARK // 1408 52#define CONFIG_FEATURE_VI_YANKMARK // 1408
53#define BB_FEATURE_VI_SEARCH // 1088 53#define CONFIG_FEATURE_VI_SEARCH // 1088
54#define BB_FEATURE_VI_USE_SIGNALS // 1056 54#define CONFIG_FEATURE_VI_USE_SIGNALS // 1056
55#define BB_FEATURE_VI_DOT_CMD // 576 55#define CONFIG_FEATURE_VI_DOT_CMD // 576
56#define BB_FEATURE_VI_READONLY // 128 56#define CONFIG_FEATURE_VI_READONLY // 128
57#define BB_FEATURE_VI_SETOPTS // 576 57#define CONFIG_FEATURE_VI_SETOPTS // 576
58#define BB_FEATURE_VI_SET // 224 58#define CONFIG_FEATURE_VI_SET // 224
59#define BB_FEATURE_VI_WIN_RESIZE // 256 WIN_RESIZE 59#define CONFIG_FEATURE_VI_WIN_RESIZE // 256 WIN_RESIZE
60// To test editor using CRASHME: 60// To test editor using CRASHME:
61// vi -C filename 61// vi -C filename
62// To stop testing, wait until all to text[] is deleted, or 62// To stop testing, wait until all to text[] is deleted, or
63// Ctrl-Z and kill -9 %1 63// Ctrl-Z and kill -9 %1
64// while in the editor Ctrl-T will toggle the crashme function on and off. 64// while in the editor Ctrl-T will toggle the crashme function on and off.
65//#define BB_FEATURE_VI_CRASHME // randomly pick commands to execute 65//#define CONFIG_FEATURE_VI_CRASHME // randomly pick commands to execute
66#endif /* STANDALONE */ 66#endif /* STANDALONE */
67 67
68#include <stdio.h> 68#include <stdio.h>
@@ -161,40 +161,40 @@ static Byte *dot; // where all the action takes place
161static int tabstop; 161static int tabstop;
162static struct termios term_orig, term_vi; // remember what the cooked mode was 162static struct termios term_orig, term_vi; // remember what the cooked mode was
163 163
164#ifdef BB_FEATURE_VI_OPTIMIZE_CURSOR 164#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR
165static int last_row; // where the cursor was last moved to 165static int last_row; // where the cursor was last moved to
166#endif /* BB_FEATURE_VI_OPTIMIZE_CURSOR */ 166#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */
167#ifdef BB_FEATURE_VI_USE_SIGNALS 167#ifdef CONFIG_FEATURE_VI_USE_SIGNALS
168static jmp_buf restart; // catch_sig() 168static jmp_buf restart; // catch_sig()
169#endif /* BB_FEATURE_VI_USE_SIGNALS */ 169#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */
170#ifdef BB_FEATURE_VI_WIN_RESIZE 170#ifdef CONFIG_FEATURE_VI_WIN_RESIZE
171static struct winsize winsize; // remember the window size 171static struct winsize winsize; // remember the window size
172#endif /* BB_FEATURE_VI_WIN_RESIZE */ 172#endif /* CONFIG_FEATURE_VI_WIN_RESIZE */
173#ifdef BB_FEATURE_VI_DOT_CMD 173#ifdef CONFIG_FEATURE_VI_DOT_CMD
174static int adding2q; // are we currently adding user input to q 174static int adding2q; // are we currently adding user input to q
175static Byte *last_modifying_cmd; // last modifying cmd for "." 175static Byte *last_modifying_cmd; // last modifying cmd for "."
176static Byte *ioq, *ioq_start; // pointer to string for get_one_char to "read" 176static Byte *ioq, *ioq_start; // pointer to string for get_one_char to "read"
177#endif /* BB_FEATURE_VI_DOT_CMD */ 177#endif /* CONFIG_FEATURE_VI_DOT_CMD */
178#if defined(BB_FEATURE_VI_DOT_CMD) || defined(BB_FEATURE_VI_YANKMARK) 178#if defined(CONFIG_FEATURE_VI_DOT_CMD) || defined(CONFIG_FEATURE_VI_YANKMARK)
179static Byte *modifying_cmds; // cmds that modify text[] 179static Byte *modifying_cmds; // cmds that modify text[]
180#endif /* BB_FEATURE_VI_DOT_CMD || BB_FEATURE_VI_YANKMARK */ 180#endif /* CONFIG_FEATURE_VI_DOT_CMD || CONFIG_FEATURE_VI_YANKMARK */
181#ifdef BB_FEATURE_VI_READONLY 181#ifdef CONFIG_FEATURE_VI_READONLY
182static int vi_readonly, readonly; 182static int vi_readonly, readonly;
183#endif /* BB_FEATURE_VI_READONLY */ 183#endif /* CONFIG_FEATURE_VI_READONLY */
184#ifdef BB_FEATURE_VI_SETOPTS 184#ifdef CONFIG_FEATURE_VI_SETOPTS
185static int autoindent; 185static int autoindent;
186static int showmatch; 186static int showmatch;
187static int ignorecase; 187static int ignorecase;
188#endif /* BB_FEATURE_VI_SETOPTS */ 188#endif /* CONFIG_FEATURE_VI_SETOPTS */
189#ifdef BB_FEATURE_VI_YANKMARK 189#ifdef CONFIG_FEATURE_VI_YANKMARK
190static Byte *reg[28]; // named register a-z, "D", and "U" 0-25,26,27 190static Byte *reg[28]; // named register a-z, "D", and "U" 0-25,26,27
191static int YDreg, Ureg; // default delete register and orig line for "U" 191static int YDreg, Ureg; // default delete register and orig line for "U"
192static Byte *mark[28]; // user marks points somewhere in text[]- a-z and previous context '' 192static Byte *mark[28]; // user marks points somewhere in text[]- a-z and previous context ''
193static Byte *context_start, *context_end; 193static Byte *context_start, *context_end;
194#endif /* BB_FEATURE_VI_YANKMARK */ 194#endif /* CONFIG_FEATURE_VI_YANKMARK */
195#ifdef BB_FEATURE_VI_SEARCH 195#ifdef CONFIG_FEATURE_VI_SEARCH
196static Byte *last_search_pattern; // last pattern from a '/' or '?' search 196static Byte *last_search_pattern; // last pattern from a '/' or '?' search
197#endif /* BB_FEATURE_VI_SEARCH */ 197#endif /* CONFIG_FEATURE_VI_SEARCH */
198 198
199 199
200static void edit_file(Byte *); // edit one file 200static void edit_file(Byte *); // edit one file
@@ -259,59 +259,59 @@ static void redraw(int); // force a full screen refresh
259static void format_line(Byte*, Byte*, int); 259static void format_line(Byte*, Byte*, int);
260static void refresh(int); // update the terminal from screen[] 260static void refresh(int); // update the terminal from screen[]
261 261
262#ifdef BB_FEATURE_VI_SEARCH 262#ifdef CONFIG_FEATURE_VI_SEARCH
263static Byte *char_search(Byte *, Byte *, int, int); // search for pattern starting at p 263static Byte *char_search(Byte *, Byte *, int, int); // search for pattern starting at p
264static int mycmp(Byte *, Byte *, int); // string cmp based in "ignorecase" 264static int mycmp(Byte *, Byte *, int); // string cmp based in "ignorecase"
265#endif /* BB_FEATURE_VI_SEARCH */ 265#endif /* CONFIG_FEATURE_VI_SEARCH */
266#ifdef BB_FEATURE_VI_COLON 266#ifdef CONFIG_FEATURE_VI_COLON
267static void Hit_Return(void); 267static void Hit_Return(void);
268static Byte *get_one_address(Byte *, int *); // get colon addr, if present 268static Byte *get_one_address(Byte *, int *); // get colon addr, if present
269static Byte *get_address(Byte *, int *, int *); // get two colon addrs, if present 269static Byte *get_address(Byte *, int *, int *); // get two colon addrs, if present
270static void colon(Byte *); // execute the "colon" mode cmds 270static void colon(Byte *); // execute the "colon" mode cmds
271#endif /* BB_FEATURE_VI_COLON */ 271#endif /* CONFIG_FEATURE_VI_COLON */
272static Byte *get_input_line(Byte *); // get input line- use "status line" 272static Byte *get_input_line(Byte *); // get input line- use "status line"
273#ifdef BB_FEATURE_VI_USE_SIGNALS 273#ifdef CONFIG_FEATURE_VI_USE_SIGNALS
274static void winch_sig(int); // catch window size changes 274static void winch_sig(int); // catch window size changes
275static void suspend_sig(int); // catch ctrl-Z 275static void suspend_sig(int); // catch ctrl-Z
276static void alarm_sig(int); // catch alarm time-outs 276static void alarm_sig(int); // catch alarm time-outs
277static void catch_sig(int); // catch ctrl-C 277static void catch_sig(int); // catch ctrl-C
278static void core_sig(int); // catch a core dump signal 278static void core_sig(int); // catch a core dump signal
279#endif /* BB_FEATURE_VI_USE_SIGNALS */ 279#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */
280#ifdef BB_FEATURE_VI_DOT_CMD 280#ifdef CONFIG_FEATURE_VI_DOT_CMD
281static void start_new_cmd_q(Byte); // new queue for command 281static void start_new_cmd_q(Byte); // new queue for command
282static void end_cmd_q(); // stop saving input chars 282static void end_cmd_q(); // stop saving input chars
283#else /* BB_FEATURE_VI_DOT_CMD */ 283#else /* CONFIG_FEATURE_VI_DOT_CMD */
284#define end_cmd_q() 284#define end_cmd_q()
285#endif /* BB_FEATURE_VI_DOT_CMD */ 285#endif /* CONFIG_FEATURE_VI_DOT_CMD */
286#ifdef BB_FEATURE_VI_WIN_RESIZE 286#ifdef CONFIG_FEATURE_VI_WIN_RESIZE
287static void window_size_get(int); // find out what size the window is 287static void window_size_get(int); // find out what size the window is
288#endif /* BB_FEATURE_VI_WIN_RESIZE */ 288#endif /* CONFIG_FEATURE_VI_WIN_RESIZE */
289#ifdef BB_FEATURE_VI_SETOPTS 289#ifdef CONFIG_FEATURE_VI_SETOPTS
290static void showmatching(Byte *); // show the matching pair () [] {} 290static void showmatching(Byte *); // show the matching pair () [] {}
291#endif /* BB_FEATURE_VI_SETOPTS */ 291#endif /* CONFIG_FEATURE_VI_SETOPTS */
292#if defined(BB_FEATURE_VI_YANKMARK) || defined(BB_FEATURE_VI_COLON) || defined(BB_FEATURE_VI_CRASHME) 292#if defined(CONFIG_FEATURE_VI_YANKMARK) || defined(CONFIG_FEATURE_VI_COLON) || defined(CONFIG_FEATURE_VI_CRASHME)
293static Byte *string_insert(Byte *, Byte *); // insert the string at 'p' 293static Byte *string_insert(Byte *, Byte *); // insert the string at 'p'
294#endif /* BB_FEATURE_VI_YANKMARK || BB_FEATURE_VI_COLON || BB_FEATURE_VI_CRASHME */ 294#endif /* CONFIG_FEATURE_VI_YANKMARK || CONFIG_FEATURE_VI_COLON || CONFIG_FEATURE_VI_CRASHME */
295#ifdef BB_FEATURE_VI_YANKMARK 295#ifdef CONFIG_FEATURE_VI_YANKMARK
296static Byte *text_yank(Byte *, Byte *, int); // save copy of "p" into a register 296static Byte *text_yank(Byte *, Byte *, int); // save copy of "p" into a register
297static Byte what_reg(void); // what is letter of current YDreg 297static Byte what_reg(void); // what is letter of current YDreg
298static void check_context(Byte); // remember context for '' command 298static void check_context(Byte); // remember context for '' command
299static Byte *swap_context(Byte *); // goto new context for '' command 299static Byte *swap_context(Byte *); // goto new context for '' command
300#endif /* BB_FEATURE_VI_YANKMARK */ 300#endif /* CONFIG_FEATURE_VI_YANKMARK */
301#ifdef BB_FEATURE_VI_CRASHME 301#ifdef CONFIG_FEATURE_VI_CRASHME
302static void crash_dummy(); 302static void crash_dummy();
303static void crash_test(); 303static void crash_test();
304static int crashme = 0; 304static int crashme = 0;
305#endif /* BB_FEATURE_VI_CRASHME */ 305#endif /* CONFIG_FEATURE_VI_CRASHME */
306 306
307 307
308extern int vi_main(int argc, char **argv) 308extern int vi_main(int argc, char **argv)
309{ 309{
310 int c; 310 int c;
311 311
312#ifdef BB_FEATURE_VI_YANKMARK 312#ifdef CONFIG_FEATURE_VI_YANKMARK
313 int i; 313 int i;
314#endif /* BB_FEATURE_VI_YANKMARK */ 314#endif /* CONFIG_FEATURE_VI_YANKMARK */
315 315
316 CMrc= "\033[%d;%dH"; // Terminal Crusor motion ESC sequence 316 CMrc= "\033[%d;%dH"; // Terminal Crusor motion ESC sequence
317 CMup= "\033[A"; // move cursor up one line, same col 317 CMup= "\033[A"; // move cursor up one line, same col
@@ -321,46 +321,46 @@ extern int vi_main(int argc, char **argv)
321 SOs = "\033[7m"; // Terminal standout mode on 321 SOs = "\033[7m"; // Terminal standout mode on
322 SOn = "\033[0m"; // Terminal standout mode off 322 SOn = "\033[0m"; // Terminal standout mode off
323 bell= "\007"; // Terminal bell sequence 323 bell= "\007"; // Terminal bell sequence
324#ifdef BB_FEATURE_VI_CRASHME 324#ifdef CONFIG_FEATURE_VI_CRASHME
325 (void) srand((long) getpid()); 325 (void) srand((long) getpid());
326#endif /* BB_FEATURE_VI_CRASHME */ 326#endif /* CONFIG_FEATURE_VI_CRASHME */
327 status_buffer = (Byte *) malloc(200); // hold messages to user 327 status_buffer = (Byte *) malloc(200); // hold messages to user
328#ifdef BB_FEATURE_VI_READONLY 328#ifdef CONFIG_FEATURE_VI_READONLY
329 vi_readonly = readonly = FALSE; 329 vi_readonly = readonly = FALSE;
330 if (strncmp(argv[0], "view", 4) == 0) { 330 if (strncmp(argv[0], "view", 4) == 0) {
331 readonly = TRUE; 331 readonly = TRUE;
332 vi_readonly = TRUE; 332 vi_readonly = TRUE;
333 } 333 }
334#endif /* BB_FEATURE_VI_READONLY */ 334#endif /* CONFIG_FEATURE_VI_READONLY */
335#ifdef BB_FEATURE_VI_SETOPTS 335#ifdef CONFIG_FEATURE_VI_SETOPTS
336 autoindent = 1; 336 autoindent = 1;
337 ignorecase = 1; 337 ignorecase = 1;
338 showmatch = 1; 338 showmatch = 1;
339#endif /* BB_FEATURE_VI_SETOPTS */ 339#endif /* CONFIG_FEATURE_VI_SETOPTS */
340#ifdef BB_FEATURE_VI_YANKMARK 340#ifdef CONFIG_FEATURE_VI_YANKMARK
341 for (i = 0; i < 28; i++) { 341 for (i = 0; i < 28; i++) {
342 reg[i] = 0; 342 reg[i] = 0;
343 } // init the yank regs 343 } // init the yank regs
344#endif /* BB_FEATURE_VI_YANKMARK */ 344#endif /* CONFIG_FEATURE_VI_YANKMARK */
345#ifdef BB_FEATURE_VI_DOT_CMD 345#ifdef CONFIG_FEATURE_VI_DOT_CMD
346 modifying_cmds = (Byte *) "aAcCdDiIJoOpPrRsxX<>~"; // cmds modifying text[] 346 modifying_cmds = (Byte *) "aAcCdDiIJoOpPrRsxX<>~"; // cmds modifying text[]
347#endif /* BB_FEATURE_VI_DOT_CMD */ 347#endif /* CONFIG_FEATURE_VI_DOT_CMD */
348 348
349 // 1- process $HOME/.exrc file 349 // 1- process $HOME/.exrc file
350 // 2- process EXINIT variable from environment 350 // 2- process EXINIT variable from environment
351 // 3- process command line args 351 // 3- process command line args
352 while ((c = getopt(argc, argv, "hCR")) != -1) { 352 while ((c = getopt(argc, argv, "hCR")) != -1) {
353 switch (c) { 353 switch (c) {
354#ifdef BB_FEATURE_VI_CRASHME 354#ifdef CONFIG_FEATURE_VI_CRASHME
355 case 'C': 355 case 'C':
356 crashme = 1; 356 crashme = 1;
357 break; 357 break;
358#endif /* BB_FEATURE_VI_CRASHME */ 358#endif /* CONFIG_FEATURE_VI_CRASHME */
359#ifdef BB_FEATURE_VI_READONLY 359#ifdef CONFIG_FEATURE_VI_READONLY
360 case 'R': // Read-only flag 360 case 'R': // Read-only flag
361 readonly = TRUE; 361 readonly = TRUE;
362 break; 362 break;
363#endif /* BB_FEATURE_VI_READONLY */ 363#endif /* CONFIG_FEATURE_VI_READONLY */
364 //case 'r': // recover flag- ignore- we don't use tmp file 364 //case 'r': // recover flag- ignore- we don't use tmp file
365 //case 'x': // encryption flag- ignore 365 //case 'x': // encryption flag- ignore
366 //case 'c': // execute command first 366 //case 'c': // execute command first
@@ -399,21 +399,21 @@ static void edit_file(Byte * fn)
399 char c; 399 char c;
400 int cnt, size, ch; 400 int cnt, size, ch;
401 401
402#ifdef BB_FEATURE_VI_USE_SIGNALS 402#ifdef CONFIG_FEATURE_VI_USE_SIGNALS
403 char *msg; 403 char *msg;
404 int sig; 404 int sig;
405#endif /* BB_FEATURE_VI_USE_SIGNALS */ 405#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */
406#ifdef BB_FEATURE_VI_YANKMARK 406#ifdef CONFIG_FEATURE_VI_YANKMARK
407 static Byte *cur_line; 407 static Byte *cur_line;
408#endif /* BB_FEATURE_VI_YANKMARK */ 408#endif /* CONFIG_FEATURE_VI_YANKMARK */
409 409
410 rawmode(); 410 rawmode();
411 rows = 24; 411 rows = 24;
412 columns = 80; 412 columns = 80;
413 ch= -1; 413 ch= -1;
414#ifdef BB_FEATURE_VI_WIN_RESIZE 414#ifdef CONFIG_FEATURE_VI_WIN_RESIZE
415 window_size_get(0); 415 window_size_get(0);
416#endif /* BB_FEATURE_VI_WIN_RESIZE */ 416#endif /* CONFIG_FEATURE_VI_WIN_RESIZE */
417 new_screen(rows, columns); // get memory for virtual screen 417 new_screen(rows, columns); // get memory for virtual screen
418 418
419 cnt = file_size(fn); // file size 419 cnt = file_size(fn); // file size
@@ -427,14 +427,14 @@ static void edit_file(Byte * fn)
427 (void) char_insert(text, '\n'); // start empty buf with dummy line 427 (void) char_insert(text, '\n'); // start empty buf with dummy line
428 } 428 }
429 file_modified = FALSE; 429 file_modified = FALSE;
430#ifdef BB_FEATURE_VI_YANKMARK 430#ifdef CONFIG_FEATURE_VI_YANKMARK
431 YDreg = 26; // default Yank/Delete reg 431 YDreg = 26; // default Yank/Delete reg
432 Ureg = 27; // hold orig line for "U" cmd 432 Ureg = 27; // hold orig line for "U" cmd
433 for (cnt = 0; cnt < 28; cnt++) { 433 for (cnt = 0; cnt < 28; cnt++) {
434 mark[cnt] = 0; 434 mark[cnt] = 0;
435 } // init the marks 435 } // init the marks
436 mark[26] = mark[27] = text; // init "previous context" 436 mark[26] = mark[27] = text; // init "previous context"
437#endif /* BB_FEATURE_VI_YANKMARK */ 437#endif /* CONFIG_FEATURE_VI_YANKMARK */
438 438
439 err_method = 1; // flash 439 err_method = 1; // flash
440 last_forward_char = last_input_char = '\0'; 440 last_forward_char = last_input_char = '\0';
@@ -442,7 +442,7 @@ static void edit_file(Byte * fn)
442 ccol = 0; 442 ccol = 0;
443 edit_status(); 443 edit_status();
444 444
445#ifdef BB_FEATURE_VI_USE_SIGNALS 445#ifdef CONFIG_FEATURE_VI_USE_SIGNALS
446 signal(SIGHUP, catch_sig); 446 signal(SIGHUP, catch_sig);
447 signal(SIGINT, catch_sig); 447 signal(SIGINT, catch_sig);
448 signal(SIGALRM, alarm_sig); 448 signal(SIGALRM, alarm_sig);
@@ -481,7 +481,7 @@ static void edit_file(Byte * fn)
481 psbs("-- caught signal %d %s--", sig, msg); 481 psbs("-- caught signal %d %s--", sig, msg);
482 screenbegin = dot = text; 482 screenbegin = dot = text;
483 } 483 }
484#endif /* BB_FEATURE_VI_USE_SIGNALS */ 484#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */
485 485
486 editing = 1; 486 editing = 1;
487 cmd_mode = 0; // 0=command 1=insert 2='R'eplace 487 cmd_mode = 0; // 0=command 1=insert 2='R'eplace
@@ -489,20 +489,20 @@ static void edit_file(Byte * fn)
489 tabstop = 8; 489 tabstop = 8;
490 offset = 0; // no horizontal offset 490 offset = 0; // no horizontal offset
491 c = '\0'; 491 c = '\0';
492#ifdef BB_FEATURE_VI_DOT_CMD 492#ifdef CONFIG_FEATURE_VI_DOT_CMD
493 if (last_modifying_cmd != 0) 493 if (last_modifying_cmd != 0)
494 free(last_modifying_cmd); 494 free(last_modifying_cmd);
495 if (ioq_start != NULL) 495 if (ioq_start != NULL)
496 free(ioq_start); 496 free(ioq_start);
497 ioq = ioq_start = last_modifying_cmd = 0; 497 ioq = ioq_start = last_modifying_cmd = 0;
498 adding2q = 0; 498 adding2q = 0;
499#endif /* BB_FEATURE_VI_DOT_CMD */ 499#endif /* CONFIG_FEATURE_VI_DOT_CMD */
500 redraw(FALSE); // dont force every col re-draw 500 redraw(FALSE); // dont force every col re-draw
501 show_status_line(); 501 show_status_line();
502 502
503 //------This is the main Vi cmd handling loop ----------------------- 503 //------This is the main Vi cmd handling loop -----------------------
504 while (editing > 0) { 504 while (editing > 0) {
505#ifdef BB_FEATURE_VI_CRASHME 505#ifdef CONFIG_FEATURE_VI_CRASHME
506 if (crashme > 0) { 506 if (crashme > 0) {
507 if ((end - text) > 1) { 507 if ((end - text) > 1) {
508 crash_dummy(); // generate a random command 508 crash_dummy(); // generate a random command
@@ -513,23 +513,23 @@ static void edit_file(Byte * fn)
513 refresh(FALSE); 513 refresh(FALSE);
514 } 514 }
515 } 515 }
516#endif /* BB_FEATURE_VI_CRASHME */ 516#endif /* CONFIG_FEATURE_VI_CRASHME */
517 last_input_char = c = get_one_char(); // get a cmd from user 517 last_input_char = c = get_one_char(); // get a cmd from user
518#ifdef BB_FEATURE_VI_YANKMARK 518#ifdef CONFIG_FEATURE_VI_YANKMARK
519 // save a copy of the current line- for the 'U" command 519 // save a copy of the current line- for the 'U" command
520 if (begin_line(dot) != cur_line) { 520 if (begin_line(dot) != cur_line) {
521 cur_line = begin_line(dot); 521 cur_line = begin_line(dot);
522 text_yank(begin_line(dot), end_line(dot), Ureg); 522 text_yank(begin_line(dot), end_line(dot), Ureg);
523 } 523 }
524#endif /* BB_FEATURE_VI_YANKMARK */ 524#endif /* CONFIG_FEATURE_VI_YANKMARK */
525#ifdef BB_FEATURE_VI_DOT_CMD 525#ifdef CONFIG_FEATURE_VI_DOT_CMD
526 // These are commands that change text[]. 526 // These are commands that change text[].
527 // Remember the input for the "." command 527 // Remember the input for the "." command
528 if (!adding2q && ioq_start == 0 528 if (!adding2q && ioq_start == 0
529 && strchr((char *) modifying_cmds, c) != NULL) { 529 && strchr((char *) modifying_cmds, c) != NULL) {
530 start_new_cmd_q(c); 530 start_new_cmd_q(c);
531 } 531 }
532#endif /* BB_FEATURE_VI_DOT_CMD */ 532#endif /* CONFIG_FEATURE_VI_DOT_CMD */
533 do_cmd(c); // execute the user command 533 do_cmd(c); // execute the user command
534 // 534 //
535 // poll to see if there is input already waiting. if we are 535 // poll to see if there is input already waiting. if we are
@@ -540,10 +540,10 @@ static void edit_file(Byte * fn)
540 refresh(FALSE); 540 refresh(FALSE);
541 show_status_line(); 541 show_status_line();
542 } 542 }
543#ifdef BB_FEATURE_VI_CRASHME 543#ifdef CONFIG_FEATURE_VI_CRASHME
544 if (crashme > 0) 544 if (crashme > 0)
545 crash_test(); // test editor variables 545 crash_test(); // test editor variables
546#endif /* BB_FEATURE_VI_CRASHME */ 546#endif /* CONFIG_FEATURE_VI_CRASHME */
547 } 547 }
548 //------------------------------------------------------------------- 548 //-------------------------------------------------------------------
549 549
@@ -554,7 +554,7 @@ static void edit_file(Byte * fn)
554 554
555static Byte readbuffer[BUFSIZ]; 555static Byte readbuffer[BUFSIZ];
556 556
557#ifdef BB_FEATURE_VI_CRASHME 557#ifdef CONFIG_FEATURE_VI_CRASHME
558static int totalcmds = 0; 558static int totalcmds = 0;
559static int Mp = 85; // Movement command Probability 559static int Mp = 85; // Movement command Probability
560static int Np = 90; // Non-movement command Probability 560static int Np = 90; // Non-movement command Probability
@@ -756,7 +756,7 @@ static void crash_test()
756 } 756 }
757 return; 757 return;
758} 758}
759#endif /* BB_FEATURE_VI_CRASHME */ 759#endif /* CONFIG_FEATURE_VI_CRASHME */
760 760
761//--------------------------------------------------------------------- 761//---------------------------------------------------------------------
762//----- the Ascii Chart ----------------------------------------------- 762//----- the Ascii Chart -----------------------------------------------
@@ -822,11 +822,11 @@ static void do_cmd(Byte c)
822 //case 0x10: // dle 822 //case 0x10: // dle
823 //case 0x11: // dc1 823 //case 0x11: // dc1
824 //case 0x13: // dc3 824 //case 0x13: // dc3
825#ifdef BB_FEATURE_VI_CRASHME 825#ifdef CONFIG_FEATURE_VI_CRASHME
826 case 0x14: // dc4 ctrl-T 826 case 0x14: // dc4 ctrl-T
827 crashme = (crashme == 0) ? 1 : 0; 827 crashme = (crashme == 0) ? 1 : 0;
828 break; 828 break;
829#endif /* BB_FEATURE_VI_CRASHME */ 829#endif /* CONFIG_FEATURE_VI_CRASHME */
830 //case 0x16: // syn 830 //case 0x16: // syn
831 //case 0x17: // etb 831 //case 0x17: // etb
832 //case 0x18: // can 832 //case 0x18: // can
@@ -873,14 +873,14 @@ static void do_cmd(Byte c)
873 case VI_K_PAGEUP: // Cursor Key Page Up 873 case VI_K_PAGEUP: // Cursor Key Page Up
874 dot_scroll(rows - 2, -1); 874 dot_scroll(rows - 2, -1);
875 break; 875 break;
876#ifdef BB_FEATURE_VI_USE_SIGNALS 876#ifdef CONFIG_FEATURE_VI_USE_SIGNALS
877 case 0x03: // ctrl-C interrupt 877 case 0x03: // ctrl-C interrupt
878 longjmp(restart, 1); 878 longjmp(restart, 1);
879 break; 879 break;
880 case 26: // ctrl-Z suspend 880 case 26: // ctrl-Z suspend
881 suspend_sig(SIGTSTP); 881 suspend_sig(SIGTSTP);
882 break; 882 break;
883#endif /* BB_FEATURE_VI_USE_SIGNALS */ 883#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */
884 case 4: // ctrl-D scroll down half screen 884 case 4: // ctrl-D scroll down half screen
885 dot_scroll((rows - 2) / 2, 1); 885 dot_scroll((rows - 2) / 2, 1);
886 break; 886 break;
@@ -949,7 +949,7 @@ static void do_cmd(Byte c)
949 } // repeat cnt 949 } // repeat cnt
950 dot_right(); 950 dot_right();
951 break; 951 break;
952#ifdef BB_FEATURE_VI_YANKMARK 952#ifdef CONFIG_FEATURE_VI_YANKMARK
953 case '"': // "- name a register to use for Delete/Yank 953 case '"': // "- name a register to use for Delete/Yank
954 c1 = get_one_char(); 954 c1 = get_one_char();
955 c1 = tolower(c1); 955 c1 = tolower(c1);
@@ -1031,7 +1031,7 @@ static void do_cmd(Byte c)
1031 dot_skip_over_ws(); 1031 dot_skip_over_ws();
1032 } 1032 }
1033 break; 1033 break;
1034#endif /* BB_FEATURE_VI_YANKMARK */ 1034#endif /* CONFIG_FEATURE_VI_YANKMARK */
1035 case '$': // $- goto end of line 1035 case '$': // $- goto end of line
1036 case VI_K_END: // Cursor Key End 1036 case VI_K_END: // Cursor Key End
1037 if (cmdcnt-- > 1) { 1037 if (cmdcnt-- > 1) {
@@ -1080,7 +1080,7 @@ static void do_cmd(Byte c)
1080 dot_prev(); 1080 dot_prev();
1081 dot_skip_over_ws(); 1081 dot_skip_over_ws();
1082 break; 1082 break;
1083#ifdef BB_FEATURE_VI_DOT_CMD 1083#ifdef CONFIG_FEATURE_VI_DOT_CMD
1084 case '.': // .- repeat the last modifying command 1084 case '.': // .- repeat the last modifying command
1085 // Stuff the last_modifying_cmd back into stdin 1085 // Stuff the last_modifying_cmd back into stdin
1086 // and let it be re-executed. 1086 // and let it be re-executed.
@@ -1088,8 +1088,8 @@ static void do_cmd(Byte c)
1088 ioq = ioq_start = (Byte *) strdup((char *) last_modifying_cmd); 1088 ioq = ioq_start = (Byte *) strdup((char *) last_modifying_cmd);
1089 } 1089 }
1090 break; 1090 break;
1091#endif /* BB_FEATURE_VI_DOT_CMD */ 1091#endif /* CONFIG_FEATURE_VI_DOT_CMD */
1092#ifdef BB_FEATURE_VI_SEARCH 1092#ifdef CONFIG_FEATURE_VI_SEARCH
1093 case '?': // /- search for a pattern 1093 case '?': // /- search for a pattern
1094 case '/': // /- search for a pattern 1094 case '/': // /- search for a pattern
1095 buf[0] = c; 1095 buf[0] = c;
@@ -1175,7 +1175,7 @@ static void do_cmd(Byte c)
1175 dot = next_line(q); // move to next blank line 1175 dot = next_line(q); // move to next blank line
1176 } 1176 }
1177 break; 1177 break;
1178#endif /* BB_FEATURE_VI_SEARCH */ 1178#endif /* CONFIG_FEATURE_VI_SEARCH */
1179 case '0': // 0- goto begining of line 1179 case '0': // 0- goto begining of line
1180 case '1': // 1- 1180 case '1': // 1-
1181 case '2': // 2- 1181 case '2': // 2-
@@ -1194,9 +1194,9 @@ static void do_cmd(Byte c)
1194 break; 1194 break;
1195 case ':': // :- the colon mode commands 1195 case ':': // :- the colon mode commands
1196 p = get_input_line((Byte *) ":"); // get input line- use "status line" 1196 p = get_input_line((Byte *) ":"); // get input line- use "status line"
1197#ifdef BB_FEATURE_VI_COLON 1197#ifdef CONFIG_FEATURE_VI_COLON
1198 colon(p); // execute the command 1198 colon(p); // execute the command
1199#else /* BB_FEATURE_VI_COLON */ 1199#else /* CONFIG_FEATURE_VI_COLON */
1200 if (*p == ':') 1200 if (*p == ':')
1201 p++; // move past the ':' 1201 p++; // move past the ':'
1202 cnt = strlen((char *) p); 1202 cnt = strlen((char *) p);
@@ -1225,7 +1225,7 @@ static void do_cmd(Byte c)
1225 } else { // unrecognised cmd 1225 } else { // unrecognised cmd
1226 ni((Byte *) p); 1226 ni((Byte *) p);
1227 } 1227 }
1228#endif /* BB_FEATURE_VI_COLON */ 1228#endif /* CONFIG_FEATURE_VI_COLON */
1229 break; 1229 break;
1230 case '<': // <- Left shift something 1230 case '<': // <- Left shift something
1231 case '>': // >- Right shift something 1231 case '>': // >- Right shift something
@@ -1289,10 +1289,10 @@ static void do_cmd(Byte c)
1289 dot = yank_delete(save_dot, dot, 0, YANKDEL); // delete to e-o-l 1289 dot = yank_delete(save_dot, dot, 0, YANKDEL); // delete to e-o-l
1290 if (c == 'C') 1290 if (c == 'C')
1291 goto dc_i; // start inserting 1291 goto dc_i; // start inserting
1292#ifdef BB_FEATURE_VI_DOT_CMD 1292#ifdef CONFIG_FEATURE_VI_DOT_CMD
1293 if (c == 'D') 1293 if (c == 'D')
1294 end_cmd_q(); // stop adding to q 1294 end_cmd_q(); // stop adding to q
1295#endif /* BB_FEATURE_VI_DOT_CMD */ 1295#endif /* CONFIG_FEATURE_VI_DOT_CMD */
1296 break; 1296 break;
1297 case 'G': // G- goto to a line number (default= E-O-F) 1297 case 'G': // G- goto to a line number (default= E-O-F)
1298 dot = end - 1; // assume E-O-F 1298 dot = end - 1; // assume E-O-F
@@ -1396,10 +1396,10 @@ static void do_cmd(Byte c)
1396 break; 1396 break;
1397 } 1397 }
1398 if (file_modified == TRUE 1398 if (file_modified == TRUE
1399#ifdef BB_FEATURE_VI_READONLY 1399#ifdef CONFIG_FEATURE_VI_READONLY
1400 && vi_readonly == FALSE 1400 && vi_readonly == FALSE
1401 && readonly == FALSE 1401 && readonly == FALSE
1402#endif /* BB_FEATURE_VI_READONLY */ 1402#endif /* CONFIG_FEATURE_VI_READONLY */
1403 ) { 1403 ) {
1404 cnt = file_write(cfn, text, end - 1); 1404 cnt = file_write(cfn, text, end - 1);
1405 if (cnt == (end - 1 - text + 1)) { 1405 if (cnt == (end - 1 - text + 1)) {
@@ -1435,15 +1435,15 @@ static void do_cmd(Byte c)
1435 break; 1435 break;
1436 case 'c': // c- change something 1436 case 'c': // c- change something
1437 case 'd': // d- delete something 1437 case 'd': // d- delete something
1438#ifdef BB_FEATURE_VI_YANKMARK 1438#ifdef CONFIG_FEATURE_VI_YANKMARK
1439 case 'y': // y- yank something 1439 case 'y': // y- yank something
1440 case 'Y': // Y- Yank a line 1440 case 'Y': // Y- Yank a line
1441#endif /* BB_FEATURE_VI_YANKMARK */ 1441#endif /* CONFIG_FEATURE_VI_YANKMARK */
1442 yf = YANKDEL; // assume either "c" or "d" 1442 yf = YANKDEL; // assume either "c" or "d"
1443#ifdef BB_FEATURE_VI_YANKMARK 1443#ifdef CONFIG_FEATURE_VI_YANKMARK
1444 if (c == 'y' || c == 'Y') 1444 if (c == 'y' || c == 'Y')
1445 yf = YANKONLY; 1445 yf = YANKONLY;
1446#endif /* BB_FEATURE_VI_YANKMARK */ 1446#endif /* CONFIG_FEATURE_VI_YANKMARK */
1447 c1 = 'y'; 1447 c1 = 'y';
1448 if (c != 'Y') 1448 if (c != 'Y')
1449 c1 = get_one_char(); // get the type of thing to delete 1449 c1 = get_one_char(); // get the type of thing to delete
@@ -1490,7 +1490,7 @@ static void do_cmd(Byte c)
1490 if (c == 'd') { 1490 if (c == 'd') {
1491 strcpy((char *) buf, "Delete"); 1491 strcpy((char *) buf, "Delete");
1492 } 1492 }
1493#ifdef BB_FEATURE_VI_YANKMARK 1493#ifdef CONFIG_FEATURE_VI_YANKMARK
1494 if (c == 'y' || c == 'Y') { 1494 if (c == 'y' || c == 'Y') {
1495 strcpy((char *) buf, "Yank"); 1495 strcpy((char *) buf, "Yank");
1496 } 1496 }
@@ -1502,7 +1502,7 @@ static void do_cmd(Byte c)
1502 } 1502 }
1503 psb("%s %d lines (%d chars) using [%c]", 1503 psb("%s %d lines (%d chars) using [%c]",
1504 buf, cnt, strlen((char *) reg[YDreg]), what_reg()); 1504 buf, cnt, strlen((char *) reg[YDreg]), what_reg());
1505#endif /* BB_FEATURE_VI_YANKMARK */ 1505#endif /* CONFIG_FEATURE_VI_YANKMARK */
1506 end_cmd_q(); // stop adding to q 1506 end_cmd_q(); // stop adding to q
1507 } 1507 }
1508 break; 1508 break;
@@ -1601,9 +1601,9 @@ static void do_cmd(Byte c)
1601 if (dot != end) { 1601 if (dot != end) {
1602 dot = bound_dot(dot); // make sure "dot" is valid 1602 dot = bound_dot(dot); // make sure "dot" is valid
1603 } 1603 }
1604#ifdef BB_FEATURE_VI_YANKMARK 1604#ifdef CONFIG_FEATURE_VI_YANKMARK
1605 check_context(c); // update the current context 1605 check_context(c); // update the current context
1606#endif /* BB_FEATURE_VI_YANKMARK */ 1606#endif /* CONFIG_FEATURE_VI_YANKMARK */
1607 1607
1608 if (!isdigit(c)) 1608 if (!isdigit(c))
1609 cmdcnt = 0; // cmd was not a number, reset cmdcnt 1609 cmdcnt = 0; // cmd was not a number, reset cmdcnt
@@ -1614,25 +1614,25 @@ static void do_cmd(Byte c)
1614} 1614}
1615 1615
1616//----- The Colon commands ------------------------------------- 1616//----- The Colon commands -------------------------------------
1617#ifdef BB_FEATURE_VI_COLON 1617#ifdef CONFIG_FEATURE_VI_COLON
1618static Byte *get_one_address(Byte * p, int *addr) // get colon addr, if present 1618static Byte *get_one_address(Byte * p, int *addr) // get colon addr, if present
1619{ 1619{
1620 int st; 1620 int st;
1621 Byte *q; 1621 Byte *q;
1622 1622
1623#ifdef BB_FEATURE_VI_YANKMARK 1623#ifdef CONFIG_FEATURE_VI_YANKMARK
1624 Byte c; 1624 Byte c;
1625#endif /* BB_FEATURE_VI_YANKMARK */ 1625#endif /* CONFIG_FEATURE_VI_YANKMARK */
1626#ifdef BB_FEATURE_VI_SEARCH 1626#ifdef CONFIG_FEATURE_VI_SEARCH
1627 Byte *pat, buf[BUFSIZ]; 1627 Byte *pat, buf[BUFSIZ];
1628#endif /* BB_FEATURE_VI_SEARCH */ 1628#endif /* CONFIG_FEATURE_VI_SEARCH */
1629 1629
1630 *addr = -1; // assume no addr 1630 *addr = -1; // assume no addr
1631 if (*p == '.') { // the current line 1631 if (*p == '.') { // the current line
1632 p++; 1632 p++;
1633 q = begin_line(dot); 1633 q = begin_line(dot);
1634 *addr = count_lines(text, q); 1634 *addr = count_lines(text, q);
1635#ifdef BB_FEATURE_VI_YANKMARK 1635#ifdef CONFIG_FEATURE_VI_YANKMARK
1636 } else if (*p == '\'') { // is this a mark addr 1636 } else if (*p == '\'') { // is this a mark addr
1637 p++; 1637 p++;
1638 c = tolower(*p); 1638 c = tolower(*p);
@@ -1645,8 +1645,8 @@ static Byte *get_one_address(Byte * p, int *addr) // get colon addr, if present
1645 *addr = count_lines(text, q); // count lines 1645 *addr = count_lines(text, q); // count lines
1646 } 1646 }
1647 } 1647 }
1648#endif /* BB_FEATURE_VI_YANKMARK */ 1648#endif /* CONFIG_FEATURE_VI_YANKMARK */
1649#ifdef BB_FEATURE_VI_SEARCH 1649#ifdef CONFIG_FEATURE_VI_SEARCH
1650 } else if (*p == '/') { // a search pattern 1650 } else if (*p == '/') { // a search pattern
1651 q = buf; 1651 q = buf;
1652 for (p++; *p; p++) { 1652 for (p++; *p; p++) {
@@ -1663,7 +1663,7 @@ static Byte *get_one_address(Byte * p, int *addr) // get colon addr, if present
1663 *addr = count_lines(text, q); 1663 *addr = count_lines(text, q);
1664 } 1664 }
1665 free(pat); 1665 free(pat);
1666#endif /* BB_FEATURE_VI_SEARCH */ 1666#endif /* CONFIG_FEATURE_VI_SEARCH */
1667 } else if (*p == '$') { // the last line in file 1667 } else if (*p == '$') { // the last line in file
1668 p++; 1668 p++;
1669 q = begin_line(end - 1); 1669 q = begin_line(end - 1);
@@ -1871,7 +1871,7 @@ static void colon(Byte * buf)
1871 ch= 1; 1871 ch= 1;
1872 } 1872 }
1873 file_modified = FALSE; 1873 file_modified = FALSE;
1874#ifdef BB_FEATURE_VI_YANKMARK 1874#ifdef CONFIG_FEATURE_VI_YANKMARK
1875 if (Ureg >= 0 && Ureg < 28 && reg[Ureg] != 0) { 1875 if (Ureg >= 0 && Ureg < 28 && reg[Ureg] != 0) {
1876 free(reg[Ureg]); // free orig line reg- for 'U' 1876 free(reg[Ureg]); // free orig line reg- for 'U'
1877 reg[Ureg]= 0; 1877 reg[Ureg]= 0;
@@ -1883,18 +1883,18 @@ static void colon(Byte * buf)
1883 for (li = 0; li < 28; li++) { 1883 for (li = 0; li < 28; li++) {
1884 mark[li] = 0; 1884 mark[li] = 0;
1885 } // init the marks 1885 } // init the marks
1886#endif /* BB_FEATURE_VI_YANKMARK */ 1886#endif /* CONFIG_FEATURE_VI_YANKMARK */
1887 // how many lines in text[]? 1887 // how many lines in text[]?
1888 li = count_lines(text, end - 1); 1888 li = count_lines(text, end - 1);
1889 psb("\"%s\"%s" 1889 psb("\"%s\"%s"
1890#ifdef BB_FEATURE_VI_READONLY 1890#ifdef CONFIG_FEATURE_VI_READONLY
1891 "%s" 1891 "%s"
1892#endif /* BB_FEATURE_VI_READONLY */ 1892#endif /* CONFIG_FEATURE_VI_READONLY */
1893 " %dL, %dC", cfn, 1893 " %dL, %dC", cfn,
1894 (sr < 0 ? " [New file]" : ""), 1894 (sr < 0 ? " [New file]" : ""),
1895#ifdef BB_FEATURE_VI_READONLY 1895#ifdef CONFIG_FEATURE_VI_READONLY
1896 ((vi_readonly == TRUE || readonly == TRUE) ? " [Read only]" : ""), 1896 ((vi_readonly == TRUE || readonly == TRUE) ? " [Read only]" : ""),
1897#endif /* BB_FEATURE_VI_READONLY */ 1897#endif /* CONFIG_FEATURE_VI_READONLY */
1898 li, ch); 1898 li, ch);
1899 } else if (strncasecmp((char *) cmd, "file", i) == 0) { // what File is this 1899 } else if (strncasecmp((char *) cmd, "file", i) == 0) { // what File is this
1900 if (b != -1 || e != -1) { 1900 if (b != -1 || e != -1) {
@@ -1940,9 +1940,9 @@ static void colon(Byte * buf)
1940 if (c > '~') 1940 if (c > '~')
1941 standout_end(); 1941 standout_end();
1942 } 1942 }
1943#ifdef BB_FEATURE_VI_SET 1943#ifdef CONFIG_FEATURE_VI_SET
1944 vc2: 1944 vc2:
1945#endif /* BB_FEATURE_VI_SET */ 1945#endif /* CONFIG_FEATURE_VI_SET */
1946 Hit_Return(); 1946 Hit_Return();
1947 } else if ((strncasecmp((char *) cmd, "quit", i) == 0) || // Quit 1947 } else if ((strncasecmp((char *) cmd, "quit", i) == 0) || // Quit
1948 (strncasecmp((char *) cmd, "next", i) == 0)) { // edit next file 1948 (strncasecmp((char *) cmd, "next", i) == 0)) { // edit next file
@@ -1982,11 +1982,11 @@ static void colon(Byte * buf)
1982 // read after current line- unless user said ":0r foo" 1982 // read after current line- unless user said ":0r foo"
1983 if (b != 0) 1983 if (b != 0)
1984 q = next_line(q); 1984 q = next_line(q);
1985#ifdef BB_FEATURE_VI_READONLY 1985#ifdef CONFIG_FEATURE_VI_READONLY
1986 l= readonly; // remember current files' status 1986 l= readonly; // remember current files' status
1987#endif 1987#endif
1988 ch = file_insert(fn, q, file_size(fn)); 1988 ch = file_insert(fn, q, file_size(fn));
1989#ifdef BB_FEATURE_VI_READONLY 1989#ifdef CONFIG_FEATURE_VI_READONLY
1990 readonly= l; 1990 readonly= l;
1991#endif 1991#endif
1992 if (ch < 0) 1992 if (ch < 0)
@@ -1994,13 +1994,13 @@ static void colon(Byte * buf)
1994 // how many lines in text[]? 1994 // how many lines in text[]?
1995 li = count_lines(q, q + ch - 1); 1995 li = count_lines(q, q + ch - 1);
1996 psb("\"%s\"" 1996 psb("\"%s\""
1997#ifdef BB_FEATURE_VI_READONLY 1997#ifdef CONFIG_FEATURE_VI_READONLY
1998 "%s" 1998 "%s"
1999#endif /* BB_FEATURE_VI_READONLY */ 1999#endif /* CONFIG_FEATURE_VI_READONLY */
2000 " %dL, %dC", fn, 2000 " %dL, %dC", fn,
2001#ifdef BB_FEATURE_VI_READONLY 2001#ifdef CONFIG_FEATURE_VI_READONLY
2002 ((vi_readonly == TRUE || readonly == TRUE) ? " [Read only]" : ""), 2002 ((vi_readonly == TRUE || readonly == TRUE) ? " [Read only]" : ""),
2003#endif /* BB_FEATURE_VI_READONLY */ 2003#endif /* CONFIG_FEATURE_VI_READONLY */
2004 li, ch); 2004 li, ch);
2005 if (ch > 0) { 2005 if (ch > 0) {
2006 // if the insert is before "dot" then we need to update 2006 // if the insert is before "dot" then we need to update
@@ -2016,7 +2016,7 @@ static void colon(Byte * buf)
2016 optind = fn_start - 1; 2016 optind = fn_start - 1;
2017 editing = 0; 2017 editing = 0;
2018 } 2018 }
2019#ifdef BB_FEATURE_VI_SET 2019#ifdef CONFIG_FEATURE_VI_SET
2020 } else if (strncasecmp((char *) cmd, "set", i) == 0) { // set or clear features 2020 } else if (strncasecmp((char *) cmd, "set", i) == 0) { // set or clear features
2021 i = 0; // offset into args 2021 i = 0; // offset into args
2022 if (strlen((char *) args) == 0) { 2022 if (strlen((char *) args) == 0) {
@@ -2024,7 +2024,7 @@ static void colon(Byte * buf)
2024 place_cursor(rows - 1, 0, FALSE); // go to Status line, bottom of screen 2024 place_cursor(rows - 1, 0, FALSE); // go to Status line, bottom of screen
2025 clear_to_eol(); // clear the line 2025 clear_to_eol(); // clear the line
2026 printf("----------------------------------------\r\n"); 2026 printf("----------------------------------------\r\n");
2027#ifdef BB_FEATURE_VI_SETOPTS 2027#ifdef CONFIG_FEATURE_VI_SETOPTS
2028 if (!autoindent) 2028 if (!autoindent)
2029 printf("no"); 2029 printf("no");
2030 printf("autoindent "); 2030 printf("autoindent ");
@@ -2038,13 +2038,13 @@ static void colon(Byte * buf)
2038 printf("no"); 2038 printf("no");
2039 printf("showmatch "); 2039 printf("showmatch ");
2040 printf("tabstop=%d ", tabstop); 2040 printf("tabstop=%d ", tabstop);
2041#endif /* BB_FEATURE_VI_SETOPTS */ 2041#endif /* CONFIG_FEATURE_VI_SETOPTS */
2042 printf("\r\n"); 2042 printf("\r\n");
2043 goto vc2; 2043 goto vc2;
2044 } 2044 }
2045 if (strncasecmp((char *) args, "no", 2) == 0) 2045 if (strncasecmp((char *) args, "no", 2) == 0)
2046 i = 2; // ":set noautoindent" 2046 i = 2; // ":set noautoindent"
2047#ifdef BB_FEATURE_VI_SETOPTS 2047#ifdef CONFIG_FEATURE_VI_SETOPTS
2048 if (strncasecmp((char *) args + i, "autoindent", 10) == 0 || 2048 if (strncasecmp((char *) args + i, "autoindent", 10) == 0 ||
2049 strncasecmp((char *) args + i, "ai", 2) == 0) { 2049 strncasecmp((char *) args + i, "ai", 2) == 0) {
2050 autoindent = (i == 2) ? 0 : 1; 2050 autoindent = (i == 2) ? 0 : 1;
@@ -2066,9 +2066,9 @@ static void colon(Byte * buf)
2066 if (ch > 0 && ch < columns - 1) 2066 if (ch > 0 && ch < columns - 1)
2067 tabstop = ch; 2067 tabstop = ch;
2068 } 2068 }
2069#endif /* BB_FEATURE_VI_SETOPTS */ 2069#endif /* CONFIG_FEATURE_VI_SETOPTS */
2070#endif /* BB_FEATURE_VI_SET */ 2070#endif /* CONFIG_FEATURE_VI_SET */
2071#ifdef BB_FEATURE_VI_SEARCH 2071#ifdef CONFIG_FEATURE_VI_SEARCH
2072 } else if (strncasecmp((char *) cmd, "s", 1) == 0) { // substitute a pattern with a replacement pattern 2072 } else if (strncasecmp((char *) cmd, "s", 1) == 0) { // substitute a pattern with a replacement pattern
2073 Byte *ls, *F, *R; 2073 Byte *ls, *F, *R;
2074 int gflag; 2074 int gflag;
@@ -2115,7 +2115,7 @@ static void colon(Byte * buf)
2115 } 2115 }
2116 q = next_line(ls); 2116 q = next_line(ls);
2117 } 2117 }
2118#endif /* BB_FEATURE_VI_SEARCH */ 2118#endif /* CONFIG_FEATURE_VI_SEARCH */
2119 } else if (strncasecmp((char *) cmd, "version", i) == 0) { // show software version 2119 } else if (strncasecmp((char *) cmd, "version", i) == 0) { // show software version
2120 psb("%s", vi_Version); 2120 psb("%s", vi_Version);
2121 } else if ((strncasecmp((char *) cmd, "write", i) == 0) || // write text to file 2121 } else if ((strncasecmp((char *) cmd, "write", i) == 0) || // write text to file
@@ -2124,12 +2124,12 @@ static void colon(Byte * buf)
2124 if (strlen((char *) args) > 0) { 2124 if (strlen((char *) args) > 0) {
2125 fn = args; 2125 fn = args;
2126 } 2126 }
2127#ifdef BB_FEATURE_VI_READONLY 2127#ifdef CONFIG_FEATURE_VI_READONLY
2128 if ((vi_readonly == TRUE || readonly == TRUE) && useforce == FALSE) { 2128 if ((vi_readonly == TRUE || readonly == TRUE) && useforce == FALSE) {
2129 psbs("\"%s\" File is read only", fn); 2129 psbs("\"%s\" File is read only", fn);
2130 goto vc3; 2130 goto vc3;
2131 } 2131 }
2132#endif /* BB_FEATURE_VI_READONLY */ 2132#endif /* CONFIG_FEATURE_VI_READONLY */
2133 // how many lines in text[]? 2133 // how many lines in text[]?
2134 li = count_lines(q, r); 2134 li = count_lines(q, r);
2135 ch = r - q + 1; 2135 ch = r - q + 1;
@@ -2153,10 +2153,10 @@ static void colon(Byte * buf)
2153 if (cmd[1] == 'q' && l == ch) { 2153 if (cmd[1] == 'q' && l == ch) {
2154 editing = 0; 2154 editing = 0;
2155 } 2155 }
2156#ifdef BB_FEATURE_VI_READONLY 2156#ifdef CONFIG_FEATURE_VI_READONLY
2157 vc3:; 2157 vc3:;
2158#endif /* BB_FEATURE_VI_READONLY */ 2158#endif /* CONFIG_FEATURE_VI_READONLY */
2159#ifdef BB_FEATURE_VI_YANKMARK 2159#ifdef CONFIG_FEATURE_VI_YANKMARK
2160 } else if (strncasecmp((char *) cmd, "yank", i) == 0) { // yank lines 2160 } else if (strncasecmp((char *) cmd, "yank", i) == 0) { // yank lines
2161 if (b < 0) { // no addr given- use defaults 2161 if (b < 0) { // no addr given- use defaults
2162 q = begin_line(dot); // assume .,. for the range 2162 q = begin_line(dot); // assume .,. for the range
@@ -2166,7 +2166,7 @@ static void colon(Byte * buf)
2166 li = count_lines(q, r); 2166 li = count_lines(q, r);
2167 psb("Yank %d lines (%d chars) into [%c]", 2167 psb("Yank %d lines (%d chars) into [%c]",
2168 li, strlen((char *) reg[YDreg]), what_reg()); 2168 li, strlen((char *) reg[YDreg]), what_reg());
2169#endif /* BB_FEATURE_VI_YANKMARK */ 2169#endif /* CONFIG_FEATURE_VI_YANKMARK */
2170 } else { 2170 } else {
2171 // cmd unknown 2171 // cmd unknown
2172 ni((Byte *) cmd); 2172 ni((Byte *) cmd);
@@ -2174,7 +2174,7 @@ static void colon(Byte * buf)
2174 vc1: 2174 vc1:
2175 dot = bound_dot(dot); // make sure "dot" is valid 2175 dot = bound_dot(dot); // make sure "dot" is valid
2176 return; 2176 return;
2177#ifdef BB_FEATURE_VI_SEARCH 2177#ifdef CONFIG_FEATURE_VI_SEARCH
2178colon_s_fail: 2178colon_s_fail:
2179 psb(":s expression missing delimiters"); 2179 psb(":s expression missing delimiters");
2180 return; 2180 return;
@@ -2193,7 +2193,7 @@ static void Hit_Return(void)
2193 ; 2193 ;
2194 redraw(TRUE); // force redraw all 2194 redraw(TRUE); // force redraw all
2195} 2195}
2196#endif /* BB_FEATURE_VI_COLON */ 2196#endif /* CONFIG_FEATURE_VI_COLON */
2197 2197
2198//----- Synchronize the cursor to Dot -------------------------- 2198//----- Synchronize the cursor to Dot --------------------------
2199static void sync_cursor(Byte * d, int *row, int *col) 2199static void sync_cursor(Byte * d, int *row, int *col)
@@ -2518,17 +2518,17 @@ static Byte *new_text(int size)
2518 return (text); 2518 return (text);
2519} 2519}
2520 2520
2521#ifdef BB_FEATURE_VI_SEARCH 2521#ifdef CONFIG_FEATURE_VI_SEARCH
2522static int mycmp(Byte * s1, Byte * s2, int len) 2522static int mycmp(Byte * s1, Byte * s2, int len)
2523{ 2523{
2524 int i; 2524 int i;
2525 2525
2526 i = strncmp((char *) s1, (char *) s2, len); 2526 i = strncmp((char *) s1, (char *) s2, len);
2527#ifdef BB_FEATURE_VI_SETOPTS 2527#ifdef CONFIG_FEATURE_VI_SETOPTS
2528 if (ignorecase) { 2528 if (ignorecase) {
2529 i = strncasecmp((char *) s1, (char *) s2, len); 2529 i = strncasecmp((char *) s1, (char *) s2, len);
2530 } 2530 }
2531#endif /* BB_FEATURE_VI_SETOPTS */ 2531#endif /* CONFIG_FEATURE_VI_SETOPTS */
2532 return (i); 2532 return (i);
2533} 2533}
2534 2534
@@ -2623,7 +2623,7 @@ static Byte *char_search(Byte * p, Byte * pat, int dir, int range) // search for
2623 return (p); 2623 return (p);
2624#endif /*REGEX_SEARCH */ 2624#endif /*REGEX_SEARCH */
2625} 2625}
2626#endif /* BB_FEATURE_VI_SEARCH */ 2626#endif /* CONFIG_FEATURE_VI_SEARCH */
2627 2627
2628static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p' 2628static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p'
2629{ 2629{
@@ -2648,7 +2648,7 @@ static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p'
2648 if ((p[-1] != '\n') && (dot>text)) { 2648 if ((p[-1] != '\n') && (dot>text)) {
2649 p--; 2649 p--;
2650 p = text_hole_delete(p, p); // shrink buffer 1 char 2650 p = text_hole_delete(p, p); // shrink buffer 1 char
2651#ifdef BB_FEATURE_VI_DOT_CMD 2651#ifdef CONFIG_FEATURE_VI_DOT_CMD
2652 // also rmove char from last_modifying_cmd 2652 // also rmove char from last_modifying_cmd
2653 if (strlen((char *) last_modifying_cmd) > 0) { 2653 if (strlen((char *) last_modifying_cmd) > 0) {
2654 Byte *q; 2654 Byte *q;
@@ -2657,7 +2657,7 @@ static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p'
2657 q[strlen((char *) q) - 1] = '\0'; // erase BS 2657 q[strlen((char *) q) - 1] = '\0'; // erase BS
2658 q[strlen((char *) q) - 1] = '\0'; // erase prev char 2658 q[strlen((char *) q) - 1] = '\0'; // erase prev char
2659 } 2659 }
2660#endif /* BB_FEATURE_VI_DOT_CMD */ 2660#endif /* CONFIG_FEATURE_VI_DOT_CMD */
2661 } 2661 }
2662 } else { 2662 } else {
2663 // insert a char into text[] 2663 // insert a char into text[]
@@ -2667,7 +2667,7 @@ static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p'
2667 c = '\n'; // translate \r to \n 2667 c = '\n'; // translate \r to \n
2668 sp = p; // remember addr of insert 2668 sp = p; // remember addr of insert
2669 p = stupid_insert(p, c); // insert the char 2669 p = stupid_insert(p, c); // insert the char
2670#ifdef BB_FEATURE_VI_SETOPTS 2670#ifdef CONFIG_FEATURE_VI_SETOPTS
2671 if (showmatch && strchr(")]}", *sp) != NULL) { 2671 if (showmatch && strchr(")]}", *sp) != NULL) {
2672 showmatching(sp); 2672 showmatching(sp);
2673 } 2673 }
@@ -2679,7 +2679,7 @@ static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p'
2679 p = stupid_insert(p, *q); // insert the char 2679 p = stupid_insert(p, *q); // insert the char
2680 } 2680 }
2681 } 2681 }
2682#endif /* BB_FEATURE_VI_SETOPTS */ 2682#endif /* CONFIG_FEATURE_VI_SETOPTS */
2683 } 2683 }
2684 return (p); 2684 return (p);
2685} 2685}
@@ -2844,7 +2844,7 @@ static Byte *find_pair(Byte * p, Byte c)
2844 return (q); 2844 return (q);
2845} 2845}
2846 2846
2847#ifdef BB_FEATURE_VI_SETOPTS 2847#ifdef CONFIG_FEATURE_VI_SETOPTS
2848// show the matching char of a pair, () [] {} 2848// show the matching char of a pair, () [] {}
2849static void showmatching(Byte * p) 2849static void showmatching(Byte * p)
2850{ 2850{
@@ -2864,7 +2864,7 @@ static void showmatching(Byte * p)
2864 refresh(FALSE); 2864 refresh(FALSE);
2865 } 2865 }
2866} 2866}
2867#endif /* BB_FEATURE_VI_SETOPTS */ 2867#endif /* CONFIG_FEATURE_VI_SETOPTS */
2868 2868
2869// open a hole in text[] 2869// open a hole in text[]
2870static Byte *text_hole_make(Byte * p, int size) // at "p", make a 'size' byte hole 2870static Byte *text_hole_make(Byte * p, int size) // at "p", make a 'size' byte hole
@@ -2951,9 +2951,9 @@ static Byte *yank_delete(Byte * start, Byte * stop, int dist, int yf)
2951 } 2951 }
2952 } 2952 }
2953 p = start; 2953 p = start;
2954#ifdef BB_FEATURE_VI_YANKMARK 2954#ifdef CONFIG_FEATURE_VI_YANKMARK
2955 text_yank(start, stop, YDreg); 2955 text_yank(start, stop, YDreg);
2956#endif /* BB_FEATURE_VI_YANKMARK */ 2956#endif /* CONFIG_FEATURE_VI_YANKMARK */
2957 if (yf == YANKDEL) { 2957 if (yf == YANKDEL) {
2958 p = text_hole_delete(start, stop); 2958 p = text_hole_delete(start, stop);
2959 } // delete lines 2959 } // delete lines
@@ -2963,33 +2963,33 @@ static Byte *yank_delete(Byte * start, Byte * stop, int dist, int yf)
2963static void show_help(void) 2963static void show_help(void)
2964{ 2964{
2965 puts("These features are available:" 2965 puts("These features are available:"
2966#ifdef BB_FEATURE_VI_SEARCH 2966#ifdef CONFIG_FEATURE_VI_SEARCH
2967 "\n\tPattern searches with / and ?" 2967 "\n\tPattern searches with / and ?"
2968#endif /* BB_FEATURE_VI_SEARCH */ 2968#endif /* CONFIG_FEATURE_VI_SEARCH */
2969#ifdef BB_FEATURE_VI_DOT_CMD 2969#ifdef CONFIG_FEATURE_VI_DOT_CMD
2970 "\n\tLast command repeat with \'.\'" 2970 "\n\tLast command repeat with \'.\'"
2971#endif /* BB_FEATURE_VI_DOT_CMD */ 2971#endif /* CONFIG_FEATURE_VI_DOT_CMD */
2972#ifdef BB_FEATURE_VI_YANKMARK 2972#ifdef CONFIG_FEATURE_VI_YANKMARK
2973 "\n\tLine marking with 'x" 2973 "\n\tLine marking with 'x"
2974 "\n\tNamed buffers with \"x" 2974 "\n\tNamed buffers with \"x"
2975#endif /* BB_FEATURE_VI_YANKMARK */ 2975#endif /* CONFIG_FEATURE_VI_YANKMARK */
2976#ifdef BB_FEATURE_VI_READONLY 2976#ifdef CONFIG_FEATURE_VI_READONLY
2977 "\n\tReadonly if vi is called as \"view\"" 2977 "\n\tReadonly if vi is called as \"view\""
2978 "\n\tReadonly with -R command line arg" 2978 "\n\tReadonly with -R command line arg"
2979#endif /* BB_FEATURE_VI_READONLY */ 2979#endif /* CONFIG_FEATURE_VI_READONLY */
2980#ifdef BB_FEATURE_VI_SET 2980#ifdef CONFIG_FEATURE_VI_SET
2981 "\n\tSome colon mode commands with \':\'" 2981 "\n\tSome colon mode commands with \':\'"
2982#endif /* BB_FEATURE_VI_SET */ 2982#endif /* CONFIG_FEATURE_VI_SET */
2983#ifdef BB_FEATURE_VI_SETOPTS 2983#ifdef CONFIG_FEATURE_VI_SETOPTS
2984 "\n\tSettable options with \":set\"" 2984 "\n\tSettable options with \":set\""
2985#endif /* BB_FEATURE_VI_SETOPTS */ 2985#endif /* CONFIG_FEATURE_VI_SETOPTS */
2986#ifdef BB_FEATURE_VI_USE_SIGNALS 2986#ifdef CONFIG_FEATURE_VI_USE_SIGNALS
2987 "\n\tSignal catching- ^C" 2987 "\n\tSignal catching- ^C"
2988 "\n\tJob suspend and resume with ^Z" 2988 "\n\tJob suspend and resume with ^Z"
2989#endif /* BB_FEATURE_VI_USE_SIGNALS */ 2989#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */
2990#ifdef BB_FEATURE_VI_WIN_RESIZE 2990#ifdef CONFIG_FEATURE_VI_WIN_RESIZE
2991 "\n\tAdapt to window re-sizes" 2991 "\n\tAdapt to window re-sizes"
2992#endif /* BB_FEATURE_VI_WIN_RESIZE */ 2992#endif /* CONFIG_FEATURE_VI_WIN_RESIZE */
2993 ); 2993 );
2994} 2994}
2995 2995
@@ -3021,7 +3021,7 @@ static void print_literal(Byte * buf, Byte * s) // copy s to buf, convert unprin
3021 } 3021 }
3022} 3022}
3023 3023
3024#ifdef BB_FEATURE_VI_DOT_CMD 3024#ifdef CONFIG_FEATURE_VI_DOT_CMD
3025static void start_new_cmd_q(Byte c) 3025static void start_new_cmd_q(Byte c)
3026{ 3026{
3027 // release old cmd 3027 // release old cmd
@@ -3041,15 +3041,15 @@ static void start_new_cmd_q(Byte c)
3041 3041
3042static void end_cmd_q() 3042static void end_cmd_q()
3043{ 3043{
3044#ifdef BB_FEATURE_VI_YANKMARK 3044#ifdef CONFIG_FEATURE_VI_YANKMARK
3045 YDreg = 26; // go back to default Yank/Delete reg 3045 YDreg = 26; // go back to default Yank/Delete reg
3046#endif /* BB_FEATURE_VI_YANKMARK */ 3046#endif /* CONFIG_FEATURE_VI_YANKMARK */
3047 adding2q = 0; 3047 adding2q = 0;
3048 return; 3048 return;
3049} 3049}
3050#endif /* BB_FEATURE_VI_DOT_CMD */ 3050#endif /* CONFIG_FEATURE_VI_DOT_CMD */
3051 3051
3052#if defined(BB_FEATURE_VI_YANKMARK) || defined(BB_FEATURE_VI_COLON) || defined(BB_FEATURE_VI_CRASHME) 3052#if defined(CONFIG_FEATURE_VI_YANKMARK) || defined(CONFIG_FEATURE_VI_COLON) || defined(CONFIG_FEATURE_VI_CRASHME)
3053static Byte *string_insert(Byte * p, Byte * s) // insert the string at 'p' 3053static Byte *string_insert(Byte * p, Byte * s) // insert the string at 'p'
3054{ 3054{
3055 int cnt, i; 3055 int cnt, i;
@@ -3061,14 +3061,14 @@ static Byte *string_insert(Byte * p, Byte * s) // insert the string at 'p'
3061 if (*s == '\n') 3061 if (*s == '\n')
3062 cnt++; 3062 cnt++;
3063 } 3063 }
3064#ifdef BB_FEATURE_VI_YANKMARK 3064#ifdef CONFIG_FEATURE_VI_YANKMARK
3065 psb("Put %d lines (%d chars) from [%c]", cnt, i, what_reg()); 3065 psb("Put %d lines (%d chars) from [%c]", cnt, i, what_reg());
3066#endif /* BB_FEATURE_VI_YANKMARK */ 3066#endif /* CONFIG_FEATURE_VI_YANKMARK */
3067 return (p); 3067 return (p);
3068} 3068}
3069#endif /* BB_FEATURE_VI_YANKMARK || BB_FEATURE_VI_COLON || BB_FEATURE_VI_CRASHME */ 3069#endif /* CONFIG_FEATURE_VI_YANKMARK || CONFIG_FEATURE_VI_COLON || CONFIG_FEATURE_VI_CRASHME */
3070 3070
3071#ifdef BB_FEATURE_VI_YANKMARK 3071#ifdef CONFIG_FEATURE_VI_YANKMARK
3072static Byte *text_yank(Byte * p, Byte * q, int dest) // copy text into a register 3072static Byte *text_yank(Byte * p, Byte * q, int dest) // copy text into a register
3073{ 3073{
3074 Byte *t; 3074 Byte *t;
@@ -3142,7 +3142,7 @@ static Byte *swap_context(Byte * p) // goto new context for '' command make this
3142 } 3142 }
3143 return (p); 3143 return (p);
3144} 3144}
3145#endif /* BB_FEATURE_VI_YANKMARK */ 3145#endif /* CONFIG_FEATURE_VI_YANKMARK */
3146 3146
3147static int isblnk(Byte c) // is the char a blank or tab 3147static int isblnk(Byte c) // is the char a blank or tab
3148{ 3148{
@@ -3170,7 +3170,7 @@ static void cookmode(void)
3170 tcsetattr(0, TCSANOW, &term_orig); 3170 tcsetattr(0, TCSANOW, &term_orig);
3171} 3171}
3172 3172
3173#ifdef BB_FEATURE_VI_WIN_RESIZE 3173#ifdef CONFIG_FEATURE_VI_WIN_RESIZE
3174//----- See what the window size currently is -------------------- 3174//----- See what the window size currently is --------------------
3175static void window_size_get(int sig) 3175static void window_size_get(int sig)
3176{ 3176{
@@ -3191,16 +3191,16 @@ static void window_size_get(int sig)
3191 rows = (int) winsize.ws_row; 3191 rows = (int) winsize.ws_row;
3192 columns = (int) winsize.ws_col; 3192 columns = (int) winsize.ws_col;
3193} 3193}
3194#endif /* BB_FEATURE_VI_WIN_RESIZE */ 3194#endif /* CONFIG_FEATURE_VI_WIN_RESIZE */
3195 3195
3196//----- Come here when we get a window resize signal --------- 3196//----- Come here when we get a window resize signal ---------
3197#ifdef BB_FEATURE_VI_USE_SIGNALS 3197#ifdef CONFIG_FEATURE_VI_USE_SIGNALS
3198static void winch_sig(int sig) 3198static void winch_sig(int sig)
3199{ 3199{
3200 signal(SIGWINCH, winch_sig); 3200 signal(SIGWINCH, winch_sig);
3201#ifdef BB_FEATURE_VI_WIN_RESIZE 3201#ifdef CONFIG_FEATURE_VI_WIN_RESIZE
3202 window_size_get(0); 3202 window_size_get(0);
3203#endif /* BB_FEATURE_VI_WIN_RESIZE */ 3203#endif /* CONFIG_FEATURE_VI_WIN_RESIZE */
3204 new_screen(rows, columns); // get memory for virtual screen 3204 new_screen(rows, columns); // get memory for virtual screen
3205 redraw(TRUE); // re-draw the screen 3205 redraw(TRUE); // re-draw the screen
3206} 3206}
@@ -3263,7 +3263,7 @@ static void core_sig(int sig)
3263 3263
3264 longjmp(restart, sig); 3264 longjmp(restart, sig);
3265} 3265}
3266#endif /* BB_FEATURE_VI_USE_SIGNALS */ 3266#endif /* CONFIG_FEATURE_VI_USE_SIGNALS */
3267 3267
3268static int mysleep(int hund) // sleep for 'h' 1/100 seconds 3268static int mysleep(int hund) // sleep for 'h' 1/100 seconds
3269{ 3269{
@@ -3396,7 +3396,7 @@ static Byte get_one_char()
3396{ 3396{
3397 static Byte c; 3397 static Byte c;
3398 3398
3399#ifdef BB_FEATURE_VI_DOT_CMD 3399#ifdef CONFIG_FEATURE_VI_DOT_CMD
3400 // ! adding2q && ioq == 0 read() 3400 // ! adding2q && ioq == 0 read()
3401 // ! adding2q && ioq != 0 *ioq 3401 // ! adding2q && ioq != 0 *ioq
3402 // adding2q *last_modifying_cmd= read() 3402 // adding2q *last_modifying_cmd= read()
@@ -3424,9 +3424,9 @@ static Byte get_one_char()
3424 last_modifying_cmd[strlen((char *) last_modifying_cmd)] = c; 3424 last_modifying_cmd[strlen((char *) last_modifying_cmd)] = c;
3425 } 3425 }
3426 } 3426 }
3427#else /* BB_FEATURE_VI_DOT_CMD */ 3427#else /* CONFIG_FEATURE_VI_DOT_CMD */
3428 c = readit(); // get the users input 3428 c = readit(); // get the users input
3429#endif /* BB_FEATURE_VI_DOT_CMD */ 3429#endif /* CONFIG_FEATURE_VI_DOT_CMD */
3430 return (c); // return the char, where ever it came from 3430 return (c); // return the char, where ever it came from
3431} 3431}
3432 3432
@@ -3489,9 +3489,9 @@ static int file_insert(Byte * fn, Byte * p, int size)
3489 int fd, cnt; 3489 int fd, cnt;
3490 3490
3491 cnt = -1; 3491 cnt = -1;
3492#ifdef BB_FEATURE_VI_READONLY 3492#ifdef CONFIG_FEATURE_VI_READONLY
3493 readonly = FALSE; 3493 readonly = FALSE;
3494#endif /* BB_FEATURE_VI_READONLY */ 3494#endif /* CONFIG_FEATURE_VI_READONLY */
3495 if (fn == 0 || strlen((char*) fn) <= 0) { 3495 if (fn == 0 || strlen((char*) fn) <= 0) {
3496 psbs("No filename given"); 3496 psbs("No filename given");
3497 goto fi0; 3497 goto fi0;
@@ -3511,13 +3511,13 @@ static int file_insert(Byte * fn, Byte * p, int size)
3511 } 3511 }
3512 3512
3513 // see if we can open the file 3513 // see if we can open the file
3514#ifdef BB_FEATURE_VI_READONLY 3514#ifdef CONFIG_FEATURE_VI_READONLY
3515 if (vi_readonly == TRUE) goto fi1; // do not try write-mode 3515 if (vi_readonly == TRUE) goto fi1; // do not try write-mode
3516#endif 3516#endif
3517 fd = open((char *) fn, O_RDWR); // assume read & write 3517 fd = open((char *) fn, O_RDWR); // assume read & write
3518 if (fd < 0) { 3518 if (fd < 0) {
3519 // could not open for writing- maybe file is read only 3519 // could not open for writing- maybe file is read only
3520#ifdef BB_FEATURE_VI_READONLY 3520#ifdef CONFIG_FEATURE_VI_READONLY
3521 fi1: 3521 fi1:
3522#endif 3522#endif
3523 fd = open((char *) fn, O_RDONLY); // try read-only 3523 fd = open((char *) fn, O_RDONLY); // try read-only
@@ -3525,10 +3525,10 @@ static int file_insert(Byte * fn, Byte * p, int size)
3525 psbs("\"%s\" %s", fn, "could not open file"); 3525 psbs("\"%s\" %s", fn, "could not open file");
3526 goto fi0; 3526 goto fi0;
3527 } 3527 }
3528#ifdef BB_FEATURE_VI_READONLY 3528#ifdef CONFIG_FEATURE_VI_READONLY
3529 // got the file- read-only 3529 // got the file- read-only
3530 readonly = TRUE; 3530 readonly = TRUE;
3531#endif /* BB_FEATURE_VI_READONLY */ 3531#endif /* CONFIG_FEATURE_VI_READONLY */
3532 } 3532 }
3533 p = text_hole_make(p, size); 3533 p = text_hole_make(p, size);
3534 cnt = read(fd, p, size); 3534 cnt = read(fd, p, size);
@@ -3591,12 +3591,12 @@ static void place_cursor(int row, int col, int opti)
3591 char cm1[BUFSIZ]; 3591 char cm1[BUFSIZ];
3592 char *cm; 3592 char *cm;
3593 int l; 3593 int l;
3594#ifdef BB_FEATURE_VI_OPTIMIZE_CURSOR 3594#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR
3595 char cm2[BUFSIZ]; 3595 char cm2[BUFSIZ];
3596 Byte *screenp; 3596 Byte *screenp;
3597 // char cm3[BUFSIZ]; 3597 // char cm3[BUFSIZ];
3598 int Rrow= last_row; 3598 int Rrow= last_row;
3599#endif /* BB_FEATURE_VI_OPTIMIZE_CURSOR */ 3599#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */
3600 3600
3601 memset(cm1, '\0', BUFSIZ - 1); // clear the buffer 3601 memset(cm1, '\0', BUFSIZ - 1); // clear the buffer
3602 3602
@@ -3610,7 +3610,7 @@ static void place_cursor(int row, int col, int opti)
3610 cm= cm1; 3610 cm= cm1;
3611 if (opti == FALSE) goto pc0; 3611 if (opti == FALSE) goto pc0;
3612 3612
3613#ifdef BB_FEATURE_VI_OPTIMIZE_CURSOR 3613#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR
3614 //----- find the minimum # of chars to move cursor ------------- 3614 //----- find the minimum # of chars to move cursor -------------
3615 //----- 2. Try moving with discreet chars (Newline, [back]space, ...) 3615 //----- 2. Try moving with discreet chars (Newline, [back]space, ...)
3616 memset(cm2, '\0', BUFSIZ - 1); // clear the buffer 3616 memset(cm2, '\0', BUFSIZ - 1); // clear the buffer
@@ -3643,7 +3643,7 @@ static void place_cursor(int row, int col, int opti)
3643 } /* else if (strlen(cm3) < strlen(cm)) { 3643 } /* else if (strlen(cm3) < strlen(cm)) {
3644 cm= cm3; 3644 cm= cm3;
3645 } */ 3645 } */
3646#endif /* BB_FEATURE_VI_OPTIMIZE_CURSOR */ 3646#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */
3647 pc0: 3647 pc0:
3648 l= strlen(cm); 3648 l= strlen(cm);
3649 if (l) write(1, cm, l); // move the cursor 3649 if (l) write(1, cm, l); // move the cursor
@@ -3690,10 +3690,10 @@ static void beep()
3690 3690
3691static void indicate_error(char c) 3691static void indicate_error(char c)
3692{ 3692{
3693#ifdef BB_FEATURE_VI_CRASHME 3693#ifdef CONFIG_FEATURE_VI_CRASHME
3694 if (crashme > 0) 3694 if (crashme > 0)
3695 return; // generate a random command 3695 return; // generate a random command
3696#endif /* BB_FEATURE_VI_CRASHME */ 3696#endif /* CONFIG_FEATURE_VI_CRASHME */
3697 if (err_method == 0) { 3697 if (err_method == 0) {
3698 beep(); 3698 beep();
3699 } else { 3699 } else {
@@ -3777,14 +3777,14 @@ static void edit_status(void) // show file status on status line
3777 percent = 100; 3777 percent = 100;
3778 } 3778 }
3779 psb("\"%s\"" 3779 psb("\"%s\""
3780#ifdef BB_FEATURE_VI_READONLY 3780#ifdef CONFIG_FEATURE_VI_READONLY
3781 "%s" 3781 "%s"
3782#endif /* BB_FEATURE_VI_READONLY */ 3782#endif /* CONFIG_FEATURE_VI_READONLY */
3783 "%s line %d of %d --%d%%--", 3783 "%s line %d of %d --%d%%--",
3784 (cfn != 0 ? (char *) cfn : "No file"), 3784 (cfn != 0 ? (char *) cfn : "No file"),
3785#ifdef BB_FEATURE_VI_READONLY 3785#ifdef CONFIG_FEATURE_VI_READONLY
3786 ((vi_readonly == TRUE || readonly == TRUE) ? " [Read only]" : ""), 3786 ((vi_readonly == TRUE || readonly == TRUE) ? " [Read only]" : ""),
3787#endif /* BB_FEATURE_VI_READONLY */ 3787#endif /* CONFIG_FEATURE_VI_READONLY */
3788 (file_modified == TRUE ? " [modified]" : ""), 3788 (file_modified == TRUE ? " [modified]" : ""),
3789 cur, tot, percent); 3789 cur, tot, percent);
3790} 3790}
@@ -3847,13 +3847,13 @@ static void refresh(int full_screen)
3847 int li, changed; 3847 int li, changed;
3848 Byte buf[MAX_SCR_COLS]; 3848 Byte buf[MAX_SCR_COLS];
3849 Byte *tp, *sp; // pointer into text[] and screen[] 3849 Byte *tp, *sp; // pointer into text[] and screen[]
3850#ifdef BB_FEATURE_VI_OPTIMIZE_CURSOR 3850#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR
3851 int last_li= -2; // last line that changed- for optimizing cursor movement 3851 int last_li= -2; // last line that changed- for optimizing cursor movement
3852#endif /* BB_FEATURE_VI_OPTIMIZE_CURSOR */ 3852#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */
3853 3853
3854#ifdef BB_FEATURE_VI_WIN_RESIZE 3854#ifdef CONFIG_FEATURE_VI_WIN_RESIZE
3855 window_size_get(0); 3855 window_size_get(0);
3856#endif /* BB_FEATURE_VI_WIN_RESIZE */ 3856#endif /* CONFIG_FEATURE_VI_WIN_RESIZE */
3857 sync_cursor(dot, &crow, &ccol); // where cursor will be (on "dot") 3857 sync_cursor(dot, &crow, &ccol); // where cursor will be (on "dot")
3858 tp = screenbegin; // index into text[] of top line 3858 tp = screenbegin; // index into text[] of top line
3859 3859
@@ -3916,31 +3916,31 @@ static void refresh(int full_screen)
3916 // to handle offsets correctly 3916 // to handle offsets correctly
3917 place_cursor(li, cs, FALSE); 3917 place_cursor(li, cs, FALSE);
3918 } else { 3918 } else {
3919#ifdef BB_FEATURE_VI_OPTIMIZE_CURSOR 3919#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR
3920 // if this just the next line 3920 // if this just the next line
3921 // try to optimize cursor movement 3921 // try to optimize cursor movement
3922 // otherwise, use standard ESC sequence 3922 // otherwise, use standard ESC sequence
3923 place_cursor(li, cs, li == (last_li+1) ? TRUE : FALSE); 3923 place_cursor(li, cs, li == (last_li+1) ? TRUE : FALSE);
3924 last_li= li; 3924 last_li= li;
3925#else /* BB_FEATURE_VI_OPTIMIZE_CURSOR */ 3925#else /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */
3926 place_cursor(li, cs, FALSE); // use standard ESC sequence 3926 place_cursor(li, cs, FALSE); // use standard ESC sequence
3927#endif /* BB_FEATURE_VI_OPTIMIZE_CURSOR */ 3927#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */
3928 } 3928 }
3929 3929
3930 // write line out to terminal 3930 // write line out to terminal
3931 write(1, sp+cs, ce-cs+1); 3931 write(1, sp+cs, ce-cs+1);
3932#ifdef BB_FEATURE_VI_OPTIMIZE_CURSOR 3932#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR
3933 last_row = li; 3933 last_row = li;
3934#endif /* BB_FEATURE_VI_OPTIMIZE_CURSOR */ 3934#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */
3935 } 3935 }
3936 } 3936 }
3937 3937
3938#ifdef BB_FEATURE_VI_OPTIMIZE_CURSOR 3938#ifdef CONFIG_FEATURE_VI_OPTIMIZE_CURSOR
3939 place_cursor(crow, ccol, (crow == last_row) ? TRUE : FALSE); 3939 place_cursor(crow, ccol, (crow == last_row) ? TRUE : FALSE);
3940 last_row = crow; 3940 last_row = crow;
3941#else 3941#else
3942 place_cursor(crow, ccol, FALSE); 3942 place_cursor(crow, ccol, FALSE);
3943#endif /* BB_FEATURE_VI_OPTIMIZE_CURSOR */ 3943#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */
3944 3944
3945 if (offset != old_offset) 3945 if (offset != old_offset)
3946 old_offset = offset; 3946 old_offset = offset;