- winio.c:do_cursorpos() - Rewritten to show col place as well as charcter place, without needing an entirely separate flag
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1067 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
7eccc7991c
commit
f27c69703d
10
ChangeLog
10
ChangeLog
|
@ -1,15 +1,15 @@
|
|||
CVS code -
|
||||
- General
|
||||
- New flag RELATIVECHARS to show column positino relative to
|
||||
the current line instead of the current file. New flag
|
||||
-C, --relative, changes to do_cursorpos().
|
||||
- Makefile.am:
|
||||
- Add SYSCONFDIR to DEFS, so we can have an /etc/nanorc.
|
||||
- Change localedir line to 1.0's version.
|
||||
- rcfile.c
|
||||
- rcfile.c:
|
||||
parse_next_rege()
|
||||
- Allow " symbol to be in regex without leading \ by checking
|
||||
for *ptr+1 is not the end of the regex.
|
||||
- winio.c:
|
||||
do_cursorpos()
|
||||
- Rewritten to show col place as well as charcter place, without
|
||||
needing an entirely separate flag.
|
||||
- utils.c:
|
||||
strstrwrapper()
|
||||
- NANO_SMALL test was backwards (Ken Tyler).
|
||||
|
|
12
nano.c
12
nano.c
|
@ -409,9 +409,6 @@ void usage(void)
|
|||
printf(_("Usage: nano [GNU long option] [option] +LINE <file>\n\n"));
|
||||
printf(_("Option Long option Meaning\n"));
|
||||
|
||||
printf
|
||||
(_
|
||||
(" -C --relative Show relative col position with ^C\n"));
|
||||
#ifndef NANO_SMALL
|
||||
printf
|
||||
(_
|
||||
|
@ -492,7 +489,6 @@ void usage(void)
|
|||
#else
|
||||
printf(_("Usage: nano [option] +LINE <file>\n\n"));
|
||||
printf(_("Option Meaning\n"));
|
||||
printf(_(" -C Show relative col position with ^C\n"));
|
||||
#ifndef NANO_SMALL
|
||||
printf(_(" -D Write file in DOS format\n"));
|
||||
#endif
|
||||
|
@ -2740,7 +2736,6 @@ int main(int argc, char *argv[])
|
|||
{"smooth", 0, 0, 'S'},
|
||||
#endif
|
||||
{"keypad", 0, 0, 'K'},
|
||||
{"relative", 0, 0, 'C'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
#endif
|
||||
|
@ -2761,18 +2756,15 @@ int main(int argc, char *argv[])
|
|||
#endif /* ENABLE_NANORC */
|
||||
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
while ((optchr = getopt_long(argc, argv, "h?CDFKMRST:Vabcefgijklmo:pr:s:tvwxz",
|
||||
while ((optchr = getopt_long(argc, argv, "h?DFKMRST:Vabcefgijklmo:pr:s:tvwxz",
|
||||
long_options, &option_index)) != EOF) {
|
||||
#else
|
||||
while ((optchr =
|
||||
getopt(argc, argv, "h?CDFKMRST:Vabcefgijklmo:pr:s:tvwxz")) != EOF) {
|
||||
getopt(argc, argv, "h?DFKMRST:Vabcefgijklmo:pr:s:tvwxz")) != EOF) {
|
||||
#endif
|
||||
|
||||
switch (optchr) {
|
||||
|
||||
case 'C':
|
||||
SET(RELATIVECHARS);
|
||||
break;
|
||||
#ifndef NANO_SMALL
|
||||
case 'D':
|
||||
SET(DOS_FILE);
|
||||
|
|
41
winio.c
41
winio.c
|
@ -1585,7 +1585,7 @@ void previous_line(void)
|
|||
int do_cursorpos(int constant)
|
||||
{
|
||||
filestruct *fileptr;
|
||||
float linepct = 0.0, bytepct = 0.0;
|
||||
float linepct = 0.0, bytepct = 0.0, colpct = 0.0;
|
||||
long i = 0, j = 0;
|
||||
static long old_i = -1, old_totsize = -1;
|
||||
|
||||
|
@ -1598,32 +1598,24 @@ int do_cursorpos(int constant)
|
|||
if (old_totsize == -1)
|
||||
old_totsize = totsize;
|
||||
|
||||
if (ISSET(RELATIVECHARS)) {
|
||||
if (strlen(current->data) == 0)
|
||||
colpct = 0;
|
||||
else
|
||||
colpct = 100 * current_x / strlen(current->data);
|
||||
|
||||
if (strlen(current->data) == 0)
|
||||
bytepct = 0;
|
||||
else
|
||||
bytepct = 100 * current_x / strlen(current->data);
|
||||
for (fileptr = fileage; fileptr != current && fileptr != NULL;
|
||||
fileptr = fileptr->next)
|
||||
i += strlen(fileptr->data) + 1;
|
||||
|
||||
old_i = -1;
|
||||
i = current_x;
|
||||
j = strlen(current->data);
|
||||
if (fileptr == NULL)
|
||||
return -1;
|
||||
|
||||
} else {
|
||||
for (fileptr = fileage; fileptr != current && fileptr != NULL;
|
||||
fileptr = fileptr->next)
|
||||
i += strlen(fileptr->data) + 1;
|
||||
i += current_x;
|
||||
|
||||
if (fileptr == NULL)
|
||||
return -1;
|
||||
j = totsize;
|
||||
|
||||
i += current_x;
|
||||
|
||||
j = totsize;
|
||||
|
||||
if (totsize > 0)
|
||||
bytepct = 100 * i / totsize;
|
||||
}
|
||||
if (totsize > 0)
|
||||
bytepct = 100 * i / totsize;
|
||||
|
||||
if (totlines > 0)
|
||||
linepct = 100 * current->lineno / totlines;
|
||||
|
@ -1638,8 +1630,9 @@ int do_cursorpos(int constant)
|
|||
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, j, bytepct);
|
||||
("line %d/%d (%.0f%%), col %ld/%ld (%.0f%%), char %ld/%ld (%.0f%%)"),
|
||||
current->lineno, totlines, linepct, current_x,
|
||||
strlen(current->data), colpct, i, j, bytepct);
|
||||
}
|
||||
|
||||
old_i = i;
|
||||
|
|
Loading…
Reference in New Issue