Пример #1
0
static void
gnt_box_draw(GntWidget *widget)
{
	GntBox *box = GNT_BOX(widget);

	if (box->focus == NULL && widget->parent == NULL)
		g_list_foreach(box->list, add_to_focus, box);

	g_list_foreach(box->list, (GFunc)gnt_widget_draw, NULL);

	if (box->title && !GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_NO_BORDER))
	{
		int pos, right;
		char *title = g_strdup(box->title);

		get_title_thingies(box, title, &pos, &right);

		if (gnt_widget_has_focus(widget))
			wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_TITLE));
		else
			wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_TITLE_D));
		mvwaddch(widget->window, 0, pos-1, ACS_RTEE | gnt_color_pair(GNT_COLOR_NORMAL));
		mvwaddstr(widget->window, 0, pos, title);
		mvwaddch(widget->window, 0, right, ACS_LTEE | gnt_color_pair(GNT_COLOR_NORMAL));
		g_free(title);
	}

	gnt_box_sync_children(box);
}
Пример #2
0
void gnt_init()
{
	char *filename;
	const char *locale;

	if (channel)
		return;
	
	locale = setlocale(LC_ALL, "");

	setup_io();

#ifdef NO_WIDECHAR
	ascii_only = TRUE;
#else
	if (locale && (strstr(locale, "UTF") || strstr(locale, "utf")))
		ascii_only = FALSE;
	else
		ascii_only = TRUE;
#endif

	initscr();
	typeahead(-1);
	noecho();
	curs_set(0);

	gnt_init_keys();
	gnt_init_styles();

	filename = g_build_filename(g_get_home_dir(), ".gntrc", NULL);
	gnt_style_read_configure_file(filename);
	g_free(filename);

	gnt_init_colors();

	wbkgdset(stdscr, '\0' | gnt_color_pair(GNT_COLOR_NORMAL));
	refresh();

#ifdef ALL_MOUSE_EVENTS
	if ((mouse_enabled = gnt_style_get_bool(GNT_STYLE_MOUSE, FALSE)))
		mousemask(ALL_MOUSE_EVENTS | REPORT_MOUSE_POSITION, NULL);
#endif

	wbkgdset(stdscr, '\0' | gnt_color_pair(GNT_COLOR_NORMAL));
	werase(stdscr);
	wrefresh(stdscr);

#ifdef SIGWINCH
	org_winch_handler = signal(SIGWINCH, sighandler);
#endif
	signal(SIGCHLD, sighandler);
	signal(SIGINT, sighandler);
	signal(SIGPIPE, SIG_IGN);

	g_type_init();

	init_wm();

	clipboard = g_object_new(GNT_TYPE_CLIPBOARD, NULL);
}
Пример #3
0
void display_column_print_core_task(const struct display_column *display_column, int row, struct lcore_cfg *lconf, struct task_args *targ)
{
	if (row >= max_n_lines)
		return;

	if (lconf->n_tasks_run == 0) {
		wattron(win_stat, A_BOLD);
		wbkgdset(win_stat, COLOR_PAIR(RED_ON_NOTHING));
	}
	if (targ->id == 0)
		mvwaddstrf(win_stat, row + 2, display_column->offset, "%2u/", lconf->id);
	if (lconf->n_tasks_run == 0) {
		wattroff(win_stat, A_BOLD);
		wbkgdset(win_stat, COLOR_PAIR(NO_COLOR));
	}
	if (!lconf_task_is_running(lconf, targ->id)) {
		wattron(win_stat, A_BOLD);
		wbkgdset(win_stat, COLOR_PAIR(RED_ON_NOTHING));
	}
	mvwaddstrf(win_stat, row + 2, display_column->offset + 3, "%1u", targ->id);
	if (!lconf_task_is_running(lconf, targ->id)) {
		wattroff(win_stat, A_BOLD);
		wbkgdset(win_stat, COLOR_PAIR(NO_COLOR));
	}
}
Пример #4
0
void
clock_move(int x, int y, int w, int h)
{

    /* Erase border for a clean move */
    wbkgdset(ttyclock->framewin, COLOR_PAIR(0));
    wborder(ttyclock->framewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
    wbkgdset(ttyclock->datewin, COLOR_PAIR(0));
    wborder(ttyclock->datewin, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
    werase(ttyclock->framewin);
    werase(ttyclock->datewin);
    wrefresh(ttyclock->framewin);
    wrefresh(ttyclock->datewin);

    /* Frame win move */
    mvwin(ttyclock->framewin, (ttyclock->geo.x = x), (ttyclock->geo.y = y));
    wresize(ttyclock->framewin, (ttyclock->geo.h = h), (ttyclock->geo.w = w));

    /* Date win move */
    mvwin(ttyclock->datewin,
          ttyclock->geo.x + ttyclock->geo.h - 1,
          ttyclock->geo.y + (ttyclock->geo.w / 2) - (strlen(ttyclock->date.datestr) / 2) - 1);
    wresize(ttyclock->datewin, DATEWINH, strlen(ttyclock->date.datestr) + 2);

    if(ttyclock->option.box) {
        box(ttyclock->framewin, 0, 0);
        box(ttyclock->datewin,  0, 0);
    }

    wrefresh(ttyclock->datewin);
    wrefresh(ttyclock->framewin);

    return;
}
Пример #5
0
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();
}
Пример #6
0
void display_page_draw_frame(const struct display_page *display_page, int height)
{
	const struct display_table *table;
	const struct display_column *col;

	wattron(win_stat, A_BOLD);
	wbkgdset(win_stat, COLOR_PAIR(YELLOW_ON_NOTHING));

	for (int i = 0; i < display_page->n_tables; ++i) {
		table = &display_page->tables[i];

		if (i != 0)
			mvwvline(win_stat, 0, table->offset - 1,  ACS_VLINE, height + 2);

		mvwaddstrf(win_stat, 0, table->offset + table->width / 2 - strlen(table->title) / 2, "%s", table->title);
		for (int j = 0; j < table->n_cols; ++j) {
			col = &table->cols[j];

			if (j != 0)
				mvwvline(win_stat, 1, col->offset - 1, ACS_VLINE, height + 1);
			mvwaddstrf(win_stat, 1, col->offset + col->width / 2 - strlen(col->title) / 2, "%s", col->title);
		}

		if (i + 1 == display_page->n_tables)
			mvwvline(win_stat, 0, table->offset + table->width,  ACS_VLINE, height + 2);
	}
	wbkgdset(win_stat, COLOR_PAIR(NO_COLOR));
	wattroff(win_stat, A_BOLD);
}
Пример #7
0
void CWidget::InitDraw()
{
    if (m_bSizeChanged)
    {
        m_bSizeChanged = false;
        MoveWindow(0, 0); // Move to a safe position first
        WindowResize(this, Width(), Height());
        MoveWindow(X(), Y());
        UpdateSize();
        TUI.QueueRefresh();
    }
    
    if (m_bColorsChanged)
    {
        if (m_bFocused)
            wbkgdset(m_pNCursWin, ' ' | TUI.GetColorPair(m_FColors.first, m_FColors.second) | A_BOLD);
        else
            wbkgdset(m_pNCursWin, ' ' | TUI.GetColorPair(m_DFColors.first, m_DFColors.second) | A_BOLD);
        
        m_bColorsChanged = false;
        
        UpdateColors();
    }
    
    WindowErase(this);

    if (HasBox())
        Border(this);
}
Пример #8
0
static PANEL *
mkpanel(short color, int rows, int cols, int tly, int tlx)
{
    WINDOW *win;
    PANEL *pan = 0;
    char *userdata = typeMalloc(char, 3);

    if ((win = newwin(rows, cols, tly, tlx)) != 0) {
	keypad(win, TRUE);
	if ((pan = new_panel(win)) == 0) {
	    delwin(win);
	} else if (use_colors) {
	    short fg = (short) ((color == COLOR_BLUE)
				? COLOR_WHITE
				: COLOR_BLACK);
	    short bg = color;

	    init_pair(color, fg, bg);
	    wbkgdset(win, (chtype) (COLOR_PAIR(color) | ' '));
	} else if (!unboxed) {
	    wbkgdset(win, A_BOLD | ' ');
	}
    }
    sprintf(userdata, "p%d", color % 8);
    set_panel_userptr(pan, (NCURSES_CONST void *) userdata);
    return pan;
}
Пример #9
0
static void
gnt_menu_draw(GntWidget *widget)
{
	GntMenu *menu = GNT_MENU(widget);
	GList *iter;
	chtype type;
	guint i;

	if (menu->type == GNT_MENU_TOPLEVEL) {
		wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_HIGHLIGHT));
		werase(widget->window);

		for (i = 0, iter = menu->list; iter; iter = iter->next, i++) {
			GntMenuItem *item = GNT_MENU_ITEM(iter->data);
			if (!gnt_menuitem_is_visible(item))
				continue;
			type = ' ';
			if (item->callback || item->submenu)
				type |= gnt_color_pair(GNT_COLOR_HIGHLIGHT);
			else
				type |= gnt_color_pair(GNT_COLOR_DISABLED);
			if (i == menu->selected)
				type |= A_REVERSE;
			item->priv.x = getcurx(widget->window) + widget->priv.x;
			item->priv.y = getcury(widget->window) + widget->priv.y + 1;
			wbkgdset(widget->window, type);
			wprintw(widget->window, " %s   ", C_(item->text));
		}
	} else {
		org_draw(widget);
	}

	GNTDEBUG;
}
Пример #10
0
/*
 * print a string in the window
 */
void wdg_scroll_print(wdg_t *wo, int color, char *fmt, ...)
{
   WDG_WO_EXT(struct wdg_scroll, ww);
   size_t c = wdg_get_ncols(wo);
   size_t l = wdg_get_nlines(wo);
   size_t x = wdg_get_begin_x(wo);
   size_t y = wdg_get_begin_y(wo);
   va_list ap;
   
   WDG_DEBUG_MSG("wdg_scroll_print");

   /* move to the bottom of the pad */
   wdg_set_scroll(wo, ww->y_max - l + 1);

   wbkgdset(ww->sub, COLOR_PAIR(color));

   /* print the message */
   va_start(ap, fmt);
   vw_printw(ww->sub, fmt, ap);
   va_end(ap);
   
   wbkgdset(ww->sub, COLOR_PAIR(wo->window_color));
   
   WDG_PAD_REFRESH(ww, c, l, x, y);
}
Пример #11
0
static void
gnt_entry_draw(GntWidget *widget)
{
	GntEntry *entry = GNT_ENTRY(widget);
	int stop;
	gboolean focus;
	int curpos;

	if ((focus = gnt_widget_has_focus(widget)))
		wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_TEXT_NORMAL));
	else
		wbkgdset(widget->window, '\0' | gnt_color_pair(GNT_COLOR_HIGHLIGHT_D));

	if (entry->masked)
	{
		mvwhline(widget->window, 0, 0, gnt_ascii_only() ? '*' : ACS_BULLET,
				g_utf8_pointer_to_offset(entry->scroll, entry->end));
	}
	else
		mvwprintw(widget->window, 0, 0, "%s", C_(entry->scroll));

	stop = gnt_util_onscreen_width(entry->scroll, entry->end);
	if (stop < widget->priv.width)
		mvwhline(widget->window, 0, stop, ENTRY_CHAR, widget->priv.width - stop);

	curpos = gnt_util_onscreen_width(entry->scroll, entry->cursor);
	if (focus)
		mvwchgat(widget->window, 0, curpos, 1, A_REVERSE, GNT_COLOR_TEXT_NORMAL, NULL);
	wmove(widget->window, 0, curpos);

	GNTDEBUG;
}
Пример #12
0
/*
==================
CON_DrawScrollBar
==================
*/
static void CON_DrawScrollBar(void)
{
    int scroll;

    if (lastline <= LOG_LINES)
    {
        scroll = 0;
    }
    else
    {
        scroll = scrollline * (LOG_LINES - 1) / (lastline - LOG_LINES);
    }

    if (com_ansiColor && !com_ansiColor->integer)
    {
        wbkgdset(scrollwin, SCRLBAR_LINE);
    }
    else
    {
        wbkgdset(scrollwin, SCRLBAR_LINE | COLOR_PAIR(6));
    }

    werase(scrollwin);
    wbkgdset(scrollwin, ' ');
    CON_SetColor(scrollwin, 1);
    mvwaddch(scrollwin, scroll, 0, SCRLBAR_CURSOR);
    wnoutrefresh(scrollwin);
}
Пример #13
0
void syncmode_gui::tick()
{
	pthread_mutex_lock(&mutex);

	switch(cfg.getsync())
	{
		case SYNC_SYNCED:
			printfounds();
			printstatus(selx,sely);
			break;
		case SYNC_FOUND:
			delwin(popupwin);

			wbkgdset(mainwin,(COLOR_PAIR(1)|A_BOLD));
			wbkgdset(statuswin,(COLOR_PAIR(1)|A_BOLD));
			wbkgdset(msgwin,(COLOR_PAIR(1)|A_BOLD));

			box(mainwin,0,0);
			box(statuswin,0,0);
			box(msgwin,0,0);

			keypad(mainwin,TRUE);

			doupdate();
			cfg.setsync(SYNC_SYNCED);
			break;
		case SYNC_SEARCH:
			break;
	}

	pthread_mutex_unlock(&mutex);
}
Пример #14
0
static void display_stats_general_per_sec(void)
{
	struct global_stats_sample *gsl = stats_get_global_stats(1);
	struct global_stats_sample *gsp = stats_get_global_stats(0);

	uint64_t rx_pps = val_to_rate(gsl->host_rx_packets - gsp->host_rx_packets, gsl->tsc - gsp->tsc);
	uint64_t tx_pps = val_to_rate(gsl->host_tx_packets - gsp->host_tx_packets, gsl->tsc - gsp->tsc);
	/* Host: RX, TX, Diff */
	pps_print(win_general, 0, 12, rx_pps, 1);
	pps_print(win_general, 0, 25, tx_pps, 1);

	uint64_t diff = 0;
	if (rx_pps > tx_pps)
		diff = rx_pps - tx_pps;
	pps_print(win_general, 0, 40, diff, 1);

	uint64_t nics_rx_pps = val_to_rate(gsl->nics_rx_packets - gsp->nics_rx_packets, gsl->tsc - gsp->tsc);
	uint64_t nics_tx_pps = val_to_rate(gsl->nics_tx_packets - gsp->nics_tx_packets, gsl->tsc - gsp->tsc);
	uint64_t nics_ierrors = val_to_rate(gsl->nics_ierrors - gsp->nics_ierrors, gsl->tsc - gsp->tsc);
	uint64_t nics_imissed = val_to_rate(gsl->nics_imissed - gsp->nics_imissed, gsl->tsc - gsp->tsc);

	/* NIC: RX, TX, Diff */
	pps_print(win_general, 1, 12, nics_rx_pps, 1);
	pps_print(win_general, 1, 25, nics_tx_pps, 1);
	pps_print(win_general, 1, 40, nics_ierrors + nics_imissed, 1);

	wbkgdset(win_general, COLOR_PAIR(CYAN_ON_NOTHING));
	wattron(win_general, A_BOLD);
	mvwaddstrf(win_general, 0, 103, "%6.2f", tx_pps > rx_pps? 100 : tx_pps * 100.0 / rx_pps);
	wattroff(win_general, A_BOLD);
	wbkgdset(win_general, COLOR_PAIR(NO_COLOR));

	struct global_stats_sample *gsb = stats_get_global_stats_beg();
	if (gsb) {
		uint64_t rx_pps = val_to_rate(gsl->host_rx_packets - gsb->host_rx_packets, gsl->tsc - gsb->tsc);
		uint64_t tx_pps = val_to_rate(gsl->host_tx_packets - gsb->host_tx_packets, gsl->tsc - gsb->tsc);

		uint64_t nics_rx_pps = val_to_rate(gsl->nics_rx_packets - gsb->nics_rx_packets, gsl->tsc - gsb->tsc);
		uint64_t nics_tx_pps = val_to_rate(gsl->nics_tx_packets - gsb->nics_tx_packets, gsl->tsc - gsb->tsc);
		uint64_t nics_ierrors = val_to_rate(gsl->nics_ierrors - gsb->nics_ierrors, gsl->tsc - gsb->tsc);
		uint64_t nics_imissed = val_to_rate(gsl->nics_imissed - gsb->nics_imissed, gsl->tsc - gsb->tsc);

		pps_print(win_general, 0, 64, rx_pps, 0);
		pps_print(win_general, 0, 77, tx_pps, 0);

		pps_print(win_general, 1, 64, nics_rx_pps, 0);
		pps_print(win_general, 1, 77, nics_tx_pps, 0);
		pps_print(win_general, 1, 91, nics_ierrors + nics_imissed, 0);

		wbkgdset(win_general, COLOR_PAIR(CYAN_ON_NOTHING));
		wattron(win_general, A_BOLD);
		uint64_t nics_in = gsl->host_rx_packets - gsb->host_rx_packets + gsl->nics_ierrors - gsb->nics_ierrors + gsl->nics_imissed - gsb->nics_imissed;
		uint64_t nics_out = gsl->host_tx_packets - gsb->host_tx_packets;
		mvwaddstrf(win_general, 1, 103, "%6.2f", nics_out > nics_in?
			   100 : nics_out * 100.0 / nics_in);
		wattron(win_general, A_BOLD);
		wbkgdset(win_general, COLOR_PAIR(NO_COLOR));
	}
}
Пример #15
0
void
draw_clock(void)
{
     /* Draw hour numbers */
     draw_number(ttyclock->date.hour[0], 1, 1);
     draw_number(ttyclock->date.hour[1], 1, 8);

     if (ttyclock->option.blink){
       time_t seconds;
       seconds = time(NULL);

       if (seconds % 2 != 0){
           /* 2 dot for number separation */
           wbkgdset(ttyclock->framewin, COLOR_PAIR(1));
           mvwaddstr(ttyclock->framewin, 2, 16, "  ");
           mvwaddstr(ttyclock->framewin, 4, 16, "  ");
       }
       else if (seconds % 2 == 0){
           /*2 dot black for blinking */
           wbkgdset(ttyclock->framewin, COLOR_PAIR(2));
           mvwaddstr(ttyclock->framewin, 2, 16, "  ");
           mvwaddstr(ttyclock->framewin, 4, 16, "  ");
       }
     }
     else{
       /* 2 dot for number separation */
       wbkgdset(ttyclock->framewin, COLOR_PAIR(1));
       mvwaddstr(ttyclock->framewin, 2, 16, "  ");
       mvwaddstr(ttyclock->framewin, 4, 16, "  ");
     }

     /* Draw minute numbers */
     draw_number(ttyclock->date.minute[0], 1, 20);
     draw_number(ttyclock->date.minute[1], 1, 27);

     /* Draw the date */
     if (ttyclock->option.date)
     {
          wbkgdset(ttyclock->datewin, (COLOR_PAIR(2)));
          mvwprintw(ttyclock->datewin, (DATEWINH / 2), 1, ttyclock->date.datestr);
          wrefresh(ttyclock->datewin);
     }

     /* Draw second if the option is enable */
     if(ttyclock->option.second)
     {
          /* Again 2 dot for number separation */
          wbkgdset(ttyclock->framewin, COLOR_PAIR(1));
          mvwaddstr(ttyclock->framewin, 2, NORMFRAMEW, "  ");
          mvwaddstr(ttyclock->framewin, 4, NORMFRAMEW, "  ");

          /* Draw second numbers */
          draw_number(ttyclock->date.second[0], 1, 39);
          draw_number(ttyclock->date.second[1], 1, 46);
     }

     return;
}
Пример #16
0
_nc_Draw_Menu(const MENU * menu)
{
  ITEM *item = menu->items[0];
  ITEM *lasthor, *lastvert;
  ITEM *hitem;
  int y = 0;
  chtype s_bkgd;

  assert(item && menu->win);

  s_bkgd = getbkgd(menu->win);
  wbkgdset(menu->win, menu->back);
  werase(menu->win);
  wbkgdset(menu->win, s_bkgd);

  lastvert = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : item;

  do
    {
      wmove(menu->win, y, 0);

      hitem = item;
      lasthor = (menu->opt & O_NONCYCLIC) ? (ITEM *) 0 : hitem;

      do
	{
	  _nc_Post_Item(menu, hitem);

	  wattron(menu->win, menu->back);
	  if (((hitem = hitem->right) != lasthor) && hitem)
	    {
	      int i, j, cy, cx;
	      chtype ch = ' ';

	      getyx(menu->win, cy, cx);
	      for (j = 0; j < menu->spc_rows; j++)
		{
		  wmove(menu->win, cy + j, cx);
		  for (i = 0; i < menu->spc_cols; i++)
		    {
		      waddch(menu->win, ch);
		    }
		}
	      wmove(menu->win, cy, cx + menu->spc_cols);
	    }
	}
      while (hitem && (hitem != lasthor));
      wattroff(menu->win, menu->back);

      item = item->down;
      y += menu->spc_rows;

    }
  while (item && (item != lastvert));
}
Пример #17
0
static void draw_general_frame(void)
{
	if (screen_state.toggle == 0) {
		wattron(win_general, A_BOLD);
		wbkgdset(win_general, COLOR_PAIR(MAGENTA_ON_NOTHING));
		mvwaddstrf(win_general, 0, 9, "rx:         tx:          diff:                     rx:          tx:                        %%:");
		mvwaddstrf(win_general, 1, 9, "rx:         tx:          err:                      rx:          tx:          err:          %%:");
		wbkgdset(win_general, COLOR_PAIR(NO_COLOR));

		wbkgdset(win_general, COLOR_PAIR(BLUE_ON_NOTHING));
		mvwaddstrf(win_general, 0, 0, "Host pps ");
		mvwaddstrf(win_general, 1, 0, "NICs pps ");

		wbkgdset(win_general, COLOR_PAIR(CYAN_ON_NOTHING));
		mvwaddstrf(win_general, 0, 56, "avg");
		mvwaddstrf(win_general, 1, 56, "avg");
		wbkgdset(win_general, COLOR_PAIR(NO_COLOR));
		wattroff(win_general, A_BOLD);
	} else {
		wattron(win_general, A_BOLD);
		wbkgdset(win_general, COLOR_PAIR(BLUE_ON_NOTHING));
		mvwaddstrf(win_general, 0, 9, "rx:                   tx:                   rx-tx:                      tx/rx:            rx/tx:");
		mvwaddstrf(win_general, 1, 9, "rx:                   tx:                   err:                        tx/rx:            rx/tx:");
		wbkgdset(win_general, COLOR_PAIR(NO_COLOR));

		wbkgdset(win_general, COLOR_PAIR(CYAN_ON_NOTHING));
		mvwaddstrf(win_general, 0, 0, "Host tot ");
		mvwaddstrf(win_general, 1, 0, "NICs tot ");
		wattroff(win_general, A_BOLD);
	}
}
Пример #18
0
/*
 * wbkgd --
 *	Set new background and new background attributes.
 */
int
wbkgd(WINDOW *win, chtype ch)
{
	int	y, x;

#ifdef DEBUG
	__CTRACE(__CTRACE_ATTR, "wbkgd: (%p), '%s', %08x\n",
	    win, unctrl(ch & +__CHARTEXT), ch & __ATTRIBUTES);
#endif

	/* Background attributes (check colour). */
	if (__using_color && !(ch & __COLOR))
		ch |= __default_color;

	win->battr = (attr_t) ch & __ATTRIBUTES;
	wbkgdset(win, ch);
	for (y = 0; y < win->maxy; y++)
		for (x = 0; x < win->maxx; x++) {
			/* Copy character if space */
			if (ch & A_CHARTEXT && win->alines[y]->line[x].ch == ' ')
				win->alines[y]->line[x].ch = ch & __CHARTEXT;
			/* Merge attributes */
			if (win->alines[y]->line[x].attr & __ALTCHARSET)
				win->alines[y]->line[x].attr =
				    (ch & __ATTRIBUTES) | __ALTCHARSET;
			else
				win->alines[y]->line[x].attr =
				    ch & __ATTRIBUTES;
#ifdef HAVE_WCHAR
			SET_WCOL(win->alines[y]->line[x], 1);
#endif
		}
	__touchwin(win);
	return(OK);
}
Пример #19
0
static void
gnt_combo_box_draw(GntWidget *widget)
{
	GntComboBox *box = GNT_COMBO_BOX(widget);
	char *text = NULL, *s;
	GntColorType type;
	int len;

	if (box->dropdown && box->selected)
		text = gnt_tree_get_selection_text(GNT_TREE(box->dropdown));

	if (text == NULL)
		text = g_strdup("");

	if (gnt_widget_has_focus(widget))
		type = GNT_COLOR_HIGHLIGHT;
	else
		type = GNT_COLOR_NORMAL;

	wbkgdset(widget->window, '\0' | gnt_color_pair(type));

	s = (char*)gnt_util_onscreen_width_to_pointer(text, widget->priv.width - 4, &len);
	*s = '\0';

	mvwaddstr(widget->window, 1, 1, C_(text));
	whline(widget->window, ' ' | gnt_color_pair(type), widget->priv.width - 4 - len);
	mvwaddch(widget->window, 1, widget->priv.width - 3, ACS_VLINE | gnt_color_pair(GNT_COLOR_NORMAL));
	mvwaddch(widget->window, 1, widget->priv.width - 2, ACS_DARROW | gnt_color_pair(GNT_COLOR_NORMAL));
	wmove(widget->window, 1, 1);

	g_free(text);
	GNTDEBUG;
}
Пример #20
0
static void update_title_win(struct view *view)
{
    size_t len;
    if (view == display[current_view])
        wbkgdset(view->title, get_line_attr(LINE_TITLE_FOCUS));
#ifdef yaomoon
fprintf(moon_log,"get linue red attr =%d\n",get_line_attr(LINE_TITLE_FOCUS));
#endif


    werase(view->title);
    wmove(view->title, 0, 0);
    wprintw(view->title, "[RPathN]");
    wmove(view->title, 0, 9);
    waddstr(view->title, view->file);
    len = strlen(view->file); 
    wmove(view->title, 0, len + 13);

    if (view->lines) { 
        wprintw(view->title, "line %d of %d (%d%%)",
            view->lineno + 1,
            view->lines,
            (view->lineno + 1) * 100 / view->lines);
    }

    wclrtoeol(view->title);
    wrefresh(view->title);
}
Пример #21
0
/* Picks window to use for suggestion box and prepares it for displaying data.
 * Sets *height to number of suggestions to display.  Returns picked window. */
static WINDOW *
prepare_suggestion_box(int *height)
{
	WINDOW *win;
	const col_attr_t col = cfg.cs.color[SUGGEST_BOX_COLOR];
	const int count = vle_compl_get_count();

	if((cfg.sug.flags & SF_OTHERPANE) && curr_stats.number_of_windows == 2)
	{
		win = other_view->win;
		*height = MIN(count, getmaxy(win));
	}
	else
	{
		const int max_height = getmaxy(stdscr) - getmaxy(status_bar) -
			ui_stat_job_bar_height() - 2;
		*height = MIN(count, max_height);
		wresize(stat_win, *height, getmaxx(stdscr));
		ui_stat_reposition(getmaxy(status_bar), 1);
		win = stat_win;
	}

	wbkgdset(win, COLOR_PAIR(colmgr_get_pair(col.fg, col.bg)) | col.attr);
	werase(win);

	return win;
}
Пример #22
0
void wbkgrndset(WINDOW *win, const cchar_t *wch)
{
    PDC_LOG(("wbkgdset() - called\n"));

    if (wch)
        wbkgdset(win, *wch);
}
Пример #23
0
static void _owl_fmtext_wcolor_set(WINDOW *w, short pair)
{
  if (owl_global_get_hascolors(&g)) {
      wcolor_set(w,pair,NULL);
      wbkgdset(w, COLOR_PAIR(pair));
  }
}
Пример #24
0
void Message::redraw ()
{
  logWrite ("Message::redraw");

  // Truncate the message, if necessary.
  std::string s = "Using database ~/.task";
  if (width - 1 < (int) s.length ())
    s = s.substr (0, width - 4) + "...";

  // Need at least space for blank + 1 char + ellipsis.
  if (width <= 5)
    s = "";

  pthread_mutex_lock (&conch);
  wbkgd (window, COLOR_PAIR (5));
  wbkgdset (window, COLOR_PAIR(5) | A_DIM);

  if (width <= 5)
    touchwin (window);

  mvwaddstr (window, 0, 1, s.c_str ());

  wrefresh (window);
  pthread_mutex_unlock (&conch);
}
Пример #25
0
/*
 * wbkgd --
 *	Set new background and new background attributes.
 */
int
wbkgd(WINDOW *win, chtype ch)
{
	int	y, x;

	/* Background attributes (check colour). */
	if (__using_color && !(ch & __COLOR))
		ch |= __default_color;

	win->battr = (attr_t) ch & __ATTRIBUTES;
	wbkgdset(win, ch);
	for (y = 0; y < win->maxy; y++)
		for (x = 0; x < win->maxx; x++) {
			/* Copy character if space */
			if (ch & A_CHARTEXT && win->alines[y]->line[x].ch == ' ')
				win->alines[y]->line[x].ch = ch & __CHARTEXT;
			/* Merge attributes */
			if (win->alines[y]->line[x].attr & __ALTCHARSET)
				win->alines[y]->line[x].attr =
				    (ch & __ATTRIBUTES) | __ALTCHARSET;
			else
				win->alines[y]->line[x].attr =
				    ch & __ATTRIBUTES;
			SET_WCOL(win->alines[y]->line[x], 1);
		}
	__touchwin(win);
	return(OK);
}
Пример #26
0
//------------------------------------------------------------------------------
void wbkgrndset( WINDOW* win, const cchar_t* wch )
{ 
    __QCS_FCONTEXT( "wbkgrndset" );

    if( wch )
	{
        wbkgdset( win, *wch );
	}
}
Пример #27
0
 void con_ta( int attr )
 {
   __ta = attr;
   wattrset(conio_scr,0); /* (???) My curses-version needs this ... */
   __fg = COLORFG(attr);
   __bg = COLORBG(attr);
   wattrset(conio_scr,COLOR_PAIR(CON_PAIR( __fg%8, __bg%8 )) | ( __bg > 7 )*(A_BLINK) | ( __fg > 7 )*(A_BOLD) );
   wbkgdset( conio_scr, COLOR_PAIR(CON_PAIR( __fg%8, __bg%8 )) );
 }
Пример #28
0
/*
 * draw the borders and title
 */
static void wdg_scroll_border(struct wdg_object *wo)
{
   WDG_WO_EXT(struct wdg_scroll, ww);
   size_t c = wdg_get_ncols(wo);
      
   /* the object was focused */
   if (wo->flags & WDG_OBJ_FOCUSED) {
      wattron(ww->win, A_BOLD);
      wbkgdset(ww->win, COLOR_PAIR(wo->focus_color));
   } else
      wbkgdset(ww->win, COLOR_PAIR(wo->border_color));

   /* draw the borders */
   box(ww->win, 0, 0);

   /* draw the elevator */
   wdg_set_scroll(wo, ww->y_scroll);
   
   /* set the title color */
   wbkgdset(ww->win, COLOR_PAIR(wo->title_color));
   
   /* there is a title: print it */
   if (wo->title) {
      switch (wo->align) {
         case WDG_ALIGN_LEFT:
            wmove(ww->win, 0, 3);
            break;
         case WDG_ALIGN_CENTER:
            wmove(ww->win, 0, (c - strlen(wo->title)) / 2);
            break;
         case WDG_ALIGN_RIGHT:
            wmove(ww->win, 0, c - strlen(wo->title) - 3);
            break;
      }
      wprintw(ww->win, wo->title);
   }
   
   /* restore the attribute */
   if (wo->flags & WDG_OBJ_FOCUSED) {
      wattroff(ww->win, A_BOLD);
      wbkgdset(ww->win, COLOR_PAIR(wo->focus_color));
   } else
      wbkgdset(ww->win, COLOR_PAIR(wo->border_color));
}
Пример #29
0
/*
 * Print current position
 */
static void print_position(WINDOW * win)
{
	int percent;

	wattrset(win, dlg.position_indicator.atr);
	wbkgdset(win, dlg.position_indicator.atr & A_COLOR);
	percent = (page - buf) * 100 / strlen(buf);
	wmove(win, getmaxy(win) - 3, getmaxx(win) - 9);
	wprintw(win, "(%3d%%)", percent);
}
Пример #30
0
void setup_show_win(void)
{
	wbkgdset (show_win,A_REVERSE);werase (show_win);
	show_pad_info.line=0;
	show_pad_info.col=0;
	show_pad_info.display_lines=LINES-TITLE_WIN_LINES-SHOW_WIN_LINES-COMMAND_WIN_LINES-2;
	show_pad_info.display_cols=COLS;
	show_pad_info.max_line=show_pad_info.display_lines-1;show_pad_info.max_col=show_pad_info.display_cols-1;
	show_pad_info.disable_output=0;
}