/* * Print the tag of a menu-item */ static void print_tag(WINDOW *win, char **items, int choice, int selected) { int my_x = item_x; int my_y = ItemToRow(choice); int tag_width = (my_x - tag_x - GUTTER); const int *cols; const int *indx; int limit; unsigned prefix; cols = dlg_index_columns(ItemName(0)); indx = dlg_index_wchars(ItemName(0)); limit = dlg_count_wchars(ItemName(0)); prefix = indx[1] - indx[0]; /* highlight first char of the tag to be special */ (void) wmove(win, my_y, tag_x); wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); if (strlen(ItemName(0)) != 0) (void) waddnstr(win, ItemName(0), prefix); /* print rest of the string */ wattrset(win, selected ? tag_selected_attr : tag_attr); if (strlen(ItemName(0)) > prefix) { limit = dlg_limit_columns(ItemName(0), tag_width, 1); if (limit > 0) (void) waddnstr(win, ItemName(0) + indx[1], indx[limit] - indx[1]); } }
void mrutils::ColChooser::printPrompt(const char * prompt, const char * prefix) { int n = 0; wmove((WINDOW*)chooserWin,maxLines-1,0); wattrset((WINDOW*)chooserWin,ATR_INPUT); wclrtoeol((WINDOW*)chooserWin); if (prefix != NULL) { waddnstr((WINDOW*)chooserWin,prefix,-1); n += strlen(prefix); } waddnstr((WINDOW*)chooserWin,prompt,-1); n += strlen(prompt); if (data[active].applySearch && !enteringSearch && prompt[0] != '>') { waddnstr((WINDOW*)chooserWin," searching /",-1); n += 12; waddnstr((WINDOW*)chooserWin,data[active].search,-1); n += strlen(data[active].search); waddnstr((WINDOW*)chooserWin,"/",-1); ++n; } wattrset((WINDOW*)chooserWin,ATR_BLANK); wchgat((WINDOW*)chooserWin, -1, A_NORMAL, COL_INPUT, NULL); wrefresh((WINDOW*)chooserWin); move(maxLines-1,n); }
void display_cmd(const char *cmd, int cl, int cursor_pos) { cmd_len = cl; if (cursor_pos == -1 || cursor_pos > cmd_len) cursor_pos = cmd_len; cmd_cursor_pos = cursor_pos; cmd_cmd = cmd; display_lock(); werase(win_cmd); if (cursor_pos < cmd_len) { waddnstr(win_cmd, cmd, cursor_pos); wbkgdset(win_cmd, COLOR_PAIR(YELLOW_ON_BLACK)); waddnstr(win_cmd, cmd + cursor_pos, 1); wbkgdset(win_cmd, COLOR_PAIR(BLACK_ON_YELLOW)); waddnstr(win_cmd, cmd + cursor_pos + 1, cmd_len - (cursor_pos + 1)); } else { waddnstr(win_cmd, cmd, cmd_len); wmove(win_cmd, cursor_pos, 0); wbkgdset(win_cmd, COLOR_PAIR(YELLOW_ON_BLACK)); waddstr(win_cmd, " "); wbkgdset(win_cmd, COLOR_PAIR(BLACK_ON_YELLOW)); } wattroff(win_stat, A_UNDERLINE); wrefresh(win_cmd); display_unlock(); }
/* * Print list item */ static void print_item(WINDOW *win, char **items, int status, int choice, int selected) { int i; chtype attr = A_NORMAL; const int *indx; int limit; /* Clear 'residue' of last item */ wattrset(win, menubox_attr); (void) wmove(win, choice, 0); for (i = 0; i < list_width; i++) (void) waddch(win, ' '); (void) wmove(win, choice, check_x); wattrset(win, selected ? check_selected_attr : check_attr); (void) wprintw(win, (checkflag == FLAG_CHECK) ? "[%c]" : "(%c)", status ? 'X' : ' '); wattrset(win, menubox_attr); (void) waddch(win, ' '); if (strlen(ItemName(0)) != 0) { indx = dlg_index_wchars(ItemName(0)); limit = dlg_count_wchars(ItemName(0)); wattrset(win, selected ? tag_key_selected_attr : tag_key_attr); (void) waddnstr(win, ItemName(0), indx[1]); if ((int) strlen(ItemName(0)) > indx[1]) { limit = dlg_limit_columns(ItemName(0), (item_x - check_x - 6), 1); if (limit > 1) { wattrset(win, selected ? tag_selected_attr : tag_attr); (void) waddnstr(win, ItemName(0) + indx[1], indx[limit] - indx[1]); } } } if (strlen(ItemText(0)) != 0) { indx = dlg_index_wchars(ItemText(0)); limit = dlg_limit_columns(ItemText(0), (getmaxx(win) - item_x - 1), 0); if (limit > 0) { (void) wmove(win, choice, item_x); wattrset(win, selected ? item_selected_attr : item_attr); dlg_print_text(win, ItemText(0), indx[limit], &attr); } } if (selected) { dlg_item_help(ItemHelp(0)); } }
/* * drawMenuItem() is a local function that draws a menu list item (for * drawList) */ static void drawMenuItem(Obj *obj, int idx, WINDOW *win, int x, int y) { int current = obj->item.list.cury; int iscurrent = (current == idx && (IS_CURRENT(obj) || (obj->flags & ALWAYS_HIGHLIT))); int color = iscurrent ? SELECTED_COLOR : WINDOW_COLOR; if (iscurrent && !IS_CURRENT(obj)) color |= READONLY_COLOR; wmove(win, y, x); if (obj->flags & SHOW_IDS) { char *p = obj->item.list.items[idx].id; if ((obj->flags & NO_HOTKEYS) == 0) { setcolor(win, iscurrent ? SELECTED_COLOR : HOTKEY_COLOR); waddch(win, (*p++)); } setcolor(win, color); waddstr(win, p); } setcolor(win, color); wmove(win, y, x+obj->item.list.itemoffset); waddnstr(win, obj->item.list.items[idx].item, obj->width - obj->item.list.itemoffset); setcolor(win, WINDOW_COLOR); } /* drawMenuItem */
/* * Print a new line of text. */ static void print_line(MY_OBJ * obj, int row, int width) { if (wmove(obj->text, row, 0) != ERR) { int i, y, x; char *line = get_line(obj); const int *cols = dlg_index_columns(line); const int *indx = dlg_index_wchars(line); int limit = dlg_count_wchars(line); int first = 0; int last = limit; if (width > getmaxx(obj->text)) width = getmaxx(obj->text); --width; /* for the leading ' ' */ for (i = 0; i <= limit && cols[i] < obj->hscroll; ++i) first = i; for (i = first; (i <= limit) && ((cols[i] - cols[first]) < width); ++i) last = i; (void) waddch(obj->text, ' '); (void) waddnstr(obj->text, line + indx[first], indx[last] - indx[first]); getyx(obj->text, y, x); if (y == row) { /* Clear 'residue' of previous line */ for (i = 0; i <= width - x; i++) { (void) waddch(obj->text, ' '); } } } }
static bool draw_chars(struct view *view, enum line_type type, const char *string, int max_len, bool use_tilde) { int len = 0; int col = 0; int trimmed = FALSE; size_t skip = view->pos.col > view->col ? view->pos.col - view->col : 0; if (max_len <= 0) return VIEW_MAX_LEN(view) <= 0; if (opt_iconv_out != ICONV_NONE) { string = encoding_iconv(opt_iconv_out, string); if (!string) return VIEW_MAX_LEN(view) <= 0; } len = utf8_length(&string, skip, &col, max_len, &trimmed, use_tilde, opt_tab_size); set_view_attr(view, type); if (len > 0) { waddnstr(view->win, string, len); if (trimmed && use_tilde) { set_view_attr(view, LINE_DELIMITER); waddch(view->win, '~'); col++; } } view->col += col; return VIEW_MAX_LEN(view) <= 0; }
static bool draw_chars(struct view *view, enum line_type type, const char *string, int length, int max_width, bool use_tilde) { int len = 0; int col = 0; int trimmed = false; size_t skip = view->pos.col > view->col ? view->pos.col - view->col : 0; if (max_width <= 0) return VIEW_MAX_LEN(view) <= 0; len = utf8_length(&string, length, skip, &col, max_width, &trimmed, use_tilde, opt_tab_size); if (opt_iconv_out != ICONV_NONE) { string = encoding_iconv(opt_iconv_out, string, len); if (!string) return VIEW_MAX_LEN(view) <= 0; } set_view_attr(view, type); if (len > 0) waddnstr(view->win, string, len); if (trimmed && use_tilde) { set_view_attr(view, LINE_DELIMITER); waddstr(view->win, opt_truncation_delimiter ? opt_truncation_delimiter : "~"); col++; } view->col += col; return VIEW_MAX_LEN(view) <= 0; }
/* * simplewin() draws a simple window */ void simplewin(WINDOW *win, /* ... in the given WINDOW */ int lines, /* of this many lines */ int cols, /* and this many cols */ char *title, /* with this title */ int formy, /* starting here */ int withbuttons) /* and with buttons, perhaps? */ { werase(win); drawbox(win, 0, 0, lines, cols, withbuttons ? lines-3 : 0, RELIEF_COLOR, WINDOW_COLOR); if (title) { int titlex = (cols - strlen(title)) / 2; setcolor(win, TITLE_COLOR); if (titlex < 1) { wmove(win, 0, 0); waddnstr(win, title, cols-2); } else mvwaddstr(win, 0, titlex, title); } setcolor(win, WINDOW_COLOR); } /* simplewin */
/* * Print a new line of text. Called by dialog_textbox() and print_page(). */ static void print_line(WINDOW * win, int row, int width) { int y=0, x=0; char *line; y=x; x=y; line = get_line(); line += MIN(strlen(line), hscroll); /* Scroll horizontally */ wmove(win, row, 0); /* move cursor to correct line */ waddch(win, ' '); waddnstr(win, line, MIN(strlen(line), width - 2)); getyx(win, y, x); /* Clear 'residue' of previous line */ #if OLD_NCURSES { int i; for (i = 0; i < width - x; i++) waddch(win, ' '); } #else wclrtoeol(win); #endif }
static int addstr4(SCR *sp, const void *str, size_t len, int wide) { WINDOW *win; size_t y, x; int iv; win = CLSP(sp) ? CLSP(sp) : stdscr; /* * If ex isn't in control, it's the last line of the screen and * it's a split screen, use inverse video. */ iv = 0; getyx(win, y, x); __USE(x); if (!F_ISSET(sp, SC_SCR_EXWROTE) && y == RLNO(sp, LASTLINE(sp)) && IS_SPLIT(sp)) { iv = 1; (void)wstandout(win); } #ifdef USE_WIDECHAR if (wide) { if (waddnwstr(win, str, len) == ERR) return (1); } else #endif if (waddnstr(win, str, len) == ERR) return (1); if (iv) (void)wstandend(win); return (0); }
static void update_text_lines(void) { int i; int width; const char *line_begin; const char *line_end; int cur_y, cur_x; int rest_of_line; for (i = 0; i < text_box_y; ++i) { width = current_left; line_begin = mbs_at_width(text_lines[current_top + i], &width, 1); wmove(text_widget.window, i + 1, 1); if (width > current_left) waddch(text_widget.window, ' '); if (*line_begin != '\0') { width = text_box_x - (width > current_left); line_end = mbs_at_width(line_begin, &width, -1); if (width) waddnstr(text_widget.window, line_begin, line_end - line_begin); } getyx(text_widget.window, cur_y, cur_x); if (cur_y == i + 1) { rest_of_line = text_box_x + 1 - cur_x; if (rest_of_line > 0) wprintw(text_widget.window, "%*s", rest_of_line, ""); } } }
/* * drawHighlitItem() is a local function that draws a highlit * checklist item (for drawList) */ static void drawHighlitItem(Obj* obj, int idx, WINDOW* win, int x, int y) { int current = obj->item.list.cury; int selected = obj->item.list.items[idx].selected; int color = selected ? SELECTED_COLOR : WINDOW_COLOR; if ((current == idx) && IS_CURRENT(obj)) { mvwaddch(win, y, x+obj->width-1, ACS_LARROW); mvwaddch(win, y, x, ACS_RARROW); } wmove(win, y, x + 1); if (obj->flags & SHOW_IDS) { char *p = obj->item.list.items[idx].id; if ((obj->flags & NO_HOTKEYS) == 0) { setcolor(win, HOTKEY_COLOR); waddch(win, (*p++)); } setcolor(win, color); waddstr(win, p); } setcolor(win, color); wmove(win, y, x+obj->item.list.itemoffset); waddnstr(win, obj->item.list.items[idx].item, obj->width - obj->item.list.itemoffset); setcolor(win, WINDOW_COLOR); } /* drawHighlitItem */
/* * mvwaddnstr -- * Add a string of at most n characters to the given window * starting at (y, x). */ int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int count) { if (wmove(win, y, x) == ERR) return ERR; return waddnstr(win, str, count); }
int addstr(const char *str) { int code; code = waddnstr(stdscr, str, -1); return (code); }
int mvaddstr(int y, int x, const char *str) { PDC_LOG(("mvaddstr() - called: y %d x %d string=\"%s\"\n", y, x, str)); if (move(y, x) == ERR) return ERR; return waddnstr(stdscr, str, -1); }
int waddstr(WINDOW *w, const char *str) { int code; code = waddnstr(w, str, -1); return (code); }
void mrutils::GuiEditBox::redraw() { box((WINDOW*)win, 0, 0); mvwaddch((WINDOW*)win, 2, 0, ACS_LTEE); mvwhline((WINDOW*)win, 2, 1, ACS_HLINE, winCols - 2); mvwaddch((WINDOW*)win, 2, winCols - 1, ACS_RTEE); wmove((WINDOW*)win, 1, MAX_(3,(int)(winCols - title.size())/2)); waddnstr((WINDOW*)win, title.c_str(), winCols-2); }
int mvwaddstr(WINDOW *win, int y, int x, const char *str) { PDC_LOG(("mvwaddstr() - called: string=\"%s\"\n", str)); if (wmove(win, y, x) == ERR) return ERR; return waddnstr(win, str, -1); }
int addnstr(const char *str, int n) { int code; code = waddnstr(stdscr, str, n); return (code); }
void print_line(GList *line) { int line_number = g_list_position(first_line, line); GNode *file = NODE(line); int depth = g_node_depth(file) - 1; char *link_str; wmove(tree_window, line_number, 0); wclrtoeol(tree_window); if (line == selected_line) wattron(tree_window, A_REVERSE); if (G_NODE_IS_ROOT(file)) { wattron(tree_window, A_BOLD); waddnstr(tree_window, FILE(file)->name, getmaxx(tree_window) - 1); if (!g_str_has_suffix(FILE(file)->name, "/")) waddch(tree_window, '/'); wattroff(tree_window, A_BOLD); } else { if (file != g_node_last_sibling(file)) mvwaddch(tree_window, line_number, 2 * depth - 2, ACS_LTEE); else mvwaddch(tree_window, line_number, 2 * depth - 2, ACS_LLCORNER); waddch(tree_window, ACS_HLINE); if (FILE(file)->link == TRUE) { link_str = g_strdup_printf("%s -> %s", FILE(file)->name, FILE(file)->link_path); waddnstr(tree_window, link_str, getmaxx(tree_window) - 2 * depth - 1); free(link_str); } else waddnstr(tree_window, FILE(file)->name, getmaxx(tree_window) - 2 * depth - 1); if (FILE(file)->type == directory_type && ((FILE(file)->link == TRUE && !g_str_has_suffix(FILE(file)->link_path, "/")) || (FILE(file)->link == FALSE && !g_str_has_suffix(FILE(file)->name, "/")))) waddch(tree_window, '/'); print_parents_lines(line); } wattroff(tree_window, A_REVERSE); }
int mvaddnstr(int y, int x, const char *str, int n) { int code; if ((code = wmove(stdscr, y, x)) == OK) code = waddnstr(stdscr, str, n); return (code); }
void do_waddstr(state *st) { int arity; long slot, strlen; ei_decode_tuple_header(st->args, &(st->index), &arity); ei_decode_long(st->args, &(st->index), &slot); ei_decode_long(st->args, &(st->index), &strlen); char str[strlen]; ei_decode_string(st->args, &(st->index), str); encode_ok_reply(st, waddnstr(st->win[slot], str, strlen)); }
/* Write a shortcut key to the help area at the bottom of the window. * keystroke is e.g. "^G" and desc is e.g. "Get Help". We are careful * to write at most len characters, even if len is very small and * keystroke and desc are long. Note that waddnstr(,,(size_t)-1) adds * the whole string! We do not bother padding the entry with blanks. */ void onekey(const std::string& keystroke, const std::string& desc, size_t len) { size_t keystroke_len = keystroke.length() + 1; set_color(bottomwin, interface_colors[KEY_COMBO]); waddnstr(bottomwin, keystroke.c_str(), actual_x(keystroke.c_str(), len)); clear_color(bottomwin, interface_colors[KEY_COMBO]); if (len > keystroke_len) { len -= keystroke_len; } else { len = 0; } if (len > 0) { waddch(bottomwin, ' '); waddnstr(bottomwin, desc.c_str(), actual_x(desc.c_str(), len)); } }
point frame::write(const point& pt, const std::string& str, int n) { CONS_ASSERT(handle, "invalid handle"); CONS_ASSERT(n>=0 && std::size_t(n) <= str.size(), "n is greater than string length"); set_cursor(pt); //throws if(waddnstr(handle.get(), str.c_str(), n)==ERR) { throw CONS_MAKE_EXCEPTION("Unable to write string to frame"); } return get_cursor(); }
void win_printline_nowrap(WINDOW *win, char *msg) { int maxx = getmaxx(win); int cury = getcury(win); waddnstr(win, msg, maxx); wmove(win, cury+1, 0); }
int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n) { PDC_LOG(("mvwaddnstr() - called: y %d x %d string=\"%s\" n %d \n", y, x, str, n)); if (wmove(win, y, x) == ERR) return ERR; return waddnstr(win, str, n); }
int mvwaddnstr(WINDOW *w, int y, int x, const char *str, int n) { int code; if ((code = wmove(w, y, x)) == OK) code = waddnstr(w, str, n); return (code); }
int mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n) { int res; res = wmove(win, y, x); if (res != OK) { return res; } return waddnstr(win, str, n); }
/* * Print a button */ static void print_button(WINDOW *win, char *label, int y, int x, int selected) { int i; int state = 0; const int *indx = dlg_index_wchars(label); int limit = dlg_count_wchars(label); chtype key_attr = (selected ? button_key_active_attr : button_key_inactive_attr); chtype label_attr = (selected ? button_label_active_attr : button_label_inactive_attr); (void) wmove(win, y, x); wattrset(win, selected ? button_active_attr : button_inactive_attr); (void) waddstr(win, "<"); wattrset(win, label_attr); for (i = 0; i < limit; ++i) { int first = indx[i]; int last = indx[i + 1]; switch (state) { case 0: #ifdef USE_WIDE_CURSES if ((last - first) != 1) { const char *temp = (label + first); int cmp = string_to_char(&temp); if (dlg_isupper(cmp)) { wattrset(win, key_attr); state = 1; } break; } #endif if (dlg_isupper(UCH(label[first]))) { wattrset(win, key_attr); state = 1; } break; case 1: wattrset(win, label_attr); state = 2; break; } waddnstr(win, label + first, last - first); } wattrset(win, selected ? button_active_attr : button_inactive_attr); (void) waddstr(win, ">"); (void) wmove(win, y, x + ((int) strspn(label, " ")) + 1); }