From: Chris Allegretta Date: Sun, 14 Oct 2001 19:05:10 +0000 (+0000) Subject: Added conversion messages for DOS and Mac files, and Alt-space as do-previous-word X-Git-Tag: v1.1.3~18 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=76e291beee70c81a484c1570e73d88accd7b7c41;p=nano.git Added conversion messages for DOS and Mac files, and Alt-space as do-previous-word git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@858 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index 726ed5f2..587fd1b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ CVS code - +- files.c: + - Added status messages for converted DOS and Mac files. + People should know that their file wasnt normally formatted. +- nano.c: + - New function do_prev_word, similar to do_next_word. Hard coded as + Alt-space, as next word is hard coded as control-space. - po/sv.po: - Updated Swedish translation (Christian Rose). - po/sv.po: diff --git a/aclocal.m4 b/aclocal.m4 index dadaa331..a9a9d423 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,4 +1,4 @@ -dnl aclocal.m4 generated automatically by aclocal 1.4 +dnl aclocal.m4 generated automatically by aclocal 1.4-p4 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation @@ -125,6 +125,24 @@ for am_file in <<$1>>; do done<<>>dnl>>) changequote([,]))]) +#serial 1 +# This test replaces the one in autoconf. +# Currently this macro should have the same name as the autoconf macro +# because gettext's gettext.m4 (distributed in the automake package) +# still uses it. Otherwise, the use in gettext.m4 makes autoheader +# give these diagnostics: +# configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX +# configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX + +undefine([AC_ISC_POSIX]) + +AC_DEFUN([AC_ISC_POSIX], + [ + dnl This test replaces the obsolescent AC_ISC_POSIX kludge. + AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"]) + ] +) + #serial 19 dnl By default, many hosts won't let programs access large files; @@ -797,15 +815,17 @@ AC_SUBST($1)dnl # Ulrich Drepper , 1996. # # This file can be copied and used freely without restrictions. It can -# be used in projects which are not available under the GNU Public License -# but which still want to provide support for the GNU gettext functionality. -# Please note that the actual code is *not* freely available. +# be used in projects which are not available under the GNU General Public +# License but which still want to provide support for the GNU gettext +# functionality. +# Please note that the actual code of GNU gettext is covered by the GNU +# General Public License and is *not* in the public domain. -# serial 1 +# serial 2 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) -AC_DEFUN(AM_PATH_PROG_WITH_TEST, +AC_DEFUN([AM_PATH_PROG_WITH_TEST], [# Extract the first word of "$2", so it can be a program name with args. set dummy $2; ac_word=[$]2 AC_MSG_CHECKING([for $ac_word]) @@ -833,7 +853,7 @@ ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" ;; esac])dnl $1="$ac_cv_path_$1" -if test -n "[$]$1"; then +if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then AC_MSG_RESULT([$]$1) else AC_MSG_RESULT(no) diff --git a/config.h.in b/config.h.in index 2fce781a..7fcb8da2 100644 --- a/config.h.in +++ b/config.h.in @@ -31,9 +31,6 @@ /* Define to `long' if doesn't define. */ #undef off_t -/* Define if you need to in order for stat and other things to work. */ -#undef _POSIX_SOURCE - /* Define as the return type of signal handlers (int or void). */ #undef RETSIGTYPE diff --git a/files.c b/files.c index fdc752be..51536cd1 100644 --- a/files.c +++ b/files.c @@ -43,6 +43,11 @@ #define _(string) (string) #endif +/* statics for here */ +#ifndef NANO_SMALL +static int fileformat = 0; /* 0 = *nix, 1 = DOS, 2 = Mac */ +#endif + /* Load file into edit buffer - takes data from file struct */ void load_file(int quiet) { @@ -130,6 +135,9 @@ filestruct *read_line(char *buf, filestruct * prev, int *line1ins) if (buf[strlen(buf) - 1] == '\r') { fileptr->data[strlen(buf) - 1] = 0; totsize--; + + if (!fileformat) + fileformat = 1; } #endif @@ -195,6 +203,7 @@ int read_file(int fd, char *filename, int quiet) #ifndef NANO_SMALL /* If it's a Mac file (no LF just a CR), handle it! */ } else if (i > 0 && buf[i-1] == '\r') { + fileformat = 2; fileptr = read_line(buf, fileptr, &line1ins); num_lines++; buf[0] = input[0]; @@ -245,7 +254,16 @@ int read_file(int fd, char *filename, int quiet) /* Update the edit buffer */ load_file(quiet); } - statusbar(_("Read %d lines"), num_lines); + +#ifndef NANO_SMALL + if (fileformat == 2) + statusbar(_("Read %d lines (Converted Mac format)"), num_lines); + else if (fileformat == 1) + statusbar(_("Read %d lines (Converted DOS format)"), num_lines); + else +#endif + statusbar(_("Read %d lines"), num_lines); + totlines += num_lines; free(buf); diff --git a/nano.c b/nano.c index d91ff69b..922eae54 100644 --- a/nano.c +++ b/nano.c @@ -235,6 +235,7 @@ void global_init(int save_cutbuffer) hblank = charalloc(COLS + 1); memset(hblank, ' ', COLS); hblank[COLS] = 0; + } #ifndef DISABLE_HELP @@ -817,6 +818,74 @@ void do_next_word(void) update_line(current, current_x); } +} + +/* the same thing for backwards */ +void do_prev_word(void) +{ + filestruct *fileptr, *old; + int i; + + if (current == NULL) + return; + + old = current; + i = current_x; + for (fileptr = current; fileptr != NULL; fileptr = fileptr->prev) { + if (fileptr == current) { + while (isalnum((int) fileptr->data[i]) + && i != 0) + i--; + + if (i == 0) { + if (fileptr->prev != NULL) + i = strlen(fileptr->prev->data) - 1; + else if (fileptr == fileage && filebot != NULL) + i = strlen(filebot->data) - 1; + + continue; + } + } + + while (!isalnum((int) fileptr->data[i]) && i != 0) + i--; + + if (i > 0) { + i--; + + while (isalnum((int) fileptr->data[i]) && i != 0) + i--; + + i++; + if (i != 0) + break; + + } + if (fileptr->prev != NULL) + i = strlen(fileptr->prev->data) - 1; + else if (fileptr == fileage && filebot != NULL) + i = strlen(filebot->data) - 1; + } + if (fileptr == NULL) + current = fileage; + else + current = fileptr; + + current_x = i; + placewewant = xplustabs(); + + if (current->lineno <= edittop->lineno) + edit_update(current, CENTER); + else { + /* If we've jumped lines, refresh the old line. We can't just use + * current->prev here, because we may have skipped over some blank + * lines, in which case the previous line is the wrong one. + */ + if (current != old) + update_line(old, 0); + + update_line(current, current_x); + } } #endif /* NANO_SMALL */ @@ -2794,6 +2863,11 @@ int main(int argc, char *argv[]) modify_control_seq = 1; keyhandled = 1; break; + case ' ': + /* If control-space is next word, Alt-space should be previous word */ + do_prev_word(); + keyhandled = 1; + break; case '[': switch (kbinput = wgetch(edit)) { case '1': /* Alt-[-1-[0-5,7-9] = F1-F8 in X at least */