Index: src/nano.h =================================================================== --- src/nano.h (revision 5749) +++ src/nano.h (working copy) @@ -57,6 +57,10 @@ /* Suppress warnings for __attribute__((warn_unused_result)). */ #define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0) +/* The ways to highlight a statusbar message. */ +#define ALERT TRUE +#define INFO FALSE + /* Macros for flags, indexing each bit in a small array. */ #define FLAGS(flag) flags[((flag) / (sizeof(unsigned) * 8))] #define FLAGMASK(flag) (1 << ((flag) % (sizeof(unsigned) * 8))) @@ -470,6 +474,7 @@ { TITLE_BAR = 0, STATUS_BAR, + ATTENTION, KEY_COMBO, FUNCTION_TAG, NUMBER_OF_ELEMENTS Index: src/files.c =================================================================== --- src/files.c (revision 5749) +++ src/files.c (working copy) @@ -47,14 +47,14 @@ if (stat(parentdir, &parentinfo) == -1) { if (errno == ENOENT) - statusbar(_("Directory '%s' does not exist"), parentdir); + statusline(ALERT, _("Directory '%s' does not exist"), parentdir); else - statusbar(_("Path '%s': %s"), parentdir, strerror(errno)); + statusline(ALERT, _("Path '%s': %s"), parentdir, strerror(errno)); } else if (!S_ISDIR(parentinfo.st_mode)) { - statusbar(_("Path '%s' is not a directory"), parentdir); + statusline(ALERT, _("Path '%s' is not a directory"), parentdir); } else { if (access(parentdir, X_OK) == -1) - statusbar(_("Path '%s' is not accessible"), parentdir); + statusline(ALERT, _("Path '%s' is not accessible"), parentdir); else validity = TRUE; } @@ -203,7 +203,8 @@ if (errno == ENAMETOOLONG) myhostname[31] = '\0'; else { - statusbar(_("Couldn't determine hostname for lock file: %s"), strerror(errno)); + statusline(INFO, _("Couldn't determine hostname for lock file: %s"), + strerror(errno)); goto free_and_fail; } } @@ -224,8 +225,8 @@ /* Maybe we just don't have write access. Print an error message * and continue. */ if (fd < 0) { - statusbar(_("Error writing lock file %s: %s"), lockfilename, - strerror(errno)); + statusline(INFO, _("Error writing lock file %s: %s"), + lockfilename, strerror(errno)); free(lockdata); return 0; } @@ -235,7 +236,7 @@ filestream = fdopen(fd, "wb"); if (fd < 0 || filestream == NULL) { - statusbar(_("Error writing lock file %s: %s"), lockfilename, + statusline(INFO, _("Error writing lock file %s: %s"), lockfilename, strerror(errno)); goto free_and_fail; } @@ -272,7 +273,7 @@ wroteamt = fwrite(lockdata, sizeof(char), lockdatalen, filestream); if (wroteamt < lockdatalen) { - statusbar(_("Error writing lock file %s: %s"), + statusline(INFO, _("Error writing lock file %s: %s"), lockfilename, ferror(filestream)); goto free_and_fail; } @@ -282,7 +283,7 @@ #endif if (fclose(filestream) == EOF) { - statusbar(_("Error writing lock file %s: %s"), + statusline(INFO, _("Error writing lock file %s: %s"), lockfilename, strerror(errno)); goto free_and_fail; } @@ -302,7 +303,7 @@ int delete_lockfile(const char *lockfilename) { if (unlink(lockfilename) < 0 && errno != ENOENT) { - statusbar(_("Error deleting lock file %s: %s"), lockfilename, + statusline(INFO, _("Error deleting lock file %s: %s"), lockfilename, strerror(errno)); return -1; } @@ -338,7 +339,7 @@ int ans; if ((lockfd = open(lockfilename, O_RDONLY)) < 0) { - statusbar(_("Error opening lock file %s: %s"), + statusline(INFO, _("Error opening lock file %s: %s"), lockfilename, strerror(errno)); goto free_the_name; } @@ -350,8 +351,8 @@ } while (readtot < 8192 && readamt > 0); if (readtot < 48) { - statusbar(_("Error reading lock file %s: Not enough data read"), - lockfilename); + statusline(INFO, _("Error reading lock file %s: " + "Not enough data read"), lockfilename); free(lockbuf); goto free_the_name; } @@ -423,7 +424,7 @@ #ifndef DISABLE_OPERATINGDIR if (check_operating_dir(filename, FALSE)) { - statusbar(_("Can't insert file from outside of %s"), + statusline(INFO, _("Can't insert file from outside of %s"), operating_dir); return FALSE; } @@ -436,9 +437,9 @@ if (stat(filename, &fileinfo) == 0 && !S_ISREG(fileinfo.st_mode)) { if (S_ISDIR(fileinfo.st_mode)) - statusbar(_("\"%s\" is a directory"), filename); + statusline(ALERT, _("\"%s\" is a directory"), filename); else - statusbar(_("\"%s\" is not a normal file"), filename); + statusline(ALERT, _("\"%s\" is not a normal file"), filename); beep(); return FALSE; } @@ -579,7 +580,7 @@ /* Indicate the switch on the statusbar. */ if (!quiet) - statusbar(_("Switched to %s"), + statusline(INFO, _("Switched to %s"), ((openfile->filename[0] == '\0') ? _("New Buffer") : openfile->filename)); @@ -939,44 +940,50 @@ if (format == 3) { if (writable) - statusbar( + statusline(INFO, P_("Read %lu line (Converted from DOS and Mac format)", "Read %lu lines (Converted from DOS and Mac format)", (unsigned long)num_lines), (unsigned long)num_lines); else - statusbar( + statusline(ALERT, P_("Read %lu line (Converted from DOS and Mac format - Warning: No write permission)", "Read %lu lines (Converted from DOS and Mac format - Warning: No write permission)", (unsigned long)num_lines), (unsigned long)num_lines); } else if (format == 2) { openfile->fmt = MAC_FILE; if (writable) - statusbar(P_("Read %lu line (Converted from Mac format)", + statusline(INFO, + P_("Read %lu line (Converted from Mac format)", "Read %lu lines (Converted from Mac format)", (unsigned long)num_lines), (unsigned long)num_lines); else - statusbar(P_("Read %lu line (Converted from Mac format - Warning: No write permission)", + statusline(ALERT, + P_("Read %lu line (Converted from Mac format - Warning: No write permission)", "Read %lu lines (Converted from Mac format - Warning: No write permission)", (unsigned long)num_lines), (unsigned long)num_lines); } else if (format == 1) { openfile->fmt = DOS_FILE; if (writable) - statusbar(P_("Read %lu line (Converted from DOS format)", + statusline(INFO, + P_("Read %lu line (Converted from DOS format)", "Read %lu lines (Converted from DOS format)", (unsigned long)num_lines), (unsigned long)num_lines); else - statusbar(P_("Read %lu line (Converted from DOS format - Warning: No write permission)", + statusline(ALERT, + P_("Read %lu line (Converted from DOS format - Warning: No write permission)", "Read %lu lines (Converted from DOS format - Warning: No write permission)", (unsigned long)num_lines), (unsigned long)num_lines); } else #endif if (writable) - statusbar(P_("Read %lu line", "Read %lu lines", + statusline(INFO, P_("Read %lu line", "Read %lu lines", (unsigned long)num_lines), (unsigned long)num_lines); - else - statusbar(P_("Read %lu line (Warning: No write permission)", + else { + statusline(ALERT, + P_("Read %lu line (Warning: No write permission)", "Read %lu lines (Warning: No write permission)", (unsigned long)num_lines), (unsigned long)num_lines); +} #ifndef NANO_TINY if (ISSET(MAKE_IT_UNIX)) @@ -1025,7 +1032,7 @@ statusbar(_("New File")); return -2; } - statusbar(_("\"%s\" not found"), filename); + statusline(INFO, _("\"%s\" not found"), filename); beep(); return -1; } else if (S_ISDIR(fileinfo.st_mode) || S_ISCHR(fileinfo.st_mode) || @@ -1034,14 +1041,14 @@ /* Don't open directories, character files, or block files. * Sorry, /dev/sndstat! */ - statusbar(S_ISDIR(fileinfo.st_mode) ? + statusline(ALERT, S_ISDIR(fileinfo.st_mode) ? _("\"%s\" is a directory") : _("\"%s\" is a device file"), filename); beep(); return -1; } else if ((fd = open(full_filename, O_RDONLY)) == -1) { free(full_filename); - statusbar(_("Error reading %s: %s"), filename, strerror(errno)); + statusline(ALERT, _("Error reading %s: %s"), filename, strerror(errno)); beep(); return -1; } else { @@ -1049,7 +1056,7 @@ *f = fdopen(fd, "rb"); if (*f == NULL) { - statusbar(_("Error reading %s: %s"), filename, strerror(errno)); + statusline(ALERT, _("Error reading %s: %s"), filename, strerror(errno)); beep(); close(fd); } else @@ -1797,7 +1804,7 @@ /* If we're writing a temporary file, we're probably going outside * the operating directory, so skip the operating directory test. */ if (!tmp && check_operating_dir(realname, FALSE)) { - statusbar(_("Can't write outside of %s"), operating_dir); + statusline(ALERT, _("Can't write outside of %s"), operating_dir); goto cleanup_and_exit; } #endif @@ -1841,7 +1848,7 @@ f = fopen(realname, "rb"); if (f == NULL) { - statusbar(_("Error reading %s: %s"), realname, + statusline(ALERT, _("Error reading %s: %s"), realname, strerror(errno)); beep(); /* If we can't read from the original file, go on, since @@ -1882,8 +1889,8 @@ free(backuptemp); backuptemp = get_next_filename(backupname, "~"); if (*backuptemp == '\0') { - statusbar(_("Error writing backup file %s: %s"), backupname, - _("Too many backup files?")); + statusline(ALERT, _("Error writing backup file %s: %s"), + backupname, _("Too many backup files?")); free(backuptemp); free(backupname); /* If we can't write to the backup, DON'T go on, since @@ -1907,8 +1914,8 @@ if (unlink(backupname) < 0 && errno != ENOENT && !ISSET(INSECURE_BACKUP)) { if (prompt_failed_backupwrite(backupname)) goto skip_backup; - statusbar(_("Error writing backup file %s: %s"), backupname, - strerror(errno)); + statusline(ALERT, _("Error writing backup file %s: %s"), + backupname, strerror(errno)); free(backupname); goto cleanup_and_exit; } @@ -1925,8 +1932,8 @@ backup_file = fdopen(backup_fd, "wb"); if (backup_fd < 0 || backup_file == NULL) { - statusbar(_("Error writing backup file %s: %s"), backupname, - strerror(errno)); + statusline(ALERT, _("Error writing backup file %s: %s"), + backupname, strerror(errno)); free(backupname); goto cleanup_and_exit; } @@ -1938,8 +1945,8 @@ && !ISSET(INSECURE_BACKUP)) { if (prompt_failed_backupwrite(backupname)) goto skip_backup; - statusbar(_("Error writing backup file %s: %s"), backupname, - strerror(errno)); + statusline(ALERT, _("Error writing backup file %s: %s"), + backupname, strerror(errno)); free(backupname); fclose(backup_file); goto cleanup_and_exit; @@ -1949,8 +1956,8 @@ && !ISSET(INSECURE_BACKUP)) { if (prompt_failed_backupwrite(backupname)) goto skip_backup; - statusbar(_("Error writing backup file %s: %s"), backupname, - strerror(errno)); + statusline(ALERT, _("Error writing backup file %s: %s"), + backupname, strerror(errno)); free(backupname); fclose(backup_file); /* If we can't write to the backup, DONT go on, since @@ -1968,7 +1975,7 @@ copy_status = copy_file(f, backup_file); if (copy_status != 0) { - statusbar(_("Error reading %s: %s"), realname, + statusline(ALERT, _("Error reading %s: %s"), realname, strerror(errno)); beep(); goto cleanup_and_exit; @@ -1978,8 +1985,8 @@ if (utime(backupname, &filetime) == -1 && !ISSET(INSECURE_BACKUP)) { if (prompt_failed_backupwrite(backupname)) goto skip_backup; - statusbar(_("Error writing backup file %s: %s"), backupname, - strerror(errno)); + statusline(ALERT, _("Error writing backup file %s: %s"), + backupname, strerror(errno)); /* If we can't write to the backup, DON'T go on, since * whatever caused the backup file to fail (e.g. disk full * may well cause the real file write to fail, which means @@ -2013,7 +2020,7 @@ f = fopen(realname, "rb"); if (f == NULL) { - statusbar(_("Error reading %s: %s"), realname, + statusline(ALERT, _("Error reading %s: %s"), realname, strerror(errno)); beep(); goto cleanup_and_exit; @@ -2023,8 +2030,8 @@ tempname = safe_tempfile(&f); if (tempname == NULL) { - statusbar(_("Error writing temp file: %s"), - strerror(errno)); + statusline(ALERT, _("Error writing temp file: %s"), + strerror(errno)); goto cleanup_and_exit; } @@ -2034,8 +2041,8 @@ if (fd_source != -1) { f_source = fdopen(fd_source, "rb"); if (f_source == NULL) { - statusbar(_("Error reading %s: %s"), realname, - strerror(errno)); + statusline(ALERT, _("Error reading %s: %s"), realname, + strerror(errno)); beep(); close(fd_source); fclose(f); @@ -2046,8 +2053,8 @@ } if (f_source == NULL || copy_file(f_source, f) != 0) { - statusbar(_("Error writing %s: %s"), tempname, - strerror(errno)); + statusline(ALERT, _("Error writing %s: %s"), tempname, + strerror(errno)); unlink(tempname); goto cleanup_and_exit; } @@ -2065,8 +2072,8 @@ /* If we couldn't open the file, give up. */ if (fd == -1) { - statusbar(_("Error writing %s: %s"), realname, - strerror(errno)); + statusline(ALERT, _("Error writing %s: %s"), realname, + strerror(errno)); /* tempname has been set only if we're prepending. */ if (tempname != NULL) @@ -2077,8 +2084,8 @@ f = fdopen(fd, (append == APPEND) ? "ab" : "wb"); if (f == NULL) { - statusbar(_("Error writing %s: %s"), realname, - strerror(errno)); + statusline(ALERT, _("Error writing %s: %s"), realname, + strerror(errno)); close(fd); goto cleanup_and_exit; } @@ -2101,8 +2108,8 @@ unsunder(fileptr->data, data_len); if (size < data_len) { - statusbar(_("Error writing %s: %s"), realname, - strerror(errno)); + statusline(ALERT, _("Error writing %s: %s"), realname, + strerror(errno)); fclose(f); goto cleanup_and_exit; } @@ -2118,8 +2125,8 @@ #ifndef NANO_TINY if (openfile->fmt == DOS_FILE || openfile->fmt == MAC_FILE) { if (putc('\r', f) == EOF) { - statusbar(_("Error writing %s: %s"), realname, - strerror(errno)); + statusline(ALERT, _("Error writing %s: %s"), realname, + strerror(errno)); fclose(f); goto cleanup_and_exit; } @@ -2128,8 +2135,8 @@ if (openfile->fmt != MAC_FILE) #endif if (putc('\n', f) == EOF) { - statusbar(_("Error writing %s: %s"), realname, - strerror(errno)); + statusline(ALERT, _("Error writing %s: %s"), realname, + strerror(errno)); fclose(f); goto cleanup_and_exit; } @@ -2153,23 +2160,23 @@ } if (f_source == NULL) { - statusbar(_("Error reading %s: %s"), tempname, - strerror(errno)); + statusline(ALERT, _("Error reading %s: %s"), tempname, + strerror(errno)); beep(); fclose(f); goto cleanup_and_exit; } if (copy_file(f_source, f) == -1) { - statusbar(_("Error writing %s: %s"), realname, - strerror(errno)); + statusline(ALERT, _("Error writing %s: %s"), realname, + strerror(errno)); goto cleanup_and_exit; } unlink(tempname); } else if (fclose(f) != 0) { - statusbar(_("Error writing %s: %s"), realname, - strerror(errno)); + statusline(ALERT, _("Error writing %s: %s"), realname, + strerror(errno)); goto cleanup_and_exit; } @@ -2197,9 +2204,8 @@ stat_with_alloc(realname, &openfile->current_stat); #endif - statusbar(P_("Wrote %lu line", "Wrote %lu lines", - (unsigned long)lineswritten), - (unsigned long)lineswritten); + statusline(INFO, P_("Wrote %lu line", "Wrote %lu lines", + (unsigned long)lineswritten), (unsigned long)lineswritten); openfile->modified = FALSE; titlebar(NULL); } Index: src/search.c =================================================================== --- src/search.c (revision 5749) +++ src/search.c (working copy) @@ -59,7 +59,7 @@ char *str = charalloc(len); regerror(rc, &search_regexp, str, len); - statusbar(_("Bad regex \"%s\": %s"), regexp, str); + statusline(ALERT, _("Bad regex \"%s\": %s"), regexp, str); free(str); return FALSE; @@ -93,7 +93,7 @@ disp = display_string(str, 0, (COLS / 2) + 1, FALSE); numchars = actual_x(disp, mbstrnlen(disp, COLS / 2)); - statusbar(_("\"%.*s%s\" not found"), numchars, disp, + statusline(INFO, _("\"%.*s%s\" not found"), numchars, disp, (disp[numchars] == '\0') ? "" : "..."); free(disp); @@ -892,7 +892,7 @@ edit_refresh(); if (numreplaced >= 0) - statusbar(P_("Replaced %lu occurrence", + statusline(INFO, P_("Replaced %lu occurrence", "Replaced %lu occurrences", (unsigned long)numreplaced), (unsigned long)numreplaced); Index: src/proto.h =================================================================== --- src/proto.h (revision 5749) +++ src/proto.h (working copy) @@ -785,7 +785,8 @@ dollars); void titlebar(const char *path); extern void set_modified(void); -void statusbar(const char *msg, ...); +void statusbar(const char *msg); +void statusline(bool alert, const char *msg, ...); void bottombars(int menu); void onekey(const char *keystroke, const char *desc, size_t len); void reset_cursor(void); Index: src/color.c =================================================================== --- src/color.c (revision 5749) +++ src/color.c (working copy) @@ -66,7 +66,12 @@ interface_color_pair[i].bright = bright; interface_color_pair[i].pairnum = COLOR_PAIR(i + 1); } - else { + else if (i == ATTENTION) { + /* If not defined, the default alert is brightwhite on red. */ + init_pair(i + 1, COLOR_WHITE, COLOR_RED); + interface_color_pair[i].bright = TRUE; + interface_color_pair[i].pairnum = COLOR_PAIR(i + 1); + } else { interface_color_pair[i].bright = FALSE; if (i != FUNCTION_TAG) interface_color_pair[i].pairnum = hilite_attribute; @@ -184,7 +189,7 @@ } if (sint == NULL) - statusbar(_("Unknown syntax name: %s"), syntaxstr); + statusline(ALERT, _("Unknown syntax name: %s"), syntaxstr); } /* If no syntax-override string was specified, or it didn't match, @@ -242,11 +247,11 @@ #endif MAGIC_ERROR); if (cookie == NULL || magic_load(cookie, NULL) < 0) - statusbar(_("magic_load() failed: %s"), strerror(errno)); + statusline(ALERT, _("magic_load() failed: %s"), strerror(errno)); else { magicstring = magic_file(cookie, openfile->filename); if (magicstring == NULL) - statusbar(_("magic_file(%s) failed: %s"), + statusline(ALERT, _("magic_file(%s) failed: %s"), openfile->filename, magic_error(cookie)); #ifdef DEBUG fprintf(stderr, "Returned magic string is: %s\n", magicstring); Index: src/browser.c =================================================================== --- src/browser.c (revision 5749) +++ src/browser.c (working copy) @@ -240,8 +240,8 @@ #ifndef DISABLE_OPERATINGDIR if (check_operating_dir(new_path, FALSE)) { - statusbar(_("Can't go outside of %s in restricted mode"), - operating_dir); + statusline(ALERT, _("Can't go outside of %s " + "in restricted mode"), operating_dir); free(new_path); continue; } @@ -251,7 +251,7 @@ if (dir == NULL) { /* We can't open this directory for some reason. * Complain. */ - statusbar(_("Error reading %s: %s"), answer, + statusline(ALERT, _("Error reading %s: %s"), answer, strerror(errno)); beep(); free(new_path); @@ -277,7 +277,7 @@ } else if (func == do_enter) { /* We can't move up from "/". */ if (strcmp(filelist[selected], "/..") == 0) { - statusbar(_("Can't move up a directory")); + statusline(ALERT, _("Can't move up a directory")); beep(); continue; } @@ -287,8 +287,8 @@ * directory if it's ".." or if it's a symlink to a * directory outside the operating directory. */ if (check_operating_dir(filelist[selected], FALSE)) { - statusbar(_("Can't go outside of %s in restricted mode"), - operating_dir); + statusline(ALERT, _("Can't go outside of %s " + "in restricted mode"), operating_dir); beep(); continue; } @@ -297,7 +297,7 @@ if (stat(filelist[selected], &st) == -1) { /* We can't open this file for some reason. * Complain. */ - statusbar(_("Error reading %s: %s"), + statusline(ALERT, _("Error reading %s: %s"), filelist[selected], strerror(errno)); beep(); continue; @@ -313,7 +313,7 @@ dir = opendir(filelist[selected]); if (dir == NULL) { - statusbar(_("Error reading %s: %s"), + statusline(ALERT, _("Error reading %s: %s"), filelist[selected], strerror(errno)); beep(); continue; Index: src/text.c =================================================================== --- src/text.c (revision 5749) +++ src/text.c (working copy) @@ -478,7 +478,7 @@ filestruct *f = fsfromline(u->mark_begin_lineno); if (!f) { - statusbar(_("Internal error: can't match line %d. " + statusline(ALERT, _("Internal error: can't match line %d. " "Please save your work."), u->mark_begin_lineno); return; } @@ -598,7 +598,7 @@ } if (undidmsg) - statusbar(_("Undid action (%s)"), undidmsg); + statusline(INFO, _("Undid action (%s)"), undidmsg); renumber(f); openfile->current_undo = openfile->current_undo->next; @@ -631,7 +631,7 @@ filestruct *f = fsfromline(u->type == INSERT ? 1 : u->mark_begin_lineno); if (!f) { - statusbar(_("Internal error: can't match line %d. " + statusline(ALERT, _("Internal error: can't match line %d. " "Please save your work."), u->mark_begin_lineno); return; } @@ -734,7 +734,7 @@ } if (redidmsg) - statusbar(_("Redid action (%s)"), redidmsg); + statusline(INFO, _("Redid action (%s)"), redidmsg); openfile->current_undo = u; openfile->last_action = OTHER; @@ -1850,7 +1850,7 @@ #ifdef HAVE_REGEX_H if (quoterc != 0) { - statusbar(_("Bad quote string %s: %s"), quotestr, quoteerr); + statusline(ALERT, _("Bad quote string %s: %s"), quotestr, quoteerr); return FALSE; } #endif @@ -2860,7 +2860,7 @@ temp = safe_tempfile(&temp_file); if (temp == NULL) { - statusbar(_("Error writing temp file: %s"), strerror(errno)); + statusline(ALERT, _("Error writing temp file: %s"), strerror(errno)); return; } @@ -2872,7 +2872,7 @@ write_file(temp, temp_file, TRUE, OVERWRITE, FALSE); if (!status) { - statusbar(_("Error writing temp file: %s"), strerror(errno)); + statusline(ALERT, _("Error writing temp file: %s"), strerror(errno)); free(temp); return; } @@ -2894,10 +2894,10 @@ if (spell_msg != NULL) { if (errno == 0) /* Don't display an error message of "Success". */ - statusbar(_("Spell checking failed: %s"), spell_msg); + statusline(ALERT, _("Spell checking failed: %s"), spell_msg); else - statusbar(_("Spell checking failed: %s: %s"), spell_msg, - strerror(errno)); + statusline(ALERT, _("Spell checking failed: %s: %s"), spell_msg, + strerror(errno)); } else statusbar(_("Finished checking spelling")); } @@ -3102,7 +3102,8 @@ free(read_buff); if (parsesuccess == 0) { - statusbar(_("Got 0 parsable lines from command: %s"), openfile->syntax->linter); + statusline(INFO, _("Got 0 parsable lines from command: %s"), + openfile->syntax->linter); goto exit_from_lint; } @@ -3241,7 +3242,7 @@ temp = safe_tempfile(&temp_file); if (temp == NULL) { - statusbar(_("Error writing temp file: %s"), strerror(errno)); + statusline(ALERT, _("Error writing temp file: %s"), strerror(errno)); return; } @@ -3250,7 +3251,7 @@ status = write_file(temp, temp_file, TRUE, OVERWRITE, FALSE); if (!status) { - statusbar(_("Error writing temp file: %s"), strerror(errno)); + statusline(ALERT, _("Error writing temp file: %s"), strerror(errno)); free(temp); return; } @@ -3393,9 +3394,9 @@ openfile->placewewant = pww_save; /* Display the total word, line, and character counts on the statusbar. */ - statusbar(_("%sWords: %lu Lines: %ld Chars: %lu"), old_mark_set ? - _("In Selection: ") : "", (unsigned long)words, (long)nlines, - (unsigned long)chars); + statusline(INFO, _("%sWords: %lu Lines: %ld Chars: %lu"), old_mark_set ? + _("In Selection: ") : "", (unsigned long)words, (long)nlines, + (unsigned long)chars); } #endif /* !NANO_TINY */ Index: src/winio.c =================================================================== --- src/winio.c (revision 5749) +++ src/winio.c (working copy) @@ -2094,10 +2094,16 @@ wnoutrefresh(edit); } +/* Display a normal message on the statusbar. */ +void statusbar(const char *msg) +{ + statusline(INFO, msg); +} + /* Display a message on the statusbar, and set disable_cursorpos to * TRUE, so that the message won't be immediately overwritten if * constant cursor position display is on. */ -void statusbar(const char *msg, ...) +void statusline(bool alert, const char *msg, ...) { va_list ap; char *bar, *foo; @@ -2136,15 +2142,25 @@ start_x = (COLS - strlenpt(foo) - 4) / 2; wmove(bottomwin, 0, start_x); - if (interface_color_pair[STATUS_BAR].bright) - wattron(bottomwin, A_BOLD); - wattron(bottomwin, interface_color_pair[STATUS_BAR].pairnum); + if (alert) { + if (interface_color_pair[ATTENTION].bright) + wattron(bottomwin, A_BOLD); + wattron(bottomwin, interface_color_pair[ATTENTION].pairnum); + } + else { + if (interface_color_pair[STATUS_BAR].bright) + wattron(bottomwin, A_BOLD); + wattron(bottomwin, interface_color_pair[STATUS_BAR].pairnum); + } waddstr(bottomwin, "[ "); waddstr(bottomwin, foo); free(foo); waddstr(bottomwin, " ]"); wattroff(bottomwin, A_BOLD); - wattroff(bottomwin, interface_color_pair[STATUS_BAR].pairnum); + if (alert) + wattroff(bottomwin, interface_color_pair[ATTENTION].pairnum); + else + wattroff(bottomwin, interface_color_pair[STATUS_BAR].pairnum); wnoutrefresh(bottomwin); /* Leave the cursor in the edit window, not in the statusbar. */ @@ -3137,7 +3153,7 @@ colpct = 100 * cur_xpt / cur_lenpt; charpct = (openfile->totsize == 0) ? 0 : 100 * i / openfile->totsize; - statusbar( + statusline(INFO, _("line %ld/%ld (%d%%), col %lu/%lu (%d%%), char %lu/%lu (%d%%)"), (long)openfile->current->lineno, (long)openfile->filebot->lineno, linepct, Index: src/nano.c =================================================================== --- src/nano.c (revision 5749) +++ src/nano.c (working copy) @@ -1445,7 +1445,8 @@ ) enabled = !enabled; - statusbar("%s %s", _(flagtostr(flag)), enabled ? _("enabled") : _("disabled")); + statusline(INFO, "%s %s", _(flagtostr(flag)), + enabled ? _("enabled") : _("disabled")); } #endif /* !NANO_TINY */ @@ -2517,10 +2518,16 @@ #else interface_color_pair[TITLE_BAR].pairnum = hilite_attribute; interface_color_pair[STATUS_BAR].pairnum = hilite_attribute; + if has_color() { + init_pair(ATTENTION + 1, COLOR_WHITE, COLOR_RED); + interface_color_pair[ATTENTION].pairnum = COLOR_PAIR(ATTENTION + 1); + } else + interface_color_pair[ATTENTION].pairnum = hilite_attribute; interface_color_pair[KEY_COMBO].pairnum = hilite_attribute; interface_color_pair[FUNCTION_TAG].pairnum = A_NORMAL; interface_color_pair[TITLE_BAR].bright = FALSE; interface_color_pair[STATUS_BAR].bright = FALSE; + interface_color_pair[ATTENTION].bright = TRUE; interface_color_pair[KEY_COMBO].bright = FALSE; interface_color_pair[FUNCTION_TAG].bright = FALSE; #endif