Fix vi so that error messages, insert mode messages, etc are
all actually displayed in the status line as expected
This commit is contained in:
parent
2ada89b60f
commit
0ef24c672a
49
editors/vi.c
49
editors/vi.c
@ -344,6 +344,7 @@ extern int vi_main(int argc, char **argv)
|
|||||||
#endif /* CONFIG_FEATURE_VI_CRASHME */
|
#endif /* CONFIG_FEATURE_VI_CRASHME */
|
||||||
|
|
||||||
status_buffer = STATUS_BUFFER;
|
status_buffer = STATUS_BUFFER;
|
||||||
|
*status_buffer = '\0'; // clear status buffer
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_VI_READONLY
|
#ifdef CONFIG_FEATURE_VI_READONLY
|
||||||
vi_readonly = readonly = FALSE;
|
vi_readonly = readonly = FALSE;
|
||||||
@ -462,7 +463,6 @@ static void edit_file(Byte * fn)
|
|||||||
last_forward_char = last_input_char = '\0';
|
last_forward_char = last_input_char = '\0';
|
||||||
crow = 0;
|
crow = 0;
|
||||||
ccol = 0;
|
ccol = 0;
|
||||||
edit_status();
|
|
||||||
|
|
||||||
#ifdef CONFIG_FEATURE_VI_USE_SIGNALS
|
#ifdef CONFIG_FEATURE_VI_USE_SIGNALS
|
||||||
catch_sig(0);
|
catch_sig(0);
|
||||||
@ -506,6 +506,7 @@ static void edit_file(Byte * fn)
|
|||||||
adding2q = 0;
|
adding2q = 0;
|
||||||
#endif /* CONFIG_FEATURE_VI_DOT_CMD */
|
#endif /* CONFIG_FEATURE_VI_DOT_CMD */
|
||||||
redraw(FALSE); // dont force every col re-draw
|
redraw(FALSE); // dont force every col re-draw
|
||||||
|
edit_status();
|
||||||
show_status_line();
|
show_status_line();
|
||||||
|
|
||||||
//------This is the main Vi cmd handling loop -----------------------
|
//------This is the main Vi cmd handling loop -----------------------
|
||||||
@ -871,6 +872,7 @@ static void colon(Byte * buf)
|
|||||||
} else {
|
} else {
|
||||||
// user wants file status info
|
// user wants file status info
|
||||||
edit_status();
|
edit_status();
|
||||||
|
show_status_line();
|
||||||
}
|
}
|
||||||
} else if (strncasecmp((char *) cmd, "features", i) == 0) { // what features are available
|
} else if (strncasecmp((char *) cmd, "features", i) == 0) { // what features are available
|
||||||
// print out values of all features
|
// print out values of all features
|
||||||
@ -1333,22 +1335,30 @@ static void dot_left(void)
|
|||||||
{
|
{
|
||||||
if (dot > text && dot[-1] != '\n')
|
if (dot > text && dot[-1] != '\n')
|
||||||
dot--;
|
dot--;
|
||||||
|
edit_status(); // show current file status
|
||||||
|
show_status_line();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dot_right(void)
|
static void dot_right(void)
|
||||||
{
|
{
|
||||||
if (dot < end - 1 && *dot != '\n')
|
if (dot < end - 1 && *dot != '\n')
|
||||||
dot++;
|
dot++;
|
||||||
|
edit_status(); // show current file status
|
||||||
|
show_status_line();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dot_begin(void)
|
static void dot_begin(void)
|
||||||
{
|
{
|
||||||
dot = begin_line(dot); // return pointer to first char cur line
|
dot = begin_line(dot); // return pointer to first char cur line
|
||||||
|
edit_status(); // show current file status
|
||||||
|
show_status_line();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dot_end(void)
|
static void dot_end(void)
|
||||||
{
|
{
|
||||||
dot = end_line(dot); // return pointer to last char cur line
|
dot = end_line(dot); // return pointer to last char cur line
|
||||||
|
edit_status(); // show current file status
|
||||||
|
show_status_line();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Byte *move_to_col(Byte * p, int l)
|
static Byte *move_to_col(Byte * p, int l)
|
||||||
@ -1373,11 +1383,15 @@ static Byte *move_to_col(Byte * p, int l)
|
|||||||
static void dot_next(void)
|
static void dot_next(void)
|
||||||
{
|
{
|
||||||
dot = next_line(dot);
|
dot = next_line(dot);
|
||||||
|
edit_status(); // show current file status
|
||||||
|
show_status_line();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dot_prev(void)
|
static void dot_prev(void)
|
||||||
{
|
{
|
||||||
dot = prev_line(dot);
|
dot = prev_line(dot);
|
||||||
|
edit_status(); // show current file status
|
||||||
|
show_status_line();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dot_scroll(int cnt, int dir)
|
static void dot_scroll(int cnt, int dir)
|
||||||
@ -1402,6 +1416,8 @@ static void dot_scroll(int cnt, int dir)
|
|||||||
if (dot > q)
|
if (dot > q)
|
||||||
dot = begin_line(q); // is dot is below bottom line?
|
dot = begin_line(q); // is dot is below bottom line?
|
||||||
dot_skip_over_ws();
|
dot_skip_over_ws();
|
||||||
|
edit_status(); // show current file status
|
||||||
|
show_status_line();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dot_skip_over_ws(void)
|
static void dot_skip_over_ws(void)
|
||||||
@ -1592,7 +1608,7 @@ static Byte *char_insert(Byte * p, Byte c) // insert the char c at 'p'
|
|||||||
cmd_mode = 0;
|
cmd_mode = 0;
|
||||||
cmdcnt = 0;
|
cmdcnt = 0;
|
||||||
end_cmd_q(); // stop adding to q
|
end_cmd_q(); // stop adding to q
|
||||||
strcpy((char *) status_buffer, " "); // clear the status buffer
|
*status_buffer = '\0'; // clear the status buffer
|
||||||
if ((p[-1] != '\n') && (dot>text)) {
|
if ((p[-1] != '\n') && (dot>text)) {
|
||||||
p--;
|
p--;
|
||||||
}
|
}
|
||||||
@ -2659,7 +2675,7 @@ static void show_status_line(void)
|
|||||||
static int last_cksum;
|
static int last_cksum;
|
||||||
int l, cnt, cksum;
|
int l, cnt, cksum;
|
||||||
|
|
||||||
edit_status();
|
//edit_status();
|
||||||
cnt = strlen((char *) status_buffer);
|
cnt = strlen((char *) status_buffer);
|
||||||
for (cksum= l= 0; l < cnt; l++) { cksum += (int)(status_buffer[l]); }
|
for (cksum= l= 0; l < cnt; l++) { cksum += (int)(status_buffer[l]); }
|
||||||
// don't write the status line unless it changes
|
// don't write the status line unless it changes
|
||||||
@ -2681,10 +2697,10 @@ static void psbs(const char *format, ...)
|
|||||||
|
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
strcpy((char *) status_buffer, SOs); // Terminal standout mode on
|
strcpy((char *) status_buffer, SOs); // Terminal standout mode on
|
||||||
vsprintf((char *) status_buffer + strlen((char *) status_buffer), format,
|
vsprintf((char *) status_buffer + strlen((char *) status_buffer), format, args);
|
||||||
args);
|
|
||||||
strcat((char *) status_buffer, SOn); // Terminal standout mode off
|
strcat((char *) status_buffer, SOn); // Terminal standout mode off
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
show_status_line();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2697,6 +2713,7 @@ static void psb(const char *format, ...)
|
|||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vsprintf((char *) status_buffer, format, args);
|
vsprintf((char *) status_buffer, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
show_status_line();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2723,17 +2740,19 @@ static void edit_status(void) // show file status on status line
|
|||||||
cur = tot = 0;
|
cur = tot = 0;
|
||||||
percent = 100;
|
percent = 100;
|
||||||
}
|
}
|
||||||
psb("\"%s\""
|
|
||||||
|
sprintf((char *) status_buffer,
|
||||||
|
"\"%s\""
|
||||||
#ifdef CONFIG_FEATURE_VI_READONLY
|
#ifdef CONFIG_FEATURE_VI_READONLY
|
||||||
"%s"
|
"%s"
|
||||||
#endif /* CONFIG_FEATURE_VI_READONLY */
|
#endif /* CONFIG_FEATURE_VI_READONLY */
|
||||||
"%s line %d of %d --%d%%--",
|
"%s line %d of %d --%d%%--",
|
||||||
(cfn != 0 ? (char *) cfn : "No file"),
|
(cfn != 0 ? (char *) cfn : "No file"),
|
||||||
#ifdef CONFIG_FEATURE_VI_READONLY
|
#ifdef CONFIG_FEATURE_VI_READONLY
|
||||||
((vi_readonly || readonly) ? " [Read only]" : ""),
|
((vi_readonly || readonly) ? " [Read only]" : ""),
|
||||||
#endif /* CONFIG_FEATURE_VI_READONLY */
|
#endif /* CONFIG_FEATURE_VI_READONLY */
|
||||||
(file_modified ? " [modified]" : ""),
|
(file_modified ? " [modified]" : ""),
|
||||||
cur, tot, percent);
|
cur, tot, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----- Force refresh of all Lines -----------------------------
|
//----- Force refresh of all Lines -----------------------------
|
||||||
@ -2879,6 +2898,8 @@ static void refresh(int full_screen)
|
|||||||
#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */
|
#endif /* CONFIG_FEATURE_VI_OPTIMIZE_CURSOR */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
edit_status(); // show current file status
|
||||||
|
show_status_line();
|
||||||
// write line out to terminal
|
// write line out to terminal
|
||||||
{
|
{
|
||||||
int nic = ce-cs+1;
|
int nic = ce-cs+1;
|
||||||
@ -3058,6 +3079,7 @@ key_cmd_mode:
|
|||||||
break;
|
break;
|
||||||
case 7: // ctrl-G show current status
|
case 7: // ctrl-G show current status
|
||||||
edit_status();
|
edit_status();
|
||||||
|
show_status_line();
|
||||||
break;
|
break;
|
||||||
case 'h': // h- move left
|
case 'h': // h- move left
|
||||||
case VI_K_LEFT: // cursor key Left
|
case VI_K_LEFT: // cursor key Left
|
||||||
@ -3067,6 +3089,8 @@ key_cmd_mode:
|
|||||||
do_cmd(c);
|
do_cmd(c);
|
||||||
} // repeat cnt
|
} // repeat cnt
|
||||||
dot_left();
|
dot_left();
|
||||||
|
edit_status(); // show current file status
|
||||||
|
show_status_line();
|
||||||
break;
|
break;
|
||||||
case 10: // Newline ^J
|
case 10: // Newline ^J
|
||||||
case 'j': // j- goto next line, same col
|
case 'j': // j- goto next line, same col
|
||||||
@ -3383,6 +3407,7 @@ key_cmd_mode:
|
|||||||
}
|
}
|
||||||
} else if (strncasecmp((char *) p, "file", cnt) == 0 ) {
|
} else if (strncasecmp((char *) p, "file", cnt) == 0 ) {
|
||||||
edit_status(); // show current file status
|
edit_status(); // show current file status
|
||||||
|
show_status_line();
|
||||||
} else if (sscanf((char *) p, "%d", &j) > 0) {
|
} else if (sscanf((char *) p, "%d", &j) > 0) {
|
||||||
dot = find_line(j); // go to line # j
|
dot = find_line(j); // go to line # j
|
||||||
dot_skip_over_ws();
|
dot_skip_over_ws();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user