void check_screen_size() /* {{{ */ { /* check for a screen thats too small */ int count = 0; do { if (count) { if (count==1) { wipe_statusbar(); wipe_tasklist(); } wattrset(stdscr, get_colors(OBJECT_ERROR, NULL, NULL)); mvaddstr(0, 0, "screen dimensions too small"); wrefresh(stdscr); wattrset(stdscr, COLOR_PAIR(0)); usleep(100000); } count++; rows = LINES; cols = COLS; } while (cols<DATELENGTH+20+cfg.fieldlengths.project || rows<5); } /* }}} */
static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor, void *bgcolor, void *pflags, char *str, void *level) { GUI_WINDOW_REC *gui; TEXT_BUFFER_VIEW_REC *view; LINE_REC *insert_after; LINE_INFO_REC lineinfo; int fg, bg, flags, attr; flags = GPOINTER_TO_INT(pflags); fg = GPOINTER_TO_INT(fgcolor); bg = GPOINTER_TO_INT(bgcolor); get_colors(flags, &fg, &bg, &attr); if (window == NULL) { g_return_if_fail(next_xpos != -1); attr |= fg >= 0 ? fg : ATTR_RESETFG; attr |= bg >= 0 ? (bg << 4) : ATTR_RESETBG; term_set_color(root_window, attr); term_move(root_window, next_xpos, next_ypos); if (flags & GUI_PRINT_FLAG_CLRTOEOL) term_clrtoeol(root_window); term_addstr(root_window, str); next_xpos += strlen(str); return; } lineinfo.level = GPOINTER_TO_INT(level); lineinfo.time = time(NULL); gui = WINDOW_GUI(window); view = gui->view; insert_after = gui->use_insert_after ? gui->insert_after : view->buffer->cur_line; if (flags & GUI_PRINT_FLAG_NEWLINE) view_add_eol(view, &insert_after); line_add_colors(view->buffer, &insert_after, fg, bg, flags); if (flags & GUI_PRINT_FLAG_INDENT_FUNC) { /* specify the indentation function */ line_add_indent_func(view->buffer, &insert_after, str); } else { insert_after = textbuffer_insert(view->buffer, insert_after, (unsigned char *) str, strlen(str), &lineinfo); } if (gui->use_insert_after) gui->insert_after = insert_after; }
void GradientEditor::_ramp_changed() { editing = true; UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo(); undo_redo->create_action(TTR("Gradient Edited")); undo_redo->add_do_method(gradient.ptr(), "set_offsets", get_offsets()); undo_redo->add_do_method(gradient.ptr(), "set_colors", get_colors()); undo_redo->add_undo_method(gradient.ptr(), "set_offsets", gradient->get_offsets()); undo_redo->add_undo_method(gradient.ptr(), "set_colors", gradient->get_colors()); undo_redo->commit_action(); editing = false; }
//Initializes the prompt static void init_prompt() { //Sets the username, homedir, and hostname, and colors if(!got_username || !got_homedir) get_username_homedir(); //Sets the hostname if we don't already have it if(!got_hostname) get_hostname(); //Sets the prompt colors if we don't already have it if(!got_di_color || !got_ex_color) get_colors(); //Sets the current working dir and the short version if(dir_changed) get_cwd(); }
static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor, void *bgcolor, void *pflags, char *str, TEXT_DEST_REC *dest) { GUI_WINDOW_REC *gui; TEXT_BUFFER_VIEW_REC *view; LINE_REC *insert_after; LINE_INFO_REC lineinfo; int fg, bg, flags, attr; flags = GPOINTER_TO_INT(pflags); fg = GPOINTER_TO_INT(fgcolor); bg = GPOINTER_TO_INT(bgcolor); get_colors(flags, &fg, &bg, &attr); if (window == NULL) { g_return_if_fail(next_xpos != -1); term_set_color2(root_window, attr, fg, bg); term_move(root_window, next_xpos, next_ypos); if (flags & GUI_PRINT_FLAG_CLRTOEOL) term_clrtoeol(root_window); term_addstr(root_window, str); next_xpos += strlen(str); /* FIXME utf8 or big5 */ return; } lineinfo.level = dest == NULL ? 0 : dest->level; gui = WINDOW_GUI(window); lineinfo.time = (gui->use_insert_after && gui->insert_after_time) ? gui->insert_after_time : time(NULL); view = gui->view; insert_after = gui->use_insert_after ? gui->insert_after : view->buffer->cur_line; if (flags & GUI_PRINT_FLAG_NEWLINE) { view_add_eol(view, &insert_after); } textbuffer_line_add_colors(view->buffer, &insert_after, fg, bg, flags); insert_after = textbuffer_insert(view->buffer, insert_after, (unsigned char *) str, strlen(str), &lineinfo); if (gui->use_insert_after) gui->insert_after = insert_after; }
void print_header() /* {{{ */ { /* print the window title bar */ char *tmp0; /* wipe bar and print bg color */ wmove(header, 0, 0); wattrset(header, get_colors(OBJECT_HEADER, NULL, NULL)); /* evaluate title string */ tmp0 = (char *)eval_format(cfg.formats.title_compiled, NULL); umvaddstr_align(header, 0, tmp0); free(tmp0); wnoutrefresh(header); } /* }}} */
int save_colors(XFILE *file) { int *colors; long n; if ((n = x_fwrite(file, &ncolors, sizeof(int))) < 0) return (int) n; if ((colors = get_colors()) == NULL) return ENSMEM; if ((n = x_fwrite(file, colors, (long) ncolors * 3L * sizeof(int))) < 0) return (int) n; free(colors); return 0; }
static int print_one_arg(t_param *buf) { char *standout; char buf2[30]; char *ap; ap = buf2; if ((buf->select % 2) == 1 && (standout = tgetstr("us", &ap)) != NULL) tputs(standout, 1, fputchar); if ((buf->select / 2) == 1 && (standout = tgetstr("so", &ap)) != NULL) tputs(standout, 1, fputchar); get_colors(buf->var); ft_dprintf(get_fd(0), "%s\x1b[0;m", buf->var); if ((buf->select % 2) == 1 && (standout = tgetstr("ue", &ap)) != NULL) tputs(standout, 1, fputchar); if ((buf->select / 2) == 1 && (standout = tgetstr("se", &ap)) != NULL) tputs(standout, 1, fputchar); if ((int)ft_strlen(buf->var) > get_width()) return (-1); return (0); }
static void gui_printtext(WINDOW_REC *window, gpointer fgcolor, gpointer bgcolor, gpointer pflags, char *str, gpointer level) { GUI_WINDOW_REC *gui; LINE_REC *line; int fg, bg, flags, new_lines, n, visible, ypos, subline; g_return_if_fail(window != NULL); remove_old_lines(window); gui = WINDOW_GUI(window); visible = is_window_visible(window) && gui->bottom; flags = GPOINTER_TO_INT(pflags); fg = GPOINTER_TO_INT(fgcolor); bg = GPOINTER_TO_INT(bgcolor); if (gui->cur_text == NULL) create_text_chunk(gui); /* \n can be only at the start of the line.. */ if (*str == '\n') { str++; linebuf_add(gui, "\0\x80", 2); /* mark EOL */ line = create_line(gui, 0); gui_window_newline(gui, visible); gui->cur_text->lines++; gui->last_subline = 0; } else { line = gui->cur_line != NULL ? gui->cur_line : create_line(gui, 0); if (line->level == 0) line->level = GPOINTER_TO_INT(level); } get_colors(flags, &fg, &bg); line_add_colors(gui, fg, bg, flags); linebuf_add(gui, str, strlen(str)); mark_temp_eol(gui->cur_text); gui_window_cache_remove(gui, line); new_lines = gui_window_get_linecount(gui, line)-1 - gui->last_subline; for (n = 0; n < new_lines; n++) gui_window_newline(gui, visible); if (visible) { /* draw the line to screen. */ ypos = gui->ypos-new_lines; if (new_lines > 0) { set_color(0); move(gui->parent->first_line+ypos, 0); clrtoeol(); } if (ypos >= 0) subline = gui->last_subline; else { /* *LONG* line - longer than screen height */ subline = -ypos+gui->last_subline; ypos = 0; } ypos += gui->parent->first_line; gui_window_line_draw(gui, line, ypos, subline, -1); } gui->last_subline += new_lines; }
static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor, void *bgcolor, void *pflags, char *str, void *level) { GUI_WINDOW_REC *gui; LINE_REC *line; int fg, bg, flags, new_lines, n, visible, ypos, subline; flags = GPOINTER_TO_INT(pflags); fg = GPOINTER_TO_INT(fgcolor); bg = GPOINTER_TO_INT(bgcolor); get_colors(flags, &fg, &bg); if (window == NULL && next_xpos != -1) { wmove(stdscr, next_ypos, next_xpos); set_color(stdscr, fg | (bg << 4)); addstr(str); next_xpos += strlen(str); return; } g_return_if_fail(window != NULL); gui = WINDOW_GUI(window); visible = is_window_visible(window) && gui->bottom; if (gui->cur_text == NULL) create_text_chunk(gui); /* newline can be only at the start of the line.. */ if (flags & PRINTFLAG_NEWLINE) { remove_old_lines(window); if (!gui->eol_marked) { if (format->len > 0 || gui->temp_line != NULL) { /* mark format continuing to next line */ char tmp[2] = { 0, (char)LINE_CMD_FORMAT_CONT }; linebuf_add(gui, tmp, 2); } linebuf_add(gui, "\0\200", 2); /* mark EOL */ } gui->eol_marked = FALSE; line = create_line(gui, 0); if (gui->temp_line == NULL || g_list_find(gui->startline, gui->temp_line) != NULL) gui_window_newline(gui, visible); gui->last_subline = 0; } else { line = gui->temp_line != NULL ? gui->temp_line : gui->cur_line != NULL ? gui->cur_line : create_line(gui, 0); if (line->level == 0) line->level = GPOINTER_TO_INT(level); } line_add_colors(gui, fg, bg, flags); linebuf_add(gui, str, strlen(str)); mark_temp_eol(gui->cur_text); gui_window_cache_remove(gui, line); if (gui->temp_line != NULL) { /* updating existing line - don't even try to print it to screen */ return; } new_lines = gui_window_get_linecount(gui, line)-1 - gui->last_subline; for (n = 0; n < new_lines; n++) gui_window_newline(gui, visible); if (visible) { /* draw the line to screen. */ ypos = gui->ypos-new_lines; if (new_lines > 0) { #ifdef USE_CURSES_WINDOWS set_color(gui->parent->curses_win, 0); wmove(gui->parent->curses_win, ypos, 0); wclrtoeol(gui->parent->curses_win); #else set_color(stdscr, 0); move(ypos + gui->parent->first_line, 0); wclrtoeol(stdscr); #endif } if (ypos >= 0) subline = gui->last_subline; else { /* *LONG* line - longer than screen height */ subline = -ypos+gui->last_subline; ypos = 0; } gui_window_line_draw(gui, line, ypos, subline, -1); } gui->last_subline += new_lines; }