vi: rename save_argc -> cmdline_filecnt
function old new delta vi_main 272 273 +1 colon 2852 2853 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
bbacd03ccc
commit
8939359180
33
editors/vi.c
33
editors/vi.c
@ -301,7 +301,7 @@ struct globals {
|
|||||||
smallint cmd_mode; // 0=command 1=insert 2=replace
|
smallint cmd_mode; // 0=command 1=insert 2=replace
|
||||||
int modified_count; // buffer contents changed if !0
|
int modified_count; // buffer contents changed if !0
|
||||||
int last_modified_count; // = -1;
|
int last_modified_count; // = -1;
|
||||||
int save_argc; // how many file names on cmd line
|
int cmdline_filecnt; // how many file names on cmd line
|
||||||
int cmdcnt; // repetition count
|
int cmdcnt; // repetition count
|
||||||
unsigned rows, columns; // the terminal screen is this size
|
unsigned rows, columns; // the terminal screen is this size
|
||||||
#if ENABLE_FEATURE_VI_ASK_TERMINAL
|
#if ENABLE_FEATURE_VI_ASK_TERMINAL
|
||||||
@ -416,7 +416,7 @@ struct globals {
|
|||||||
#define cmd_mode (G.cmd_mode )
|
#define cmd_mode (G.cmd_mode )
|
||||||
#define modified_count (G.modified_count )
|
#define modified_count (G.modified_count )
|
||||||
#define last_modified_count (G.last_modified_count)
|
#define last_modified_count (G.last_modified_count)
|
||||||
#define save_argc (G.save_argc )
|
#define cmdline_filecnt (G.cmdline_filecnt )
|
||||||
#define cmdcnt (G.cmdcnt )
|
#define cmdcnt (G.cmdcnt )
|
||||||
#define rows (G.rows )
|
#define rows (G.rows )
|
||||||
#define columns (G.columns )
|
#define columns (G.columns )
|
||||||
@ -2367,7 +2367,7 @@ static void colon(char *buf)
|
|||||||
} else {
|
} else {
|
||||||
modified_count = 0;
|
modified_count = 0;
|
||||||
last_modified_count = -1;
|
last_modified_count = -1;
|
||||||
status_line("'%s' %dL, %dC",
|
status_line("'%s' %uL, %uC",
|
||||||
current_filename,
|
current_filename,
|
||||||
count_lines(text, end - 1), cnt
|
count_lines(text, end - 1), cnt
|
||||||
);
|
);
|
||||||
@ -2538,7 +2538,7 @@ static void colon(char *buf)
|
|||||||
li = count_lines(text, end - 1);
|
li = count_lines(text, end - 1);
|
||||||
status_line("'%s'%s"
|
status_line("'%s'%s"
|
||||||
IF_FEATURE_VI_READONLY("%s")
|
IF_FEATURE_VI_READONLY("%s")
|
||||||
" %dL, %dC",
|
" %uL, %uC",
|
||||||
current_filename,
|
current_filename,
|
||||||
(size < 0 ? " [New file]" : ""),
|
(size < 0 ? " [New file]" : ""),
|
||||||
IF_FEATURE_VI_READONLY(
|
IF_FEATURE_VI_READONLY(
|
||||||
@ -2604,7 +2604,7 @@ static void colon(char *buf)
|
|||||||
if (useforce) {
|
if (useforce) {
|
||||||
if (*cmd == 'q') {
|
if (*cmd == 'q') {
|
||||||
// force end of argv list
|
// force end of argv list
|
||||||
optind = save_argc;
|
optind = cmdline_filecnt - 1;
|
||||||
}
|
}
|
||||||
editing = 0;
|
editing = 0;
|
||||||
goto ret;
|
goto ret;
|
||||||
@ -2615,9 +2615,9 @@ static void colon(char *buf)
|
|||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
// are there other file to edit
|
// are there other file to edit
|
||||||
n = save_argc - optind - 1;
|
n = cmdline_filecnt - optind - 1;
|
||||||
if (*cmd == 'q' && n > 0) {
|
if (*cmd == 'q' && n > 0) {
|
||||||
status_line_bold("%d more file(s) to edit", n);
|
status_line_bold("%u more file(s) to edit", n);
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
if (*cmd == 'n' && n <= 0) {
|
if (*cmd == 'n' && n <= 0) {
|
||||||
@ -2662,7 +2662,7 @@ static void colon(char *buf)
|
|||||||
li = count_lines(q, q + size - 1);
|
li = count_lines(q, q + size - 1);
|
||||||
status_line("'%s'"
|
status_line("'%s'"
|
||||||
IF_FEATURE_VI_READONLY("%s")
|
IF_FEATURE_VI_READONLY("%s")
|
||||||
" %dL, %dC",
|
" %uL, %uC",
|
||||||
fn,
|
fn,
|
||||||
IF_FEATURE_VI_READONLY((readonly_mode ? " [Readonly]" : ""),)
|
IF_FEATURE_VI_READONLY((readonly_mode ? " [Readonly]" : ""),)
|
||||||
li, size
|
li, size
|
||||||
@ -2834,7 +2834,7 @@ static void colon(char *buf)
|
|||||||
} else {
|
} else {
|
||||||
// how many lines written
|
// how many lines written
|
||||||
li = count_lines(q, q + l - 1);
|
li = count_lines(q, q + l - 1);
|
||||||
status_line("'%s' %dL, %dC", fn, li, l);
|
status_line("'%s' %uL, %uC", fn, li, l);
|
||||||
if (l == size) {
|
if (l == size) {
|
||||||
if (q == text && q + l == end) {
|
if (q == text && q + l == end) {
|
||||||
modified_count = 0;
|
modified_count = 0;
|
||||||
@ -4368,23 +4368,22 @@ int vi_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The argv array can be used by the ":next" and ":rewind" commands
|
|
||||||
argv += optind;
|
argv += optind;
|
||||||
argc -= optind;
|
cmdline_filecnt = argc - optind;
|
||||||
|
|
||||||
//----- This is the main file handling loop --------------
|
|
||||||
save_argc = argc;
|
|
||||||
optind = 0;
|
|
||||||
// "Save cursor, use alternate screen buffer, clear screen"
|
// "Save cursor, use alternate screen buffer, clear screen"
|
||||||
write1(ESC"[?1049h");
|
write1(ESC"[?1049h");
|
||||||
|
// This is the main file handling loop
|
||||||
|
optind = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
edit_file(argv[optind]); // param might be NULL
|
edit_file(argv[optind]); // might be NULL on 1st iteration
|
||||||
if (++optind >= argc)
|
// NB: optind can be changed by ":next" and ":rewind" commands
|
||||||
|
optind++;
|
||||||
|
if (!argv[optind])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// "Use normal screen buffer, restore cursor"
|
// "Use normal screen buffer, restore cursor"
|
||||||
write1(ESC"[?1049l");
|
write1(ESC"[?1049l");
|
||||||
//-----------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user