*/
static const char vi_Version[] =
- "$Id: vi.c,v 1.31 2004/01/21 10:59:45 bug1 Exp $";
+ "$Id: vi.c,v 1.37 2004/07/20 06:44:46 andersen Exp $";
/*
* To compile for standalone use:
* An "ex" line oriented mode- maybe using "cmdedit"
*/
-//---- Feature -------------- Bytes to immplement
+//---- Feature -------------- Bytes to implement
#ifdef STANDALONE
#define vi_main main
#define CONFIG_FEATURE_VI_COLON // 4288
#ifdef CONFIG_FEATURE_VI_READONLY
case 'R': // Read-only flag
readonly = TRUE;
+ vi_readonly = TRUE;
break;
#endif /* CONFIG_FEATURE_VI_READONLY */
//case 'r': // recover flag- ignore- we don't use tmp file
p = get_one_address(p, b);
while (isblnk(*p))
p++;
- if (*p == ',') { // is there a address seperator
+ if (*p == ',') { // is there a address separator
p++;
while (isblnk(*p))
p++;
// :s/find/replace/ // substitute pattern "find" with "replace"
// :!<cmd> // run <cmd> then return
//
+ forced = useforce = FALSE;
+
if (strlen((char *) buf) <= 0)
goto vc1;
if (*buf == ':')
buf++; // move past the ':'
- forced = useforce = FALSE;
li = st = ch = i = 0;
b = e = -1;
q = text; // assume 1,$ for the range
screen = (Byte *) xmalloc(screensize);
// initialize the new screen. assume this will be a empty file.
screen_erase();
- // non-existant text[] lines start with a tilde (~).
+ // non-existent text[] lines start with a tilde (~).
for (li = 1; li < ro - 1; li++) {
screen[(li * co) + 0] = '~';
}
q = dot;
} else if (strchr("wW", c)) {
do_cmd(c); // execute movement cmd
- // if we are at the next word's first char
- // step back one char
- if (dot > text && isspace(dot[-1]))
- dot--; // move back off of next word
+ // if we are at the next word's first char
+ // step back one char
+ // but check the possibilities when it is true
+ if (dot > text && ((isspace(dot[-1]) && !isspace(dot[0]))
+ || (ispunct(dot[-1]) && !ispunct(dot[0]))
+ || (isalnum(dot[-1]) && !isalnum(dot[0]))))
+ dot--; // move back off of next word
if (dot > text && *dot == '\n')
dot--; // stay off NL
q = dot;
//----- Terminal Drawing ---------------------------------------
// The terminal is made up of 'rows' line of 'columns' columns.
-// classicly this would be 24 x 80.
+// classically this would be 24 x 80.
// screen coordinates
// 0,0 ... 0,79
// 1,0 ... 1,79
// char cm3[BUFSIZ];
int Rrow= last_row;
#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */
-
+
memset(cm1, '\0', BUFSIZ - 1); // clear the buffer
if (row < 0) row = 0;
if (row >= rows) row = rows - 1;
if (col < 0) col = 0;
if (col >= columns) col = columns - 1;
-
+
//----- 1. Try the standard terminal ESC sequence
sprintf((char *) cm1, CMrc, row + 1, col + 1);
cm= cm1;
//----- find the minimum # of chars to move cursor -------------
//----- 2. Try moving with discreet chars (Newline, [back]space, ...)
memset(cm2, '\0', BUFSIZ - 1); // clear the buffer
-
+
// move to the correct row
while (row < Rrow) {
// the cursor has to move up
strcat(cm2, CMdown);
Rrow++;
}
-
+
// now move to the correct column
strcat(cm2, "\r"); // start at col 0
// just send out orignal source char to get to correct place
{
int co;
Byte c;
-
+
for (co= 0; co < MAX_SCR_COLS; co++) {
c= ' '; // assume blank
if (li > 0 && co == 0) {
#else
place_cursor(crow, ccol, FALSE);
#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */
-
+
if (offset != old_offset)
old_offset = offset;
}
//case 0x1d: // gs
//case 0x1e: // rs
//case 0x1f: // us
- //case '!': // !-
- //case '#': // #-
- //case '&': // &-
- //case '(': // (-
- //case ')': // )-
- //case '*': // *-
- //case ',': // ,-
- //case '=': // =-
- //case '@': // @-
- //case 'F': // F-
- //case 'K': // K-
- //case 'Q': // Q-
- //case 'S': // S-
- //case 'T': // T-
- //case 'V': // V-
- //case '[': // [-
- //case '\\': // \-
- //case ']': // ]-
- //case '_': // _-
- //case '`': // `-
- //case 'g': // g-
+ //case '!': // !-
+ //case '#': // #-
+ //case '&': // &-
+ //case '(': // (-
+ //case ')': // )-
+ //case '*': // *-
+ //case ',': // ,-
+ //case '=': // =-
+ //case '@': // @-
+ //case 'F': // F-
+ //case 'K': // K-
+ //case 'Q': // Q-
+ //case 'S': // S-
+ //case 'T': // T-
+ //case 'V': // V-
+ //case '[': // [-
+ //case '\\': // \-
+ //case ']': // ]-
+ //case '_': // _-
+ //case '`': // `-
+ //case 'g': // g-
//case 'u': // u- FIXME- there is no undo
- //case 'v': // v-
+ //case 'v': // v-
default: // unrecognised command
buf[0] = c;
buf[1] = '\0';
case 'f': // f- forward to a user specified char
last_forward_char = get_one_char(); // get the search char
//
- // dont seperate these two commands. 'f' depends on ';'
+ // dont separate these two commands. 'f' depends on ';'
//
//**** fall thru to ... 'i'
case ';': // ;- look at rest of line for last forward char
break;
#endif /* CONFIG_FEATURE_VI_SEARCH */
case '0': // 0- goto begining of line
- case '1': // 1-
- case '2': // 2-
- case '3': // 3-
- case '4': // 4-
- case '5': // 5-
- case '6': // 6-
- case '7': // 7-
- case '8': // 8-
- case '9': // 9-
+ case '1': // 1-
+ case '2': // 2-
+ case '3': // 3-
+ case '4': // 4-
+ case '5': // 5-
+ case '6': // 6-
+ case '7': // 7-
+ case '8': // 8-
+ case '9': // 9-
if (c == '0' && cmdcnt < 1) {
dot_begin(); // this was a standalone zero
} else {