version 1.1, 1996/09/07 21:40:26 |
version 1.2, 1996/09/21 06:22:57 |
|
|
char_u *complete_pat = NULL; |
char_u *complete_pat = NULL; |
char_u *tmp_ptr; |
char_u *tmp_ptr; |
char_u *mesg = NULL; /* Message about completion */ |
char_u *mesg = NULL; /* Message about completion */ |
char_u *quick_m; /* Message without sleep */ |
|
int started_completion = FALSE; |
int started_completion = FALSE; |
colnr_t complete_col = 0; /* init for gcc */ |
colnr_t complete_col = 0; /* init for gcc */ |
int complete_direction; |
int complete_direction; |
|
|
#endif |
#endif |
FPOS tpos; |
FPOS tpos; |
|
|
/* sleep before redrawing, needed for "CTRL-O :" that results in an |
|
* error message */ |
|
if (msg_scroll || emsg_on_display) |
|
{ |
|
mch_delay(1000L, TRUE); |
|
msg_scroll = FALSE; |
|
emsg_on_display = FALSE; |
|
} |
|
#ifdef SLEEP_IN_EMSG |
|
if (need_sleep) |
|
{ |
|
mch_delay(1000L, TRUE); |
|
need_sleep = FALSE; |
|
} |
|
#endif |
|
|
|
#ifdef USE_MOUSE |
#ifdef USE_MOUSE |
/* |
/* |
* When doing a paste with the middle mouse button, Insstart is set to |
* When doing a paste with the middle mouse button, Insstart is set to |
|
|
can_cindent = TRUE; |
can_cindent = TRUE; |
#endif |
#endif |
|
|
|
/* |
|
* If 'showmode' is set, show the current (insert/replace/..) mode. |
|
* A warning message for changing a readonly file is given here, before |
|
* actually changing anything. It's put after the mode, if any. |
|
*/ |
|
i = 0; |
if (p_smd) |
if (p_smd) |
showmode(); |
i = showmode(); |
|
|
if (!p_im) |
if (!p_im) |
change_warning(); /* give a warning if readonly */ |
change_warning(i + 1); |
|
|
#ifdef DIGRAPHS |
#ifdef DIGRAPHS |
do_digraph(-1); /* clear digraphs */ |
do_digraph(-1); /* clear digraphs */ |
|
|
else if (p_smd) |
else if (p_smd) |
MSG(""); |
MSG(""); |
old_indent = 0; |
old_indent = 0; |
|
|
|
/* |
|
* This is the ONLY return from edit(). |
|
*/ |
return (c == Ctrl('O')); |
return (c == Ctrl('O')); |
|
|
/* |
/* |
|
|
break; |
break; |
|
|
case K_HOME: |
case K_HOME: |
|
case K_KHOME: |
undisplay_dollar(); |
undisplay_dollar(); |
tpos = curwin->w_cursor; |
tpos = curwin->w_cursor; |
if ((mod_mask & MOD_MASK_CTRL)) |
if ((mod_mask & MOD_MASK_CTRL)) |
|
|
break; |
break; |
|
|
case K_END: |
case K_END: |
|
case K_KEND: |
undisplay_dollar(); |
undisplay_dollar(); |
tpos = curwin->w_cursor; |
tpos = curwin->w_cursor; |
if ((mod_mask & MOD_MASK_CTRL)) |
if ((mod_mask & MOD_MASK_CTRL)) |
|
|
|
|
case K_S_UP: |
case K_S_UP: |
case K_PAGEUP: |
case K_PAGEUP: |
|
case K_KPAGEUP: |
undisplay_dollar(); |
undisplay_dollar(); |
tpos = curwin->w_cursor; |
tpos = curwin->w_cursor; |
if (onepage(BACKWARD, 1L) == OK) |
if (onepage(BACKWARD, 1L) == OK) |
|
|
|
|
case K_S_DOWN: |
case K_S_DOWN: |
case K_PAGEDOWN: |
case K_PAGEDOWN: |
|
case K_KPAGEDOWN: |
undisplay_dollar(); |
undisplay_dollar(); |
tpos = curwin->w_cursor; |
tpos = curwin->w_cursor; |
if (onepage(FORWARD, 1L) == OK) |
if (onepage(FORWARD, 1L) == OK) |
|
|
complete_direction = BACKWARD; |
complete_direction = BACKWARD; |
else |
else |
complete_direction = FORWARD; |
complete_direction = FORWARD; |
quick_m = mesg = NULL; /* No message by default */ |
mesg = NULL; /* No message by default */ |
if (!started_completion) |
if (!started_completion) |
{ |
{ |
/* First time we hit ^N or ^P (in a row, I mean) */ |
/* First time we hit ^N or ^P (in a row, I mean) */ |
|
|
set_reg_ic(complete_pat); |
set_reg_ic(complete_pat); |
prog = vim_regcomp(complete_pat); |
prog = vim_regcomp(complete_pat); |
if (prog != NULL && |
if (prog != NULL && |
find_tags(NULL, prog, &num_matches, &matches, FALSE) |
find_tags(NULL, prog, &num_matches, &matches, |
== OK && num_matches > 0) |
FALSE, FALSE) == OK && num_matches > 0) |
{ |
{ |
for (i = 0; i < num_matches; i++) |
for (i = 0; i < num_matches; i++) |
if (add_completion(matches[i], -1, NULL, |
if (add_completion(matches[i], -1, NULL, |
|
|
if (ExpandWildCards(1, &complete_pat, &num_matches, |
if (ExpandWildCards(1, &complete_pat, &num_matches, |
&matches, FALSE, FALSE) == OK) |
&matches, FALSE, FALSE) == OK) |
{ |
{ |
|
/* |
|
* May change home directory back to "~". |
|
*/ |
|
tilde_replace(complete_pat, num_matches, matches); |
for (i = 0; i < num_matches; i++) |
for (i = 0; i < num_matches; i++) |
if (add_completion(matches[i], -1, NULL, |
if (add_completion(matches[i], -1, NULL, |
FORWARD) == RET_ERROR) |
FORWARD) == RET_ERROR) |
|
|
complete_pos = NULL; |
complete_pos = NULL; |
if (started_completion && curr_match == NULL && |
if (started_completion && curr_match == NULL && |
(p_ws || done_dir == BOTH_DIRECTIONS)) |
(p_ws || done_dir == BOTH_DIRECTIONS)) |
quick_m = e_patnotf; |
{ |
|
edit_submode_extra = e_patnotf; |
|
edit_submode_highl = TRUE; |
|
} |
else if (curr_match != NULL && complete_direction == FORWARD && |
else if (curr_match != NULL && complete_direction == FORWARD && |
curr_match->next != NULL) |
curr_match->next != NULL) |
curr_match = curr_match->next; |
curr_match = curr_match->next; |
|
|
mesg = IObuff; |
mesg = IObuff; |
} |
} |
else if (tot == 0) |
else if (tot == 0) |
quick_m = e_patnotf; |
{ |
|
edit_submode_extra = e_patnotf; |
|
edit_submode_highl = TRUE; |
|
} |
} |
} |
|
|
/* eat the ESC to avoid leaving insert mode */ |
/* eat the ESC to avoid leaving insert mode */ |
|
|
else /* back to what has been typed */ |
else /* back to what has been typed */ |
ptr = original_text; |
ptr = original_text; |
|
|
if (curr_match == NULL || curr_match->original) |
if (edit_submode_extra == NULL) |
{ |
{ |
edit_submode_extra = (char_u *)"Back at original"; |
if (curr_match == NULL || curr_match->original) |
edit_submode_highl = TRUE; |
{ |
|
edit_submode_extra = (char_u *)"Back at original"; |
|
edit_submode_highl = TRUE; |
|
} |
|
else if (first_match != NULL && |
|
first_match->next != NULL && |
|
(first_match->next == first_match || |
|
first_match->next->original)) |
|
{ |
|
edit_submode_extra = (char_u *)"(the only match)"; |
|
edit_submode_highl = FALSE; |
|
} |
} |
} |
else if (first_match != NULL && first_match->next != NULL && |
|
(first_match->next == first_match || |
|
first_match->next->original)) |
|
{ |
|
edit_submode_extra = (char_u *)"(the only match)"; |
|
edit_submode_highl = FALSE; |
|
} |
|
|
|
/* |
/* |
* Use ins_char() to insert the text, it is a bit slower than |
* Use ins_char() to insert the text, it is a bit slower than |
|
|
|
|
started_completion = TRUE; |
started_completion = TRUE; |
need_redraw = TRUE; |
need_redraw = TRUE; |
(void)set_highlight('r'); |
|
msg_highlight = TRUE; |
|
if (mesg != NULL) |
if (mesg != NULL) |
{ |
{ |
|
(void)set_highlight('r'); |
|
msg_highlight = TRUE; |
msg(mesg); |
msg(mesg); |
mch_delay(1000L, FALSE); |
mch_delay(2000L, FALSE); |
} |
} |
else if (quick_m != NULL) |
if (edit_submode_extra != NULL) |
msg(quick_m); |
{ |
else if (edit_submode_extra != NULL) |
|
showmode(); |
showmode(); |
edit_submode_extra = NULL; |
edit_submode_extra = NULL; |
msg_highlight = FALSE; |
} |
|
|
/* |
/* |
* If there is a file name for the match, overwrite any |
* If there is a file name for the match, overwrite any |
|
|
* Truncate the file name to avoid a wait for return. |
* Truncate the file name to avoid a wait for return. |
*/ |
*/ |
if (curr_match != NULL && curr_match->fname != NULL && |
if (curr_match != NULL && curr_match->fname != NULL && |
(ctrl_x_mode != CTRL_X_DICTIONARY || |
(ctrl_x_mode != CTRL_X_DICTIONARY || mesg == NULL)) |
(mesg == NULL && quick_m == NULL))) |
|
{ |
{ |
STRCPY(IObuff, "match in file "); |
STRCPY(IObuff, "match in file "); |
i = (strsize(curr_match->fname) + 16) - sc_col; |
i = (strsize(curr_match->fname) + 16) - sc_col; |
|
|
STRCAT(IObuff, "<"); |
STRCAT(IObuff, "<"); |
STRCAT(IObuff, curr_match->fname + i); |
STRCAT(IObuff, curr_match->fname + i); |
msg(IObuff); |
msg(IObuff); |
|
redraw_cmdline = FALSE; /* don't overwrite! */ |
} |
} |
|
|
break; |
break; |
#endif /* INSERT_EXPAND */ |
#endif /* INSERT_EXPAND */ |
|
|
|
|
* oneright oneleft cursor_down cursor_up |
* oneright oneleft cursor_down cursor_up |
* |
* |
* Move one char {right,left,down,up}. |
* Move one char {right,left,down,up}. |
* Return OK when sucessful, FAIL when we hit a line of file boundary. |
* Return OK when successful, FAIL when we hit a line of file boundary. |
*/ |
*/ |
|
|
int |
int |
|
|
return FAIL; |
return FAIL; |
for ( ; count > 0; --count) |
for ( ; count > 0; --count) |
{ |
{ |
if (dir == FORWARD ? (curwin->w_topline >= |
/* |
curbuf->b_ml.ml_line_count - 1) : (curwin->w_topline == 1)) |
* It's an error to move a page up when the first line is already on |
|
* the screen. It's an error to move a page down when the last line |
|
* is on the screen and the topline is 'scrolloff' lines from the |
|
* last line. |
|
*/ |
|
if (dir == FORWARD |
|
? ((curwin->w_topline >= curbuf->b_ml.ml_line_count - p_so) && |
|
curwin->w_botline > curbuf->b_ml.ml_line_count) |
|
: (curwin->w_topline == 1)) |
{ |
{ |
beep_flush(); |
beep_flush(); |
return FAIL; |
return FAIL; |
|
|
/* at end of file */ |
/* at end of file */ |
if (curwin->w_botline > curbuf->b_ml.ml_line_count) |
if (curwin->w_botline > curbuf->b_ml.ml_line_count) |
curwin->w_topline = curbuf->b_ml.ml_line_count; |
curwin->w_topline = curbuf->b_ml.ml_line_count; |
/* next line is big */ |
|
/* or just three lines on screen */ |
|
else |
else |
{ |
{ |
if (plines(curwin->w_botline) >= curwin->w_height - 2 || |
/* |
curwin->w_botline - curwin->w_topline <= 3) |
* When there are three or less lines on the screen, move them |
|
* all to above the screen. |
|
*/ |
|
if (curwin->w_botline - curwin->w_topline <= 3) |
off = 0; |
off = 0; |
|
/* |
|
* Make sure at least w_botline gets onto the screen, also |
|
* when 'scrolloff' is non-zero and with very long lines. |
|
*/ |
|
else if (plines(curwin->w_botline) + |
|
plines(curwin->w_botline - 1) + |
|
plines(curwin->w_botline - 2) >= curwin->w_height - 2) |
|
off = 0; |
else |
else |
off = 2; |
off = 2; |
curwin->w_topline = curwin->w_botline - off; |
curwin->w_topline = curwin->w_botline - off; |
|
|
} |
} |
cursor_correct(); |
cursor_correct(); |
beginline(MAYBE); |
beginline(MAYBE); |
|
/* |
|
* Avoid the screen jumping up and down when 'scrolloff' is non-zero. |
|
*/ |
|
if (dir == FORWARD && curwin->w_cursor.lnum < curwin->w_topline + p_so) |
|
scroll_cursor_top(1, FALSE); |
updateScreen(VALID); |
updateScreen(VALID); |
return OK; |
return OK; |
} |
} |