/* * draw_thin_red_line() * */ static void draw_thin_red_line(window_t *w, int y) { ncurses_window_t *n = w->priv_data; int attr = color_pair(COLOR_RED, COLOR_BLACK) | A_BOLD | A_ALTCHARSET; wattrset(n->window, attr); mvwhline(n->window, n->margin_top + y, 0, ACS_HLINE, w->width); }
/* * returns currsor x position */ static int ncurses_redraw_input_line(CHAR_T *text) { #ifdef HAVE_LIBASPELL char *aspell_line = NULL; #endif int i, stop, cur_posx = 0; int attr = A_NORMAL; const int linelen = xwcslen(text); int promptlen = getcurx(input); int width = input->_maxx + 1 - promptlen; int y = getcury(input); #ifdef HAVE_LIBASPELL if (spell_checker) { aspell_line = xmalloc(linelen + 1); spellcheck(text, aspell_line); } #endif stop = linelen < width+line_start ? linelen : width + line_start; for (i = line_start; i < stop; i++) { if (line_index == i) { cur_posx = getcurx(input); } #ifdef HAVE_LIBASPELL if (aspell_line && aspell_line[i] == ASPELLCHAR && text[i] != ' ') /* jesli b³êdny to wy¶wietlamy podkre¶lony */ attr = A_UNDERLINE; else attr = A_NORMAL; #endif print_char(input, text[i], attr); } if (line_index >= i) { cur_posx = getcurx(input); } #ifdef HAVE_LIBASPELL xfree(aspell_line); #endif if (width>2) { wattrset(input, color_pair(COLOR_BLACK, COLOR_BLACK) | A_BOLD); if (line_start > 0) mvwaddch(input, y, promptlen, '<'); if (linelen && linelen - line_start > width) mvwaddch(input, y, input->_maxx, '>'); } wattrset(input, A_NORMAL); return cur_posx; }
/* * wyswietla ponownie linie wprowadzenia tekstu (prompt + aktualnie wpisany tekst) * przy okazji jesli jest aspell to sprawdza czy tekst jest poprawny. */ void ncurses_redraw_input(unsigned int ch) { int x, y; /* draw prompt */ werase(input); wmove(input, 0, 0); if (!ncurses_lines) { gchar *tmp = ekg_recode_to_locale(format_find( ncurses_current->prompt ? "ncurses_prompt_query" : "ncurses_prompt_none")); gchar *tmp2 = format_string(tmp, "\037"); /* unit separator */ fstring_t *prompt_f = fstring_new(tmp2); gchar *s = prompt_f->str, *s2; fstr_attr_t *a = prompt_f->attr, *a2; g_free(tmp2); g_free(tmp); if (ncurses_current->prompt) { /* find our \037 */ for (s2 = s, a2 = a; *s2 != '\037'; s2++, a2++) g_assert(*s2); *s2 = '\0'; /* and split the original string using it */ } ncurses_fstring_print(input, s, a, -1); if (ncurses_current->prompt) { if (!ncurses_simple_print(input, ncurses_current->prompt, *a2, input->_maxx / 4)) { /* don't change colors or anything * just disable bold to distinguish */ wattroff(input, A_BOLD); /* XXX? */ waddstr(input, ncurses_hellip); } s2++, a2++; ncurses_fstring_print(input, s2, a2, -1); } fstring_free(prompt_f); } getyx(input, y, x); ncurses_current->prompt_len = x; /* XXX: cleanup, optimize */ { int cur_posx = -1, cur_posy = 0; const int width = input->_maxx - x; if ((line_index - line_start >= width) || (line_index - line_start < 2)) line_start = line_index - width/2; if (line_start < 0) line_start = 0; ncurses_redraw_input_already_exec = 1; wattrset(input, color_pair(COLOR_WHITE, COLOR_BLACK)); if (ncurses_lines) { int i, x; cur_posy = lines_index - lines_start; for (i = 0; i < MULTILINE_INPUT_SIZE; i++) { if (!ncurses_lines[lines_start + i]) break; wmove(input, i, 0); x = ncurses_redraw_input_line(ncurses_lines[lines_start + i]); if (lines_index == (lines_start + i)) cur_posx = x; } wattrset(input, color_pair(COLOR_BLACK, COLOR_BLACK) | A_BOLD); if (lines_start>0) mvwaddch(input, 0, input->_maxx, '^'); if (g_strv_length((char **) ncurses_lines)-lines_start > MULTILINE_INPUT_SIZE) mvwaddch(input, MULTILINE_INPUT_SIZE-1, input->_maxx, 'v'); wattrset(input, A_NORMAL); } else { #if 0 if (ncurses_noecho) { static char *funnything = ncurses_funnything; waddch(input, ' '); /* XXX why here? If you want to add space after propt, add it in theme */ waddch(input, *funnything); wmove(input, 0, getcurx(input)-1); if (!*(++funnything)) funnything = ncurses_funnything; return; } #endif cur_posx = ncurses_redraw_input_line(ncurses_line); } /* this mut be here if we don't want 'timeout' after pressing ^C */ if (ch == 3) ncurses_commit(); if (cur_posx != -1) { wmove(input, cur_posy, cur_posx); curs_set(1); } else { wmove(input, 0, 0); // XXX ??? curs_set(0); } } }