/* Call this before any call to linux conio - except the port functions ! */ void init_lconio (void) /* This is needed, because ncurses needs to be initialized */ { int x,y; initialized=1; initscr(); /* initialize curses screen -- modified by GLF to detect X Windows */ #ifdef XCURSES Xinitscr(1, fakelist); /* fake out argument list */ #else initscr(); #endif start_color(); oldattr=wattr_get(stdscr,&store_oldattr.attrs,&store_oldattr.color_pair,&store_oldattr.opts); nonl(); /* disable translation of CR to newline on input */ raw(); /* characters immediately available -- break not processed; like cbreak() but also passes INTR, QUIT, SUSP, and STOP chars */ noecho(); /* no echo of key input */ /* Removed from original linux-conio: if (!has_colors() & (color_warning>-1)) fprintf(stderr,"Attention: A color terminal may be required to run this application !\n"); */ /* GLF settings added to the original linux-conio initializations */ curs_set(0); /* turn off cursor */ /* cbreak(); */ /* characters immediately available -- break not processed */ clear(); /* clear screen */ timeout(0); /* non-blocking read -- if no input, return ERR */ conio_scr=newwin(0,0,0,0); keypad(conio_scr,TRUE); meta(conio_scr,TRUE); idlok(conio_scr,TRUE); scrollok(conio_scr,TRUE); /* Color initialization */ for (y=0;y<=7;y++) for (x=0;x<=7;x++) init_pair((8*y)+x+1, colortab(x), colortab(y)); txtattr=wattr_get(conio_scr,&store_txtattr.attrs,&store_txtattr.color_pair,&store_txtattr.opts); bgc=0; textcolor(7); textbackground(0); }
int attr_get(attr_t *at, short *co, void *opts) { (void) wattr_get(stdscr, at, co, opts); return (OK); }
bool frame::is_attr_on(int attr_on) const { CONS_ASSERT(handle, "invalid handle"); attr_t attr; short pair; wattr_get(handle.get(), &attr, &pair, nullptr); return attr & attr_on; }
/** Redraws the window. Draws the custom interface. @param win The window to redraw. @return OK if successful and ERR otherwise. **/ int OVERLOAD(wrefresh)(WINDOW * const win) { if (options.roll_on) { return OK; } log_call("wrefresh(" PTRF ").", PTRS(win)); /* Stores the state of the window, draws the interface and restores the state. Pointers are used to suppress a warning about a bug in a library. <pre> the comparison will always evaluate as 'true' for the address of 'attrs' will never be NULL [-Waddress] </pre> */ int y, x; attr_t attrs; attr_t * const attrs_ptr = &attrs; short int pair; short int * const pair_ptr = &pair; wattr_get(win, attrs_ptr, pair_ptr, NULL); getyx(win, y, x); wattrset(win, A_NORMAL); const int result = orig_wrefresh(win); gui_draw(win); orig_wrefresh(win); wmove(win, y, x); wattr_set(win, attrs, pair, NULL); return result; }
void gettextinfo(struct text_info *inforec) { unsigned char xp,yp; unsigned char x1,x2,y1,y2; unsigned char cols,lines; unsigned char dattr,dnattr,a; /* The "d" stands for DOS */ attr_store_type store_a_attr; if (initialized==0) init_lconio(); getyx(conio_scr,yp,xp); getbegyx(conio_scr,y1,x1); getmaxyx(conio_scr,y2,x2); dattr=(bgc*16)+fgc; a = wattr_get(conio_scr,&store_a_attr.attrs,&store_a_attr.color_pair,&store_a_attr.opts); if (a==(a & A_BLINK)) dattr=dattr+128; dnattr=oldattr; /* Well, this cannot be right, because we don't know the COLORPAIR values from before init_lconio() !*/ inforec->winleft=x1+1; inforec->wintop=y1+1; if (x1==0) x2--; if (y1==0) y2--; inforec->winright=x1+x2+1; inforec->winbottom=y1+y2+1; inforec->curx=xp+1; inforec->cury=yp+1; inforec->screenheight=y2+1; inforec->screenwidth=x2+1; inforec->currmode=3; /* This is C80 */ inforec->normattr=dnattr; /* Don't use this ! */ inforec->attribute=dattr; }
void Screen::plot(int y, int x, chtype ch, unsigned int attr) { attr_t attr_save; //used in wattr_(get|set) short pair; //used in wattr_(get|set) wattr_get(innerWindow,&attr_save,&pair,NULL);//save terminal state wattron(innerWindow,attr); //Turn on any attributes passed in mvwaddch(innerWindow,y,x,ch); //Write out the character wattr_set(innerWindow,attr_save,pair,NULL);//restore terminal state }
void separe(WINDOW *win) { int attrs, x, y; short pair; /* Saving current state */ wattr_get(win, &attrs, &pair, NULL); /* Print sepration */ wattrset(win, COLOR_PAIR(2)); wvline(win, ACS_VLINE, 1); getyx(win, y, x); wmove(win, y, x + 1); /* Restoring */ wattr_set(win, attrs, pair, NULL); }
/* Get the attributes and color pair number of a window */ SCM gucu_wattr_get (SCM win) { WINDOW *c_win; attr_t c_attrs; short c_pair; SCM s_list; int ret; c_win = _scm_to_window (win); /* wattr_get appears to be a macro that always returns OK */ ret = wattr_get (c_win, &c_attrs, &c_pair, NULL); if (ret == OK) s_list = scm_list_2 (_scm_from_attr (c_attrs), scm_from_short (c_pair)); else abort (); return s_list; }
/* window:print_colored(s, { bold = true, foreground = 3, ... }) Stack: 2nd the string to display 3rd argument is a table who can contain all the attributes above TODO: Optimisation ? */ int lui_print_colored_window(lua_State *L) { WINDOW *w = panel_window(check_window(L, 1)); const char *s = luaL_checkstring(L, 2); /* string to display */ attr_t attr; short pair; t_style style; /* save current state */ wattr_get(w, &attr, &pair, NULL); get_style(L, 3, style); wattron(w, style.on); wattroff(w, style.off); /* put the string */ waddstr(w, s); /* restore old attr */ wattr_set(w, attr, pair, NULL); return 0; }
void vl_int_draw_list(WINDOW *win, unsigned int width, dl_list *sel_entry, dl_list *start_entry, dl_list *stop_entry) { vl_entry *ent; int line; int tmp_attr; int utf8_len; short std_color_pair; attr_t std_attr; wattr_get(win, &std_attr, &std_color_pair, NULL); line = 0; do{ ent = (vl_entry *)start_entry->data; if( ent->attributes) tmp_attr = wattrset(win, ent->attributes); if(start_entry == sel_entry ) wattron(win,A_STANDOUT); mvwaddstr(win, line, 0, ent->str); utf8_len = utf8_strlen(ent->str); mvwhline(win, line, utf8_len, ' ', width - utf8_len); if( ent->attributes) tmp_attr = wattrset(win, std_attr); if(start_entry == sel_entry ) wattroff(win,A_STANDOUT); line ++; start_entry = start_entry->next; }while( start_entry != NULL && start_entry != stop_entry->next ); }
/* chatbox:print_colored(s, { bold = true, foreground = 3, ... }) Stack: 2nd the string to display 3rd argument is a table who can contain all the attributes above TODO: Optimisation ? */ int lui_print_colored_chatbox(lua_State *L) { CHATBOX *c = check_chatbox(L, 1); const char *s = luaL_checkstring(L, 2); /* string to display */ attr_t attr; short pair; t_style style; /* save current state */ wattr_get(c->pad, &attr, &pair, NULL); get_style(L, 3, style); wattron(c->pad, style.on); wattroff(c->pad, style.off); /* put the string */ c->scroll = 0; waddstr(c->pad, s); /* restore old attr */ wattr_set(c->pad, attr, pair, NULL); return 0; }
int attr_get(attr_t *attrs, short *color_pair, void *opts) { PDC_LOG(("attr_get() - called\n")); return wattr_get(stdscr, attrs, color_pair, opts); }