nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit ccd1b7b50a6a7286c32622296485e173595b4cd5
parent d15c92d41ad4db8d03eb7b15cbe8ca9a4bd142ea
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Fri, 18 Nov 2005 20:21:48 +0000

miscellaneous minor fixes


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3201 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

Diffstat:
MChangeLog | 7+++++++
Msrc/browser.c | 11++++++-----
Msrc/files.c | 12++++++++++--
Msrc/text.c | 4++--
4 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -113,6 +113,13 @@ CVS code - prompt. New functions find_statusbar_bracket_match() and do_statusbar_find_bracket(); changes to do_statusbar_input(). (DLR) + - Beep whenever we can't read a file or directory and have to + indicate it on the statusbar, as Pico does. Changes to + do_browser(), open_file(), and write_file(). (DLR) +- browser.c: + do_browser() + - When setting the width of each file, use the "?" operator + instead of an if/else clause. (DLR) - chars.c: mbwidth() - If wcwidth() returns -1 for the character passed in, treat the diff --git a/src/browser.c b/src/browser.c @@ -207,6 +207,8 @@ char *do_browser(char *path, DIR *dir) #endif if (stat(filelist[selected], &st) == -1) { + /* We can't open this file for some reason. + * Complain. */ statusbar(_("Error reading %s: %s"), filelist[selected], strerror(errno)); beep(); @@ -225,6 +227,7 @@ char *do_browser(char *path, DIR *dir) * Complain. */ statusbar(_("Error reading %s: %s"), filelist[selected], strerror(errno)); + beep(); break; } @@ -284,6 +287,7 @@ char *do_browser(char *path, DIR *dir) * Complain. */ statusbar(_("Error reading %s: %s"), answer, strerror(errno)); + beep(); free(new_path); break; } @@ -308,11 +312,8 @@ char *do_browser(char *path, DIR *dir) blank_edit(); - if (width != 0) - j = width * editwinrows * - ((selected / width) / editwinrows); - else - j = 0; + j = (width != 0) ? width * editwinrows * ((selected / width) / + editwinrows) : 0; wmove(edit, 0, 0); diff --git a/src/files.c b/src/files.c @@ -595,6 +595,7 @@ int open_file(const char *filename, bool newfie, FILE **f) return -2; } statusbar(_("\"%s\" not found"), filename); + beep(); return -1; } else if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) || S_ISBLK(fileinfo.st_mode)) { @@ -602,9 +603,11 @@ int open_file(const char *filename, bool newfie, FILE **f) statusbar(S_ISDIR(fileinfo.st_mode) ? _("\"%s\" is a directory") : _("File \"%s\" is a device file"), filename); + beep(); return -1; } else if ((fd = open(filename, O_RDONLY)) == -1) { statusbar(_("Error reading %s: %s"), filename, strerror(errno)); + beep(); return -1; } else { /* File is A-OK. Open it in binary mode for our own end-of-line @@ -614,6 +617,7 @@ int open_file(const char *filename, bool newfie, FILE **f) if (*f == NULL) { statusbar(_("Error reading %s: %s"), filename, strerror(errno)); + beep(); close(fd); } else statusbar(_("Reading File")); @@ -1322,6 +1326,7 @@ int write_file(const char *name, FILE *f_open, bool tmp, append_type if (f == NULL) { statusbar(_("Error reading %s: %s"), realname, strerror(errno)); + beep(); goto cleanup_and_exit; } } @@ -1401,10 +1406,11 @@ int write_file(const char *name, FILE *f_open, bool tmp, append_type openfile->current_stat->st_gid) == -1 || utime(backupname, &filetime) == -1) { free(backupname); - if (copy_status == -1) + if (copy_status == -1) { statusbar(_("Error reading %s: %s"), realname, strerror(errno)); - else + beep(); + } else statusbar(_("Error writing %s: %s"), backupname, strerror(errno)); goto cleanup_and_exit; @@ -1455,6 +1461,7 @@ int write_file(const char *name, FILE *f_open, bool tmp, append_type if (f_source == NULL) { statusbar(_("Error reading %s: %s"), realname, strerror(errno)); + beep(); close(fd_source); fclose(f); unlink(tempname); @@ -1576,6 +1583,7 @@ int write_file(const char *name, FILE *f_open, bool tmp, append_type if (f_source == NULL) { statusbar(_("Error reading %s: %s"), tempname, strerror(errno)); + beep(); fclose(f); goto cleanup_and_exit; } diff --git a/src/text.c b/src/text.c @@ -1446,8 +1446,8 @@ void do_justify(bool full_justify) /* Partition the filestruct so that it contains only the * text of the justified paragraph. */ filepart = partition_filestruct(first_par_line, 0, - last_par_line, (filebot_inpar && last_par_line == - openfile->filebot) ? strlen(last_par_line->data) : 0); + last_par_line, filebot_inpar ? + strlen(last_par_line->data) : 0); /* Remove the text of the justified paragraph, and * replace it with the text in the justify buffer. */