Exemple #1
0
void wsetcolor (WINDOW *w,int n,int m)
{
   if (m==1) wattr_set (w,A_BOLD,0,0);
   else wattr_set (w,A_NORMAL,0,0);
   wcolor_set (w,n,0);
   if ((nocolor==1) && ((n==2) || (n==3) || (n==5) || (n==7) || (n==10) || (n==11) || (n==12) || (n==13))) wattrset (w,A_REVERSE);
}
Exemple #2
0
int
attr_set(attr_t at, short co, void *opts)
{
	(void) wattr_set(stdscr, at, co, opts);

	return (OK);
}
Exemple #3
0
/**
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;
}
Exemple #4
0
/**
 * mvwcch -- move the cursor and write a complex character and rendition
 * @win : pointer to a WINDOW
 * @y   : y-coordinate to write at
 * @x   : x-coordinate to write at
 * @wch : pointer to the wchar_t to be written
 * @attr: the desired window attributes
 * @pair: the desired color pair
 */
void mvwcch(WINDOW *win, int y, int x, const wchar_t *wch, attr_t attr, short pair)
{
        SAVEWIN(win);
        wattr_set(win, attr, pair, NULL);
        if (wch && (*wch != L'\0')) {
                mvwaddnwstr(win, y, x, wch, 1);
        }
        RESTORE(win);
}
Exemple #5
0
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
}
Exemple #6
0
void CWidget::setBold(bool bold)
{
	DEBUG_ui("CWidget::setBold");
	_bold = bold;

	wbkgdset(_window, attribute(_bgcolor, _fgcolor, _bold));
	wattr_set(_window, _bold ? A_BOLD : A_NORMAL, colorpair(_bgcolor, _fgcolor), 0);

	_changed = true;
}
Exemple #7
0
void CWidget::setForegroundColor(Color color)
{
	DEBUG_ui("CWidget::setForegroundColor");
	_fgcolor = color;

	wbkgdset(_window, attribute(_bgcolor, _fgcolor, _bold));
	wattr_set(_window, _bold ? A_BOLD : A_NORMAL, colorpair(_bgcolor, _fgcolor), 0);

	_changed = true;
}
Exemple #8
0
int
slk_attr_set(const attr_t at, short co, void *opts)
{
	int code = ERR;

#ifdef M_CURSES_TRACE
	__m_trace("slk_attr_set(%x, %d, %p)", at, co, opts);
#endif

	if (__m_screen->_slk._w != (WINDOW *) 0)
		code = wattr_set(__m_screen->_slk._w, at, co, opts);

	return __m_return_code("slk_attr_set", code);
}
Exemple #9
0
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);
}
Exemple #10
0
/*
  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;
}
Exemple #11
0
/* Set the attributes and color pair for a given window */
SCM
gucu_wattr_set_x (SCM win, SCM attrs, SCM pair)
{
  WINDOW *c_win;
  attr_t c_attrs;
  short c_pair;
  int ret;

  SCM_ASSERT (_scm_is_window (win), win, SCM_ARG1, "wattr-set!");
  SCM_ASSERT (_scm_is_attr (attrs), attrs, SCM_ARG2, "wattr-set!");
  SCM_ASSERT (scm_is_integer (pair), pair, SCM_ARG3, "wattr-set!");

  c_win = _scm_to_window (win);
  c_attrs = _scm_to_attr (attrs);
  c_pair = scm_to_short (pair);

  /* wattr_set always returns OK */
  ret = wattr_set (c_win, c_attrs, c_pair, NULL);
  if (ret != OK)
    abort ();

  return SCM_UNSPECIFIED;
}
Exemple #12
0
/*
  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;
}
Exemple #13
0
 void CursesRenderer::style(Colour fg, Colour bg, int styleMask)
 {
   int pair = getPair(fg, bg);
   styleMask |= A_COLOR;
   wattr_set(win(), styleMask, pair, NULL);
 }
Exemple #14
0
int attr_set(attr_t attrs, short color_pair, void *opts)
{
    PDC_LOG(("attr_get() - called\n"));

    return wattr_set(stdscr, attrs, color_pair, opts);
}
Exemple #15
0
void myprintloc(WINDOW *w, int y, int x, const char *fmt, ...)
{
	char *line = NULL;
	int line_len = 0;
	va_list ap;

	va_start(ap, fmt);
	line_len = vasprintf(&line, fmt, ap);
	va_end(ap);

	wmove(w, y, x);

	if (use_colors)
	{
		int index = 0;

		for(index=0; index<line_len; index++)
		{
			static int clr = C_WHITE, att = A_NORMAL;

			if (line[index] == COLOR_ESCAPE[0])
			{
				switch(line[++index])
				{
					case '1':
						clr = C_RED;
						break;
					case '2':
						clr = C_BLUE;
						break;
					case '3':
						clr = C_GREEN;
						break;
					case '4':
						clr = C_YELLOW;
						break;
					case '5':
						clr = C_MAGENTA;
						break;
					case '6':
						clr = C_CYAN;
						break;
					case '7':
						clr = C_WHITE;
						break;
					case '8':
						att = A_BOLD;
						break;
					case '9':
						att = A_NORMAL;
						break;
				}

				wattr_set(w, att, clr, NULL);
			}
			else
			{
				waddch(w, line[index]);
			}
		}
	}
	else
	{
		mvwprintw(w, y, x, "%s", line);
	}

	free(line);
}