At LONG last committed David's patch
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@912 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Этот коммит содержится в:
родитель
3795e5fc76
Коммит
2084acc37d
10
ChangeLog
10
ChangeLog
@ -4,7 +4,10 @@ CVS Code -
|
||||
colortoint() and parse_color() in rcfile.c, new code in
|
||||
edit_add() in winio.c to actually do the highlighting. It's
|
||||
not even close to pretty yet :P
|
||||
- Many int/long alignments (David Lawrence Ramsey).
|
||||
- files.c:
|
||||
- Fixes for tab completion and screen refresh (David Lawrence
|
||||
Ramsey).
|
||||
add_open_file()
|
||||
- Get rid of unsetting MARK_ISSET because otherwise writing
|
||||
marked text will automatically unset the marker with
|
||||
@ -22,6 +25,11 @@ CVS Code -
|
||||
we have _POSIX_VDISABLE or not (more Hurd fixes)
|
||||
help_init()
|
||||
- Typo fixes and additions to the new help texts.
|
||||
do_curpos()
|
||||
- Now takes arg for constant updating to always show the cursor
|
||||
position (David Lawrence Ramsey).
|
||||
do_wrap()
|
||||
- Many fixes (David Lawrence Ramsey).
|
||||
- po/de.po:
|
||||
- German translation updates (Karl Eichwalder).
|
||||
- po/ru.po:
|
||||
@ -82,7 +90,7 @@ nano-1.1.3 - 10/26/2001
|
||||
- Fix incorrect number of rc options (David Lawrence Ramsey).
|
||||
- po/sv.po:
|
||||
- Updated Swedish translation (Christian Rose).
|
||||
- po/sv.po:
|
||||
- po/da.po:
|
||||
- Updated Danish translation (Keld Simonsen).
|
||||
- po/es.po:
|
||||
- Style updates to Spanish translation (Santiago Vila).
|
||||
|
37
files.c
37
files.c
@ -380,7 +380,7 @@ int do_insertfile(int loading_file)
|
||||
that could create them are taken care of elsewhere) */
|
||||
add_open_file(1, 0);
|
||||
|
||||
free_filestruct(current);
|
||||
free_filestruct(fileage);
|
||||
new_file();
|
||||
UNSET(MODIFIED);
|
||||
}
|
||||
@ -461,7 +461,7 @@ int add_open_file(int update, int dup_fix)
|
||||
{
|
||||
filestruct *tmp;
|
||||
|
||||
if (!current || !filename)
|
||||
if (!fileage || !current || !filename)
|
||||
return 1;
|
||||
|
||||
/* first, if duplicate checking is allowed, do it */
|
||||
@ -477,8 +477,8 @@ int add_open_file(int update, int dup_fix)
|
||||
open_files = make_new_node(NULL);
|
||||
|
||||
/* if open_files->file is NULL at the nrealloc() below, we get a
|
||||
segfault */
|
||||
open_files->file = open_files;
|
||||
segfault
|
||||
open_files->file = open_files; */
|
||||
}
|
||||
|
||||
else if (!update) {
|
||||
@ -523,11 +523,9 @@ int add_open_file(int update, int dup_fix)
|
||||
/* save current line number */
|
||||
open_files->lineno = current->lineno;
|
||||
|
||||
/* save current filestruct */
|
||||
/* save current filestruct and restore full file position afterward */
|
||||
open_files->file = nmalloc(sizeof(filestruct));
|
||||
while (current->prev)
|
||||
current = current->prev;
|
||||
open_files->file = copy_filestruct(current);
|
||||
open_files->file = copy_filestruct(fileage);
|
||||
do_gotopos(open_files->lineno, open_files->file_current_x, open_files->file_current_y, open_files->file_placewewant);
|
||||
|
||||
/* save current modification status */
|
||||
@ -584,6 +582,11 @@ int load_open_file(void)
|
||||
coordinate, place we want */
|
||||
do_gotopos(open_files->lineno, open_files->file_current_x, open_files->file_current_y, open_files->file_placewewant);
|
||||
|
||||
/* restore the bottom of the file */
|
||||
filebot = current;
|
||||
while (filebot->next)
|
||||
filebot = filebot->next;
|
||||
|
||||
/* set up modification status and update the titlebar */
|
||||
if (open_files->file_modified)
|
||||
SET(MODIFIED);
|
||||
@ -592,9 +595,11 @@ int load_open_file(void)
|
||||
clearok(topwin, FALSE);
|
||||
titlebar(NULL);
|
||||
|
||||
/* if we're constantly displaying the cursor position, update it */
|
||||
/* if we're constantly displaying the cursor position, update it (and do so
|
||||
unconditionally, in the rare case that the character count is the same
|
||||
but the line count isn't) */
|
||||
if (ISSET(CONSTUPDATE))
|
||||
do_cursorpos();
|
||||
do_cursorpos(0);
|
||||
|
||||
/* now we're done */
|
||||
return 0;
|
||||
@ -1707,7 +1712,7 @@ char **cwd_tab_completion(char *buf, int *num_matches)
|
||||
/* This function now has an arg which refers to how much the
|
||||
* statusbar (place) should be advanced, i.e. the new cursor pos.
|
||||
*/
|
||||
char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
|
||||
char *input_tab(char *buf, int place, int *lastWasTab, int *newplace, int *list)
|
||||
{
|
||||
/* Do TAB completion */
|
||||
static int num_matches = 0, match_matches = 0;
|
||||
@ -1716,6 +1721,8 @@ char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
|
||||
int longestname = 0, is_dir = 0;
|
||||
char *foo;
|
||||
|
||||
*list = 0;
|
||||
|
||||
if (*lastWasTab == FALSE) {
|
||||
char *tmp, *copyto, *matchBuf;
|
||||
|
||||
@ -1846,7 +1853,7 @@ char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
|
||||
/* Ok -- the last char was a TAB. Since they
|
||||
* just hit TAB again, print a list of all the
|
||||
* available choices... */
|
||||
if (matches && num_matches > 0) {
|
||||
if (matches && num_matches > 1) {
|
||||
|
||||
/* Blank the edit window, and print the matches out there */
|
||||
blank_edit();
|
||||
@ -1895,12 +1902,16 @@ char *input_tab(char *buf, int place, int *lastWasTab, int *newplace)
|
||||
}
|
||||
free(foo);
|
||||
wrefresh(edit);
|
||||
*list = 1;
|
||||
} else
|
||||
beep();
|
||||
|
||||
}
|
||||
|
||||
edit_refresh();
|
||||
/* Only refresh the edit window if we don't have a list of filename
|
||||
matches on it */
|
||||
if (*list == 0)
|
||||
edit_refresh();
|
||||
curs_set(1);
|
||||
return buf;
|
||||
}
|
||||
|
2
global.c
2
global.c
@ -363,7 +363,7 @@ void shortcut_init(int unjustify)
|
||||
|
||||
sc_init_one(&main_list[10], NANO_CURSORPOS_KEY, _("Cur Pos"),
|
||||
nano_cursorpos_msg,
|
||||
0, NANO_CURSORPOS_FKEY, 0, VIEW, do_cursorpos);
|
||||
0, NANO_CURSORPOS_FKEY, 0, VIEW, do_cursorpos_void);
|
||||
|
||||
sc_init_one(&main_list[11], NANO_SPELL_KEY, _("To Spell"),
|
||||
nano_spell_msg, 0, NANO_SPELL_FKEY, 0, NOVIEW, do_spell);
|
||||
|
77
nano.c
77
nano.c
@ -996,10 +996,18 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
down = 1;
|
||||
}
|
||||
|
||||
/* Subtract length of original line, plus one for the newline, from
|
||||
totsize. */
|
||||
totsize -= (strlen(inptr->data) + 1);
|
||||
|
||||
temp->data = charalloc(strlen(&inptr->data[current_word_start]) + 1);
|
||||
strcpy(temp->data, &inptr->data[current_word_start]);
|
||||
inptr->data = nrealloc(inptr->data, last_word_end + 2);
|
||||
inptr->data[last_word_end + 1] = 0;
|
||||
|
||||
/* Now add lengths of new lines, plus two for the newlines, to totsize. */
|
||||
totsize += (strlen(inptr->data) + strlen(temp->data) + 2);
|
||||
|
||||
} else
|
||||
/* Category 1b: one word on the line and word not taking up whole line
|
||||
(i.e. there are spaces at the beginning of the line) */
|
||||
@ -1011,9 +1019,6 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
if (current_x >= current_word_start) {
|
||||
right = current_x - current_word_start;
|
||||
|
||||
/* Decrease totsize by the number of spaces we removed, less
|
||||
one for the new line we're replacing the spaces with. */
|
||||
totsize -= (current_word_start - 1);
|
||||
current_x = 0;
|
||||
#ifndef NANO_SMALL
|
||||
if (ISSET(AUTOINDENT)) {
|
||||
@ -1028,8 +1033,15 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
down = 1;
|
||||
}
|
||||
|
||||
/* Subtract length of original line, plus one for the newline, from
|
||||
totsize. */
|
||||
totsize -= (strlen(inptr->data) + 1);
|
||||
|
||||
null_at(&inptr->data, current_x);
|
||||
|
||||
/* Now add lengths of new lines, plus two for the newlines, to totsize. */
|
||||
totsize += (strlen(inptr->data) + strlen(temp->data) + 2);
|
||||
|
||||
if (ISSET(MARK_ISSET) && (mark_beginbuf == inptr)) {
|
||||
mark_beginbuf = temp;
|
||||
mark_beginx = 0;
|
||||
@ -1047,22 +1059,25 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
if (!isspace((int) input_char)) {
|
||||
i = current_word_start - 1;
|
||||
|
||||
/* Decrement totsize each time we remove a space. */
|
||||
while (isspace((int) inptr->data[i])) {
|
||||
i--;
|
||||
totsize--;
|
||||
assert(i >= 0);
|
||||
}
|
||||
/* And increment it to account for the blank line we're
|
||||
replacing the spaces with. */
|
||||
totsize++;
|
||||
} else if (current_x <= last_word_end)
|
||||
i = last_word_end - 1;
|
||||
else
|
||||
i = current_x;
|
||||
|
||||
/* Subtract length of original line, plus one for the newline, from
|
||||
totsize. */
|
||||
totsize -= (strlen(inptr->data) + 1);
|
||||
|
||||
inptr->data = nrealloc(inptr->data, i + 2);
|
||||
inptr->data[i + 1] = 0;
|
||||
|
||||
/* Now add lengths of new lines, plus two for the newlines, to totsize. */
|
||||
totsize += (strlen(inptr->data) + strlen(temp->data) + 2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1089,12 +1104,14 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
i = current_word_start - 1;
|
||||
current_x = current_word_start;
|
||||
|
||||
/* Subtract length of original line, plus one for the newline, from
|
||||
totsize. */
|
||||
totsize -= (strlen(inptr->data) + 1);
|
||||
|
||||
null_at(&inptr->data, current_word_start);
|
||||
|
||||
/* Increment totsize to account for the new line that
|
||||
will be added below, so that it won't end up being
|
||||
short by one. */
|
||||
totsize++;
|
||||
/* Now add lengths of new lines, plus two for the newlines, to totsize. */
|
||||
totsize += (strlen(inptr->data) + strlen(temp->data) + 2);
|
||||
}
|
||||
|
||||
|
||||
@ -1110,17 +1127,20 @@ void do_wrap(filestruct * inptr, char input_char)
|
||||
current_x = current_word_start;
|
||||
i = current_word_start - 1;
|
||||
|
||||
/* Decrement totsize each time we remove a space. */
|
||||
while (isspace((int) inptr->data[i])) {
|
||||
i--;
|
||||
totsize--;
|
||||
assert(i >= 0);
|
||||
inptr->data = nrealloc(inptr->data, i + 2);
|
||||
inptr->data[i + 1] = 0;
|
||||
}
|
||||
/* And increment it to account for the blank line we're
|
||||
replacing the spaces with. */
|
||||
totsize++;
|
||||
|
||||
/* Subtract length of original line, plus one for the newline, from
|
||||
totsize. */
|
||||
totsize -= (strlen(inptr->data) + 1);
|
||||
|
||||
inptr->data = nrealloc(inptr->data, i + 2);
|
||||
inptr->data[i + 1] = 0;
|
||||
|
||||
/* Now add lengths of new lines, plus two for the newlines, to totsize. */
|
||||
totsize += (strlen(inptr->data) + strlen(temp->data) + 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1359,6 +1379,12 @@ int do_delete(void)
|
||||
{
|
||||
filestruct *foo;
|
||||
|
||||
/* blbf -> blank line before filebot (see below) */
|
||||
int blbf = 0;
|
||||
|
||||
if (current->next == filebot && !strcmp(current->data, ""))
|
||||
blbf = 1;
|
||||
|
||||
if (current_x != strlen(current->data)) {
|
||||
/* Let's get dangerous */
|
||||
memmove(¤t->data[current_x], ¤t->data[current_x + 1],
|
||||
@ -1366,9 +1392,11 @@ int do_delete(void)
|
||||
|
||||
align(¤t->data);
|
||||
|
||||
/* Now that we have a magic lnie again, we can check for both being
|
||||
on the line before filebot as well as at filebot */
|
||||
} else if (current->next != NULL && current->next != filebot) {
|
||||
/* Now that we have a magic line again, we can check for both being
|
||||
on the line before filebot as well as at filebot; it's a special
|
||||
case if we're on the line before filebot and it's blank, since we
|
||||
should be able to delete it */
|
||||
} else if (current->next != NULL && (current->next != filebot || blbf)) {
|
||||
current->data = nrealloc(current->data,
|
||||
strlen(current->data) +
|
||||
strlen(current->next->data) + 1);
|
||||
@ -2611,7 +2639,6 @@ int main(int argc, char *argv[])
|
||||
int keyhandled; /* Have we handled the keystroke yet? */
|
||||
int i, modify_control_seq;
|
||||
char *argv0;
|
||||
long constcheck; /* Check to constantly update */
|
||||
|
||||
#ifdef _POSIX_VDISABLE
|
||||
struct termios term;
|
||||
@ -2916,7 +2943,6 @@ int main(int argc, char *argv[])
|
||||
reset_cursor();
|
||||
|
||||
while (1) {
|
||||
constcheck = current->lineno + current_x + current_y + totsize;
|
||||
|
||||
#ifndef DISABLE_MOUSE
|
||||
currshortcut = main_list;
|
||||
@ -3227,8 +3253,7 @@ int main(int argc, char *argv[])
|
||||
if (ISSET(DISABLE_CURPOS))
|
||||
UNSET(DISABLE_CURPOS);
|
||||
else if (ISSET(CONSTUPDATE))
|
||||
if (constcheck != current->lineno + current_x + current_y + totsize)
|
||||
do_cursorpos();
|
||||
do_cursorpos(1);
|
||||
|
||||
reset_cursor();
|
||||
wrefresh(edit);
|
||||
|
8
proto.h
8
proto.h
@ -113,13 +113,13 @@ int check_operating_dir(char *currpath, int allow_tabcomp);
|
||||
#endif
|
||||
|
||||
int do_writeout(char *path, int exiting, int append);
|
||||
int do_gotoline(long line, int save_pos);
|
||||
int do_gotoline(int line, int save_pos);
|
||||
int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
|
||||
int wholewords, int *i);
|
||||
int do_find_bracket(void);
|
||||
|
||||
#if defined (ENABLE_MULTIBUFFER) || !defined (DISABLE_SPELLER)
|
||||
void do_gotopos(long line, int pos_x, int pos_y, int pos_placewewant);
|
||||
void do_gotopos(int line, int pos_x, int pos_y, int pos_placewewant);
|
||||
#endif
|
||||
|
||||
/* Now in move.c */
|
||||
@ -129,7 +129,7 @@ int do_left(void);
|
||||
int do_right(void);
|
||||
int check_wildcard_match(const char *text, const char *pattern);
|
||||
|
||||
char *input_tab(char *buf, int place, int *lastWasTab, int *newplace);
|
||||
char *input_tab(char *buf, int place, int *lastWasTab, int *newplace, int *list);
|
||||
char *real_dir_from_tilde(char *buf);
|
||||
|
||||
void shortcut_init(int unjustify);
|
||||
@ -201,7 +201,7 @@ int load_open_file(void), close_open_file(void);
|
||||
#endif
|
||||
|
||||
int do_page_up(void), do_page_down(void);
|
||||
int do_cursorpos(void), do_spell(void);
|
||||
int do_cursorpos(int constant), do_cursorpos_void(void), do_spell(void);
|
||||
int do_up(void), do_down (void), do_right(void), do_left (void);
|
||||
int do_home(void), do_end(void), total_refresh(void), do_mark(void);
|
||||
int do_delete(void), do_backspace(void), do_tab(void), do_justify(void);
|
||||
|
24
search.c
24
search.c
@ -289,7 +289,7 @@ filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beg
|
||||
|
||||
/* We found an instance */
|
||||
current_x_find = found - fileptr->data;
|
||||
#if 0
|
||||
#if 1
|
||||
/* Ensure we haven't wrapped around again! */
|
||||
if ((search_last_line) && (current_x_find >= beginx)) {
|
||||
if (!quiet)
|
||||
@ -308,7 +308,7 @@ filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beg
|
||||
search_last_line = 1;
|
||||
|
||||
/* Make sure we haven't passed the begining of the string */
|
||||
#if 0 /* Is this required here ? */
|
||||
#if 1 /* Is this required here ? */
|
||||
if (!(&fileptr->data[current_x_find] - fileptr->data))
|
||||
current_x_find++;
|
||||
#endif
|
||||
@ -352,7 +352,7 @@ filestruct *findnextstr(int quiet, int bracket_mode, filestruct * begin, int beg
|
||||
|
||||
/* We found an instance */
|
||||
current_x_find = found - fileptr->data;
|
||||
#if 0
|
||||
#if 1
|
||||
/* Ensure we haven't wrapped around again! */
|
||||
if ((search_last_line) && (current_x_find < beginx)) {
|
||||
if (!quiet)
|
||||
@ -651,8 +651,10 @@ int do_replace_loop(char *prevanswer, filestruct *begin, int *beginx,
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
totsize -= strlen(current->data);
|
||||
free(current->data);
|
||||
current->data = copy;
|
||||
totsize += strlen(current->data);
|
||||
|
||||
/* Stop bug where we replace a substring of the replacement text */
|
||||
current_x += strlen(last_replace) - 1;
|
||||
@ -768,13 +770,13 @@ void goto_abort(void)
|
||||
display_main_list();
|
||||
}
|
||||
|
||||
int do_gotoline(long line, int save_pos)
|
||||
int do_gotoline(int line, int save_pos)
|
||||
{
|
||||
long i = 1;
|
||||
int i = 1;
|
||||
|
||||
if (line <= 0) { /* Ask for it */
|
||||
|
||||
long j = 0;
|
||||
int j = 0;
|
||||
|
||||
j = statusq(0, goto_list, GOTO_LIST_LEN, "", _("Enter line number"));
|
||||
if (j != 0) {
|
||||
@ -815,13 +817,21 @@ int do_gotoline_void(void)
|
||||
}
|
||||
|
||||
#if (defined ENABLE_MULTIBUFFER || !defined DISABLE_SPELLER)
|
||||
void do_gotopos(long line, int pos_x, int pos_y, int pos_placewewant)
|
||||
void do_gotopos(int line, int pos_x, int pos_y, int pos_placewewant)
|
||||
{
|
||||
|
||||
/* since do_gotoline() resets the x-coordinate but not the
|
||||
y-coordinate, set the coordinates up this way */
|
||||
current_y = pos_y;
|
||||
do_gotoline(line, 1);
|
||||
|
||||
/* recalculate the x-coordinate and place we want, just in case their
|
||||
values are insane; if they aren't, they won't be changed by this */
|
||||
current_x = pos_x;
|
||||
pos_placewewant = xplustabs();
|
||||
pos_x = actual_x(current, pos_placewewant);
|
||||
|
||||
/* set the rest of the coordinates up */
|
||||
current_x = pos_x;
|
||||
placewewant = pos_placewewant;
|
||||
update_line(current, pos_x);
|
||||
|
52
winio.c
52
winio.c
@ -260,7 +260,7 @@ void nanoget_repaint(char *buf, char *inputbuf, int x)
|
||||
|
||||
/* Get the input from the kb; this should only be called from statusq */
|
||||
int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
|
||||
int start_x)
|
||||
int start_x, int list)
|
||||
{
|
||||
int kbinput = 0, j = 0, x = 0, xend;
|
||||
int x_left = 0, inputlen, tabbed = 0;
|
||||
@ -389,7 +389,7 @@ int nanogetstr(int allowtabs, char *buf, char *def, shortcut s[], int slen,
|
||||
if (allowtabs) {
|
||||
shift = 0;
|
||||
inputbuf = input_tab(inputbuf, (x - x_left),
|
||||
&tabbed, &shift);
|
||||
&tabbed, &shift, &list);
|
||||
x += shift;
|
||||
if (x - x_left > strlen(inputbuf))
|
||||
x = strlen(inputbuf) + x_left;
|
||||
@ -1048,7 +1048,7 @@ void update_line(filestruct * fileptr, int index)
|
||||
virt_cur_x--;
|
||||
if (i < mark_beginx)
|
||||
virt_mark_beginx--;
|
||||
} else if (realdata[i] >= 1 && realdata[i] <= 26) {
|
||||
} else if (realdata[i] < 32) {
|
||||
/* Treat control characters as ^letter */
|
||||
fileptr->data[pos++] = '^';
|
||||
fileptr->data[pos++] = realdata[i] + 64;
|
||||
@ -1213,6 +1213,10 @@ int statusq(int tabs, shortcut s[], int slen, char *def, char *msg, ...)
|
||||
char foo[133];
|
||||
int ret;
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
int list;
|
||||
#endif
|
||||
|
||||
bottombars(s, slen);
|
||||
|
||||
va_start(ap, msg);
|
||||
@ -1227,7 +1231,13 @@ int statusq(int tabs, shortcut s[], int slen, char *def, char *msg, ...)
|
||||
#endif
|
||||
|
||||
|
||||
ret = nanogetstr(tabs, foo, def, s, slen, (strlen(foo) + 3));
|
||||
#ifndef DISABLE_TABCOMP
|
||||
ret = nanogetstr(tabs, foo, def, s, slen, (strlen(foo) + 3), list);
|
||||
#else
|
||||
/* if we've disabled tab completion, the value of list won't be
|
||||
used at all, so it's safe to use 0 (NULL) as a placeholder */
|
||||
ret = nanogetstr(tabs, foo, def, s, slen, (strlen(foo) + 3), 0);
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
color_off(bottomwin, COLOR_STATUSBAR);
|
||||
@ -1245,6 +1255,13 @@ int statusq(int tabs, shortcut s[], int slen, char *def, char *msg, ...)
|
||||
do_last_line();
|
||||
break;
|
||||
case NANO_CANCEL_KEY:
|
||||
#ifndef DISABLE_TABCOMP
|
||||
/* if we've done tab completion, there might be a list of
|
||||
filename matches on the edit window at this point; make sure
|
||||
they're cleared off */
|
||||
if (list)
|
||||
edit_refresh();
|
||||
#endif
|
||||
return -1;
|
||||
default:
|
||||
blank_statusbar();
|
||||
@ -1480,11 +1497,12 @@ void previous_line(void)
|
||||
current_y--;
|
||||
}
|
||||
|
||||
int do_cursorpos(void)
|
||||
int do_cursorpos(int constant)
|
||||
{
|
||||
filestruct *fileptr;
|
||||
float linepct = 0.0, bytepct = 0.0;
|
||||
long i = 0;
|
||||
static long old_i = -1, old_totsize = -1;
|
||||
|
||||
if (current == NULL || fileage == NULL)
|
||||
return 0;
|
||||
@ -1498,6 +1516,12 @@ int do_cursorpos(void)
|
||||
|
||||
i += current_x;
|
||||
|
||||
if (old_i == -1)
|
||||
old_i = i;
|
||||
|
||||
if (old_totsize == -1)
|
||||
old_totsize = totsize;
|
||||
|
||||
if (totlines > 0)
|
||||
linepct = 100 * current->lineno / totlines;
|
||||
|
||||
@ -1509,12 +1533,26 @@ int do_cursorpos(void)
|
||||
linepct, bytepct);
|
||||
#endif
|
||||
|
||||
statusbar(_("line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"),
|
||||
current->lineno, totlines, linepct, i, totsize, bytepct);
|
||||
/* if constant is zero, display the position on the statusbar
|
||||
unconditionally; otherwise, only display the position when the
|
||||
character values have changed */
|
||||
if (!constant || (old_i != i || old_totsize != totsize)) {
|
||||
statusbar(_("line %d of %d (%.0f%%), character %ld of %ld (%.0f%%)"),
|
||||
current->lineno, totlines, linepct, i, totsize, bytepct);
|
||||
}
|
||||
|
||||
old_i = i;
|
||||
old_totsize = totsize;
|
||||
|
||||
reset_cursor();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int do_cursorpos_void(void)
|
||||
{
|
||||
return do_cursorpos(0);
|
||||
}
|
||||
|
||||
/* Our broken, non-shortcut list compliant help function.
|
||||
But, hey, it's better than nothing, and it's dynamic! */
|
||||
int do_help(void)
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user