/* Whack up an informational message on the status line */ void msgInfo(const char *fmt, ...) { va_list args; char *errstr; int i, attrs; char line[81]; attrs = getattrs(stdscr); /* NULL is a special convention meaning "erase the old stuff" */ if (!fmt) { move(StatusLine, 0); clrtoeol(); return; } errstr = (char *)alloca(FILENAME_MAX); va_start(args, fmt); vsnprintf(errstr, FILENAME_MAX, fmt, args); va_end(args); memset(line, ' ', 80); for (i = 0; i < 80; i++) { if (errstr[i]) line[i] = errstr[i]; else break; } line[80] = '\0'; attrset(ATTR_TITLE); mvaddstr(StatusLine, 0, line); attrset(attrs); move(StatusLine, 79); refresh(); }
/* Whack up a fatal error on the status line */ void msgFatal(const char *fmt, ...) { va_list args; char *errstr; int attrs; errstr = (char *)alloca(FILENAME_MAX); strcpy(errstr, "Fatal Error: "); va_start(args, fmt); vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); va_end(args); beep(); attrs = getattrs(stdscr); attrset(ATTR_TITLE); mvaddstr(StatusLine, 0, errstr); addstr(" - "); addstr("PRESS ANY KEY TO "); if (getpid() == 1) addstr("REBOOT"); else addstr("QUIT"); attrset(attrs); refresh(); if (OnVTY) msgDebug("Fatal error `%s'!\n", errstr); getch(); }
/* * Print a `one-liner' status message at the bottom of the screen. Messages are * trimmed to fit within the console length (ANSI coloring not accounted for). */ void status_printf(const char *fmt, ...) { int n, attrs; chtype color = dlg_color_pair(dlg_color_table[BUTTON_ACTIVE_ATTR].fg, dlg_color_table[SCREEN_ATTR].bg) | A_BOLD; va_list args; status_row = tty_maxrows() - 1; status_width = tty_maxcols(); /* NULL is a special convention meaning "erase the old stuff" */ if (fmt == NULL) { move(status_row, 0); clrtoeol(); return; } /* Resize buffer if terminal width is greater */ if ((status_width + 1) > status_bufsize) { status_buf = realloc(status_buf, status_width + 1); if (status_buf == NULL) { status_bufsize = -1; return; } status_bufsize = status_width + 1; } /* Print the message within a space-filled buffer */ memset(status_buf, ' ', status_width); va_start(args, fmt); n = vsnprintf(status_buf, status_width + 1, fmt, args); va_end(args); /* If vsnprintf(3) produced less bytes than the maximum, change the * implicitly-added NUL-terminator into a space and terminate at max */ if (n < status_width) { status_buf[n] = ' '; status_buf[status_width] = '\0'; } /* Print text in screen bg, button active fg, and bold */ attrs = getattrs(stdscr); attrset(color); mvaddstr(status_row, 0, status_buf); attrset(attrs); /* Seat the cursor over the last character at absolute lower-right */ move(status_row, status_width - 1); refresh(); }
/* Whack up an informational message on the status line, in stand-out */ void msgYap(const char *fmt, ...) { va_list args; char *errstr; int attrs; errstr = (char *)alloca(FILENAME_MAX); va_start(args, fmt); vsnprintf(errstr, FILENAME_MAX, fmt, args); va_end(args); attrs = getattrs(stdscr); attrset(A_REVERSE); mvaddstr(StatusLine, 0, errstr); attrset(attrs); refresh(); }
static WINDOW * show_cmd(const char *scmd, struct winsize *win) { int n, m; WINDOW *actionwin; int nrow; wclear(stdscr); clearok(stdscr, 1); touchwin(stdscr); refresh(); mvaddstr(0, 4, msg_string(MSG_Status)); standout(); addstr(msg_string(MSG_Running)); standend(); mvaddstr(1, 4, msg_string(MSG_Command)); standout(); printw("%s", scmd); standend(); addstr("\n\n"); for (n = win->ws_col; (m = min(n, 30)) > 0; n -= m) addstr( "------------------------------" + 30 - m); refresh(); nrow = getcury(stdscr) + 1; actionwin = subwin(stdscr, win->ws_row - nrow, win->ws_col, nrow, 0); if (actionwin == NULL) { fprintf(stderr, "sysinst: failed to allocate output window.\n"); exit(1); } scrollok(actionwin, TRUE); if (has_colors()) { wbkgd(actionwin, getbkgd(stdscr)); wattrset(actionwin, getattrs(stdscr)); } wmove(actionwin, 0, 0); wrefresh(actionwin); return actionwin; }
/* Whack up a warning on the status line */ void msgWarn(const char *fmt, ...) { va_list args; char *errstr; int attrs; errstr = (char *)alloca(FILENAME_MAX); strcpy(errstr, "Warning: "); va_start(args, fmt); vsnprintf((char *)(errstr + strlen(errstr)), FILENAME_MAX, fmt, args); va_end(args); attrs = getattrs(stdscr); beep(); attrset(ATTR_TITLE); mvaddstr(StatusLine, 0, errstr); attrset(attrs); refresh(); if (OnVTY && isDebug()) msgDebug("Warning message `%s'\n", errstr); }
EIF_INTEGER c_ecurses_getattrs (EIF_POINTER w) { return getattrs((WINDOW*)w); };