Example #1
0
void window_modify_border(WINDOW *window,gint attrs,gshort colors)
{
	chtype	char_attr;
	gint	width,height;
	gint	x,y;
	
	if(window==NULL) return;
	
	getmaxyx(window,height,width);
	
	for(y=0;y<height+1;y++)
	{
		for(x=0;x<width+1;x++)
		{
			if((x%(width-1)==0) || (y%(height-1)==0))
			{
				char_attr=mvwinch(window,y,x);
				if((char_attr & A_ALTCHARSET)==A_ALTCHARSET)
			 		mvwchgat(window,y,x,1,attrs | A_ALTCHARSET,colors,NULL);
				else mvwchgat(window,y,x,1,attrs,colors,NULL);
			}
		}
	}
	
	return;
}
Example #2
0
void overlay_lnum(Overlay *ov, int lnum, int max)
{
  snprintf(ov->lineno, SZ_LN, " %*d:%-*d ", 3, lnum+1, 3, max);
  int pos = ST_LN(ov->ov_size.col) - 2;
  draw_wide(ov->nc_st, 0, pos, ov->lineno, SZ_ARGS+1);
  mvwchgat (ov->nc_st, 0, pos,  -1, A_NORMAL, ov->col_lbl, NULL);
  mvwchgat (ov->nc_st, 0, pos+5, ov->filter, A_NORMAL, ov->col_fil, NULL);
  wnoutrefresh(ov->nc_st);
}
Example #3
0
static void overlay_draw_progress(Overlay *ov)
{
  int x = ov->ov_size.col;
  if (ov->progfin) {
    ov->progfin = false;
    mvwchgat(ov->nc_st, 0, ST_PRG(), SZ_PRG(x), A_REVERSE, ov->col_lbl, NULL);
  }
  else
    mvwchgat(ov->nc_st, 0, ST_PRG(), ov->prog, A_NORMAL, ov->col_prog, NULL);
}
Example #4
0
WINDOW* window_create_shadow(WINDOW *window,WINDOW *window_below)
{
	/* WINDOW  *window_below; */
   extern WINDOW  *SCREEN_WINDOW;
	WINDOW 	      *shadow_window;
	gint	         width,height;
	gint	         beg_x,beg_y;
	gint	         x,y;
#ifdef _VIPER_WIDE
	cchar_t	      wcval;
	wchar_t	      wch;
	attr_t	      attrs;
	short	         color_pair;
#else
	chtype	      char_attr;
#endif

	if(window==NULL) return window;

	getmaxyx(window,height,width);
	getbegyx(window,beg_y,beg_x);

	if(window_below==NULL) window_below=SCREEN_WINDOW;
	shadow_window=newwin(height,width,beg_y+1,beg_x+1);

	for(y=0;y<height;y++)
	{
		for(x=0;x<width;x++)
		{
#ifdef _VIPER_WIDE
			mvwin_wch(window_below,beg_y+y+1,beg_x+x+1,&wcval);
			getcchar(&wcval,&wch,&attrs,&color_pair,NULL);
			setcchar(&wcval,&wch,attrs,
					viper_color_pair(COLOR_WHITE,COLOR_BLACK),NULL);
			mvwadd_wch(shadow_window,y,x,&wcval);
#else
			char_attr=mvwinch(window_below,beg_y+y+1,beg_x+x+1);
			mvwaddch(shadow_window,y,x,char_attr & A_CHARTEXT);
			if((char_attr & A_ALTCHARSET)==A_ALTCHARSET)
			 	mvwchgat(shadow_window,y,x,1,A_NORMAL | A_ALTCHARSET,
					viper_color_pair(COLOR_WHITE,COLOR_BLACK),NULL);
			else mvwchgat(shadow_window,y,x,1,A_NORMAL,
				viper_color_pair(COLOR_WHITE,COLOR_BLACK),NULL);
#endif
		}
	}

	return shadow_window;
}
Example #5
0
gint viper_form_driver(FORM *form,gint request,guint32 flags,
   chtype active,chtype normal,gshort cursor_color)
{
   WINDOW   *window;
   chtype   eraser;
   chtype   temp_ch;
   gint     x,y;
   gint     retval;
   gshort   fg,bg;

   if(form==NULL) return ERR;
   
   if(form_sub(form)!=form_win(form)) window=form_sub(form);
   else window=form_win(form);

   getyx(window,y,x);
   eraser=field_back(current_field(form));
   mvwchgat(window,y,x,1,(eraser & A_ATTRIBUTES),
      PAIR_NUMBER(eraser & A_COLOR),NULL);
   
   retval=form_driver(form,request);

   if(flags & FORM_COLORIZE) 
      viper_form_colorize(form,active,normal,active,normal);

   if(flags & FORM_CURSOR_NONE) return retval;

   temp_ch=termattrs();
   if((flags & FORM_CURSOR_ULINE) && !(temp_ch & A_UNDERLINE)) return ERR;
   
   getyx(window,y,x);
   temp_ch=field_fore(current_field(form));
   if(flags & FORM_CURSOR_ULINE)
      mvwchgat(window,y,x,1,(temp_ch & A_ATTRIBUTES) | A_UNDERLINE,
         PAIR_NUMBER(temp_ch & A_COLOR),NULL);
   else
   {
      pair_content(PAIR_NUMBER(temp_ch & A_COLOR),&fg,&bg);
      if(cursor_color!=-1)
      {
         bg=cursor_color;
         mvwchgat(window,y,x,1,A_NORMAL,viper_color_pair(fg,bg),NULL);
      }
      else mvwchgat(window,y,x,1,A_REVERSE,viper_color_pair(fg,bg),NULL);
   }
   
   return E_OK;
}
Example #6
0
static void
highlight_line(WINDOW *win, int line)
{
	wstandout(win);

	/*
	 * this is a tricky one
	 */
#if 0
/*#ifdef mvwchgat*/
	mvwchgat(win, line, 0, -1,  A_STANDOUT, 0, NULL);
#else
	/*
	 * buggy function: FIXME
	 */
	scrollok(win, FALSE);
	{
		int i;
		wmove(win, line, 0);
		for(i = 0; i < COLS; i++)
			waddch(win, ' ');
	/*wattrset(win, 0);*/
	}
	scrollok(win, TRUE);
#endif
}
Example #7
0
// 左右にカーソル移動できるメニューを表示
// 色塗り未対応
// 
void CWindows::setselect(int x, int y, int* posx, int* dposx, std::vector<std::string> list, std::vector<int> cpair)
{
	std::string	str;		// アイテムを全て連結した文字列
	int	num = list.size();	// アイテムの個数
	int 	pos_l = 0, pos_r = 0;	// カーソルが合っているメニュー文字列の左右端座標
	int	width;			// 表示領域の幅
	width = m_winw - x - 1;

	for (int i = 0; i < num; i++)
	{
		if (i != 0)	str += " ";
		if (i == *posx)	pos_l = CMyStr::length(str);	// 左端座標取得
		str += list[i];
		if (i == *posx)	pos_r = CMyStr::length(str);	// 右端座標取得
	}

	if (pos_l < *dposx)		*dposx = pos_l;		// 左にシフト
	if (pos_r > *dposx + width)	*dposx = pos_r - width;	// 右にシフト

	// 表示する
	mvwaddstrtoeol(x, y, str.substr(adjx(*dposx)));

	// 選択中アイテム反転
	mvwchgat(m_this, y, adjx(pos_l - *dposx + x), adjx(CMyStr::length(list[*posx])), WA_REVERSE, 0, NULL);

	wrefresh(m_this);
}
Example #8
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;
}
Example #9
0
File: list.c Project: hhirsch/abook
static void
highlight_line(WINDOW *win, int line)
{
	wattrset(win, COLOR_PAIR(CP_LIST_HIGHLIGHT));
	if(!opt_get_bool(BOOL_USE_COLORS)) {
		wstandout(win);
	}

	/*
	 * this is a tricky one
	 */
#if 0
/*#ifdef mvwchgat*/
	mvwchgat(win, line, 0, -1,  A_STANDOUT, 0, NULL);
#else
	/*
	 * buggy function: FIXME
	 */
	scrollok(win, FALSE);
	{
		int i;
		wmove(win, line, 0);
		for(i = 0; i < COLS; i++)
			waddch(win, ' ');
	/*wattrset(win, 0);*/
	}
	scrollok(win, TRUE);
#endif
}
Example #10
0
static void
draw_view_line_search_result(struct view *view, unsigned int lineno)
{
	size_t bufsize = view->width * 4;
	char *buf = malloc(bufsize);
	regmatch_t pmatch[1];
	regoff_t bufpos = 0;

	if (!buf || mvwinnstr(view->win, lineno, 0, buf, bufsize) == ERR) {
		free(buf);
		return;
	}

	while (bufpos < bufsize && !regexec(view->regex, buf + bufpos, ARRAY_SIZE(pmatch), pmatch, 0)) {
		regoff_t start = pmatch[0].rm_so;
		regoff_t end = pmatch[0].rm_eo;

		if (start == -1 || end <= 0 || end <= start)
			continue;

		mvwchgat(view->win, lineno,
			 utf8_width_of(buf, bufpos + start, -1),
			 utf8_width_of(buf + bufpos + start, end - start, -1),
			 get_view_attr(view, LINE_SEARCH_RESULT),
			 get_view_color(view, LINE_SEARCH_RESULT),
			 NULL);

		bufpos += end;
	}

	free(buf);
}
Example #11
0
void splash_draw(ui_t *ui)
{
  int line = DSFY_MAX((ui->height - LOGO_HEIGHT * 2) / 2, 0);

  int x = DSFY_MAX((ui->width - LOGO_WIDTH) / 2, 0);

  wattron(ui->win, A_BOLD | COLOR_PAIR(UI_STYLE_DIM));
  for (int i = 0; i < LOGO_HEIGHT; ++i) {
    mvwaddnwstr(ui->win, ++line, x, g_wlogo[i], ui->width - x);
  }
  wattroff(ui->win, A_BOLD | COLOR_PAIR(UI_STYLE_DIM));

  mvwprintw(ui->win, line, x + 34, "despotify.se");
  mvwchgat(ui->win, line, x + 34, 12, A_BOLD | A_REVERSE, UI_STYLE_DIM, NULL);

  line += 2;

  mvwprintw(ui->win, ++line, x, "Type ':connect' to login, then press '/' to search for hits.");
  mvwprintw(ui->win, ++line, x + 3, "Press F1 for a list of all commands and key bindings.");

  line += 2;
  x += 18;

  mvwprintw(ui->win, ++line, x, "Web: http://despotify.se/");
  mvwprintw(ui->win, ++line, x, "IRC: #despotify @ EFNet");
}
Example #12
0
void
vterm_wnd_update(vterm_t *vterm)
{
    int             i;
    int             x,y;
    int             cell_count;
    chtype          ch;
    unsigned int    attr;

    if(vterm == NULL) return;
    if(vterm->window == NULL) return;

    cell_count = vterm->rows * vterm->cols;

    for(i = 0;i < cell_count;i++)
    {
        x = i % vterm->cols;
        y = (int)(i / vterm->cols);

        ch = vterm->cells[y][x].ch;
        attr = vterm->cells[y][x].attr;

        wattrset(vterm->window,attr);
        wmove(vterm->window,y,x);
        waddch(vterm->window,ch);
    }

    if(!(vterm->state & STATE_CURSOR_INVIS))
    {
        mvwchgat(vterm->window,vterm->crow,vterm->ccol,1,A_REVERSE,
            vterm->colors,NULL);
    }

    return;
}
Example #13
0
static void crsr_on(struct wdgt *w, int line)
{
	DBG("ENABLING in %s on line %d", w->name, line);	
	mvwinchnstr(CWND(w), line, 0, curs_buf, w->xsize+1);
	mvwchgat(CWND(w), line, 0, w->xsize+1, A_REVERSE, 0, 0);	
	wattrset(CWND(w), A_NORMAL);
}
Example #14
0
static void
draw_view_line_search_result(struct view *view, unsigned int lineno)
{
	size_t bufsize = view->width * 4;
	char *buf = malloc(bufsize);
	regmatch_t pmatch[1];
	int i;

	if (!buf || mvwinnstr(view->win, lineno, 0, buf, bufsize) == ERR ||
	    regexec(view->regex, buf, ARRAY_SIZE(pmatch), pmatch, 0)) {
		free(buf);
		return;
	}

	for (i = 0; i < ARRAY_SIZE(pmatch); i++) {
		regoff_t start = pmatch[i].rm_so;

		if (start == -1)
			continue;

		mvwchgat(view->win, lineno,
			 utf8_width_of(buf, start, -1),
			 utf8_width_of(buf + start, pmatch[i].rm_eo - start, -1),
			 get_view_attr(view, LINE_SEARCH_RESULT),
			 get_view_color(view, LINE_SEARCH_RESULT),
			 NULL);
	}

	free(buf);
}
Example #15
0
static void
test_wchgat(WINDOW *win)
{
    STATUS st;

    init_status(win, &st);

    do {
	switch (st.ch) {
	case '.':		/* change from current position */
	    wchgat(win, st.count, st.attr, st.pair, (void *) 0);
	    touch_if_needed(win, st.y_val);
	    break;
	case ',':		/* change from beginning of window */
	    mvwchgat(win, 0, 0, st.count, st.attr, st.pair, (void *) 0);
	    touch_if_needed(win, 0);
	    wmove(win, st.y_val, st.x_val);
	    break;
	case 'w':
	    do_subwindow(win, &st, test_wchgat);
	    break;
	case 'q':
	    return;
	default:
	    update_status(win, &st);
	    break;
	}
    } while ((st.ch = wgetch(win)) != ERR);
}
Example #16
0
void mim_extra_display(struct tlmframestruct *tlmframe, struct satstruct *sat, struct winstruct *screen)
{

   int j;
   for (j=0; j<=4; j++)
   {
      switch(tlmframe[0].valtype[j])
      {
         case TLM_VAL_TYPE_VOLT:
            mvwprintw(screen->tlm_win[0],tlmframe[0].loc[0][j],tlmframe[0].loc[1][j]+15,"V S");
            break;
         case TLM_VAL_TYPE_CURR:
            mvwprintw(screen->tlm_win[0],tlmframe[0].loc[0][j],tlmframe[0].loc[1][j]+14,"mA S");
            break;
         case TLM_VAL_TYPE_TEMP:
            mvwprintw(screen->tlm_win[0],tlmframe[0].loc[0][j],tlmframe[0].loc[1][j]+15,"C S");
            mvwaddch(screen->tlm_win[0],tlmframe[0].loc[0][j],tlmframe[0].loc[1][j]+14,ACS_DEGREE);
            break;
         case TLM_VAL_TYPE_TEMP_SHORTLBL:
            mvwprintw(screen->tlm_win[0],tlmframe[0].loc[0][j],tlmframe[0].loc[1][j]+15,"C S");
            mvwaddch(screen->tlm_win[0],tlmframe[0].loc[0][j],tlmframe[0].loc[1][j]+14,ACS_DEGREE);
            mvwaddch(screen->tlm_win[0],tlmframe[0].loc[0][j],tlmframe[0].loc[1][j]+6,ACS_DEGREE);
            break;
         case TLM_VAL_TYPE_WATT:
            mvwprintw(screen->tlm_win[0],tlmframe[0].loc[0][j],tlmframe[0].loc[1][j]+15,"W S");
            break;
      }
      mvwchgat(screen->tlm_win[0],tlmframe[0].loc[0][j],tlmframe[0].loc[1][j]+17,1,A_NORMAL,TLM_COLOUR_INVIS,NULL);
   }
}
Example #17
0
/*
 * cl_deleteln --
 *	Delete the current line, scrolling all lines below it.
 *
 * PUBLIC: int cl_deleteln __P((SCR *));
 */
int
cl_deleteln(SCR *sp)
{
	CHAR_T ch;
	CL_PRIVATE *clp;
	WINDOW *win;
	size_t col, lno, spcnt, y, x;

	clp = CLP(sp);
	win = CLSP(sp) ? CLSP(sp) : stdscr;

	/*
	 * This clause is required because the curses screen uses reverse
	 * video to delimit split screens.  If the screen does not do this,
	 * this code won't be necessary.
	 *
	 * If the bottom line was in reverse video, rewrite it in normal
	 * video before it's scrolled.
	 *
	 * Check for the existence of a chgat function; XSI requires it, but
	 * historic implementations of System V curses don't.   If it's not
	 * a #define, we'll fall back to doing it by hand, which is slow but
	 * acceptable.
	 *
	 * By hand means walking through the line, retrieving and rewriting
	 * each character.  Curses has no EOL marker, so track strings of
	 * spaces, and copy the trailing spaces only if there's a non-space
	 * character following.
	 */
	if (!F_ISSET(sp, SC_SCR_EXWROTE) && IS_SPLIT(sp)) {
		getyx(win, y, x);
#ifdef mvchgat
		mvwchgat(win, RLNO(sp, LASTLINE(sp)), 0, -1, A_NORMAL, 0, NULL);
#else
		for (lno = RLNO(sp, LASTLINE(sp)), col = spcnt = 0;;) {
			(void)wmove(win, lno, col);
			ch = winch(win);
			if (isblank(ch))
				++spcnt;
			else {
				(void)wmove(win, lno, col - spcnt);
				for (; spcnt > 0; --spcnt)
					(void)waddch(win, ' ');
				(void)waddch(win, ch);
			}
			if (++col >= sp->cols)
				break;
		}
#endif
		(void)wmove(win, y, x);
	}

	/*
	 * The bottom line is expected to be blank after this operation,
	 * and other screens must support that semantic.
	 */
	return (wdeleteln(win) == ERR);
}
Example #18
0
void value_list_set_selected(struct value_list *vl, bool reverse)
{
	attr_t attr = A_NORMAL;

	if (reverse) {
		attr = A_REVERSE;
	}
	mvwchgat(vl->window, 0, HEADING_X, 5, attr, 0, NULL);
}
Example #19
0
static void
move_selection(int n)
{
	mvwchgat(blockpad, selected_rel, 0, 40, A_NORMAL, 0, NULL);

	selected_rel += n;
	if (selected_rel >= nrels)
		selected_rel = nrels - 1;
	if (selected_rel < 0)
		selected_rel = 0;

	if (selected_rel < blockpad_pos)
		scroll_blockpad(selected_rel - blockpad_pos);
	else if (selected_rel - blockpad_pos > blockpad_lines)
		scroll_blockpad(selected_rel - blockpad_pos - blockpad_lines);

	mvwchgat(blockpad, selected_rel, 0, 40, A_REVERSE, 0, NULL);
}
Example #20
0
void curses_clear_unhighlight_message_window()
{
    int mh, mw, count;
    boolean border = curses_window_has_border(MESSAGE_WIN);
    WINDOW *win = curses_get_nhwin(MESSAGE_WIN);

    turn_lines = 1;
    
    curses_get_window_size(MESSAGE_WIN, &mh, &mw); 
    
    mx = 0;
    
    if (border)
    {
        mx++;
    }
       
    if (mh == 1)
    {
        curses_clear_nhwin(MESSAGE_WIN);
    }
    else
    {
        mx += mw;    /* Force new line on new turn */
        
        if (border)
        {

            for (count = 0; count < mh; count++)
            {
                mvwchgat(win, count+1, 1, mw, COLOR_PAIR(8), A_NORMAL, NULL);
            }
        }
        else
        {
            for (count = 0; count < mh; count++)
            {
                mvwchgat(win, count, 0, mw, COLOR_PAIR(8), A_NORMAL, NULL);
            }
        }

        wrefresh(win);
    }
}
void Screen::update_sloneczko_stan(const char* stan, int kolor)
{
    std::lock_guard<std::mutex> straznik_teksasu(screen_lock_);
    wmove(watki_,2,0);
    wclrtoeol(watki_);
    mvwprintw(watki_, 2, 0, "   Sloneczko");
    mvwprintw(watki_, 2, 23, ": %s", stan);
    mvwchgat(watki_, 2, 0, 2, A_BLINK | A_COLOR, kolor, NULL);
    wrefresh(watki_);
}
void Screen::update_stan_zlodziej(int id,const char* status, int kolor, 
                                  const char * imie) {
    std::lock_guard<std::mutex> straznik_teksasu (screen_lock_);
        wmove(watki_, 14,0);
        wclrtoeol(watki_);
        mvwprintw(watki_, 14,0, "   Zlodziej %s",imie);
        mvwprintw(watki_, 14, 23, ": %s", status);
        mvwchgat(watki_, 14, 0, 2, A_BLINK | A_COLOR, kolor, NULL);
        wrefresh(watki_);
}
Example #23
0
void draw_column(WINDOW *win, int x, int height, char overflow, char limitter)
{
	void *dummy = NULL;
	int y = 0, end_y = 0, win_h = 0, win_w = 0;

	getmaxyx(win, win_h, win_w);
	(void)win_w; /* silence warnings */

	end_y = max(0, win_h - height);

	for(y=win_h - 1; y >= end_y; y--)
		mvwchgat(win, y, x, 1, A_REVERSE, C_YELLOW, dummy);

	if (limitter)
		mvwchgat(win, 0, x, 1, A_REVERSE, C_BLUE, dummy);
	else if (overflow)
		mvwchgat(win, 0, x, 1, A_REVERSE, C_RED, dummy);
	else if (height == 0)
		mvwchgat(win, win_h - 1, x, 1, A_REVERSE, C_GREEN, dummy);
}
Example #24
0
void overlay_draw(void **argv)
{
  log_msg("OVERLAY", "draw");
  Overlay *ov = argv[0];
  if (!ov)
    return;
  if (overlay_expire(ov))
    return;
  ov->queued = false;

  int x = ov->ov_size.col;
  int y = ov->ov_size.lnum;

  draw_wide(ov->nc_st, 0, 0, ov->bufno, SZ_BUF+1);
  mvwchgat (ov->nc_st, 0, 0, SZ_BUF+1, A_NORMAL, ov->col_bufno, NULL);

  draw_wide(ov->nc_st, 0, SZ_BUF-1, ov->name, SZ_LBL+1);
  mvwchgat (ov->nc_st, 0, SZ_BUF-1, SZ_LBL+1, A_NORMAL, ov->col_lbl, NULL);

  mvwhline(ov->nc_st, 0, SZ_LBL-1, ' ', x);
  mvwchgat(ov->nc_st, 0, SZ_LBL-1, -1, A_NORMAL, ov->col_ln, NULL);

  if (ov->separator) {
    wattron(ov->nc_sep, COLOR_PAIR(ov->col_sep));
    int i;
    for (i = 0; i < y; i++)
      mvwaddstr(ov->nc_sep, i, 0, sep_char);
    wattroff(ov->nc_sep, COLOR_PAIR(ov->col_sep));
    DRAW_CH(ov, nc_sep, i, 0, ' ', col_ln);
  }

  //TODO: if arg exceeds SZ_USR() then compress /*/*/ to fit
  int pos = ST_LN(x) - 2;
  draw_wide(ov->nc_st, 0, ST_ARG(), ov->arg, SZ_USR(x));
  mvwchgat (ov->nc_st, 0, ST_ARG(), pos, A_NORMAL, ov->col_text, NULL);

  draw_wide(ov->nc_st, 0, pos, ov->lineno, SZ_ARGS+1);
  mvwchgat (ov->nc_st, 0, pos,  -1, A_NORMAL, ov->col_lbl, NULL);
  mvwchgat (ov->nc_st, 0, pos+5, ov->filter, A_NORMAL, ov->col_fil, NULL);

  if (ov->progfin) {
    ov->progfin = false;
    mvwchgat (ov->nc_st, 0, ST_PRG(), SZ_PRG(x), A_REVERSE, ov->col_lbl, NULL);
  }
  else
    mvwchgat (ov->nc_st, 0, ST_PRG(), ov->prog, A_NORMAL, ov->col_prog, NULL);

  wnoutrefresh(ov->nc_st);
  if (ov->separator)
    wnoutrefresh(ov->nc_sep);
}
Example #25
0
void draw_UI(void){
	int i;

	wclear(ui.plane_list);	
	wclear(ui.cmds);
	wclear(ui.map);
	wclear(ui.score);
	
	for (i = 0; i < state.airports_num; i++){
		mvwprintw(ui.map, (state.airports[i].y/(float)MAX_HEIGHT)*(MAP_HEIGHT), (state.airports[i].x/(float)MAX_LEN)*(MAP_WIDTH), "@");
	}

	for (i = 0; i < state.planes_num; i++){
		mvwprintw(ui.map, (state.planes[i].y/(float)MAX_HEIGHT)*(MAP_HEIGHT), (state.planes[i].x/(float)MAX_LEN)*(MAP_WIDTH), "%d", i);
		if (i >= ui.cur_page*PLANES_PER_PAGE && i < PLANES_PER_PAGE*(ui.cur_page+1)){
			mvwprintw(ui.plane_list, (i%PLANES_PER_PAGE)*2, 0, "%d: %s (%d, %d, %d)", i, state.planes[i].id, state.planes[i].x, state.planes[i].y, state.planes[i].z);
			mvwchgat(ui.plane_list, (i%PLANES_PER_PAGE)*2, 0, -1, A_BOLD, 0, NULL);
			if (ui.cur_plane >= 0 && i == ui.cur_page*PLANES_PER_PAGE+ui.cur_plane){
				mvwchgat(ui.plane_list, (i%PLANES_PER_PAGE)*2, 0, -1, A_REVERSE, 0, NULL);
			}
			mvwprintw(ui.plane_list, (i%PLANES_PER_PAGE)*2+1, 0, "%s E:%d S:%d H:%d", get_status(state.planes[i].status), state.planes[i].elevation, (state.planes[i].speed/14)*50, state.planes[i].heading);
		}		
	}

	for (i = 0; i < CMDS_NUM; i++){
		mvwprintw(ui.cmds, i, 0, "%d: %s", i, get_cmdname(i));
		if (ui.cur_cmd != -1){
			mvwchgat(ui.cmds, ui.cur_cmd, 0, -1, A_REVERSE, 0, NULL);
		}
	}

	mvwprintw(ui.score, 0, 0, "Landed:%d Crashed:%d", state.landed_planes, state.crashed_planes);

	wrefresh(ui.map);
	wrefresh(ui.cmds);
	wrefresh(ui.plane_list);	
	wrefresh(ui.score);
}
Example #26
0
void draw_rad_column(WINDOW *win, int x, double val)
{
	void *dummy = NULL;
	int y = 0, end_y = 0, win_h = 0, win_w = 0;
	int center_y = 0;

	getmaxyx(win, win_h, win_w);
	(void)win_w; /* silence warnings */

	center_y = win_h / 2;
	end_y = (int)((double)(win_h / 2) * ((val / PI) + 1.0));

	if (end_y > center_y)
	{
		for(y=center_y; y<end_y; y++)
			mvwchgat(win, y, x, 1, A_REVERSE, C_YELLOW, dummy);
	}
	else
	{
		for(y=end_y; y<center_y; y++)
			mvwchgat(win, y, x, 1, A_REVERSE, C_YELLOW, dummy);
	}
}
Example #27
0
void updatelog(Logger* lg){
	WINDOW* w = lg->win;
	int i=0;
	for(i=0; i<lg->height; i++){
		if(lg->wsk-lg->height+i >=0){
			LogMove* lm = &(lg->data[lg->wsk-lg->height+i]);
			lm->pid--;
			
			char* wyn;
			switch(lm->res){
				case MISS:
					wyn = "Pudlo";
					break;
				case SHOT:
					wyn = "Trafiony";
					break;
				case DESTROYED:
				case WIN:
					wyn = "Zatopiony";
					break;
			}
			
			mvwprintw(w,i,0," %s %3.d %3.d %s",lm->pid ? "P2" : "P1",lm->l, lm->c, wyn);
			switch(lm->pid){
				case 0:
					mvwchgat(w,i, 0, -1, A_STANDOUT, 1, NULL);
					break;
				case 1:
					mvwchgat(w,i, 0, -1, A_NORMAL, 1, NULL);
					break;
			}
			lm->pid++;
		}
	}
	wrefresh(w);
}
Example #28
0
static void ex_draw()
{
  log_msg("EXCMD", "ex_draw");
  werase(ex.nc_win);

  if (ex.ex_state == EX_CMD_STATE)
    menu_draw(ex.menu);

  pos_T max = layout_size();
  wchar_t *wline = str2wide(ex.line);
  int len = 2 + wcswidth(wline, -1);
  int offset = MAX(len - (max.col - 1), 0);

  mvwaddch(ex.nc_win, 0, 0, ex.state_symbol);
  mvwaddwstr(ex.nc_win, 0, 1, &wline[offset]);
  mvwchgat(ex.nc_win, 0, 0, 1, A_NORMAL, ex.col_symb, NULL);
  mvwchgat(ex.nc_win, 0, 1, -1, A_NORMAL, ex.col_text, NULL);

  doupdate();
  curs_set(1);
  wmove(ex.nc_win, 0, (ex.curpos + 1) - offset);
  wnoutrefresh(ex.nc_win);
  free(wline);
}
Example #29
0
File: ndwin.c Project: Orc/ndialog
/*
 * drawGauge() draws a progress bar
 */
void
drawGauge(void *o, void* w)
{
    Obj *obj = OBJ(o);
    int percent;
    int fillwidth;
    int rc;
    WINDOW *win = Window(w);
    int x = WX(w),
	y = WY(w);
    char bfr[5];

    if (obj == 0 || obj->Class != O_GAUGE)
	return;

    percent = obj->content ? *((int*)(obj->content)) : 0;

    fillwidth = (obj->width * percent) / 100;

    rc = _nd_drawObjCommon(o, w);
    _nd_adjustXY(rc, o, &x, &y);
    
    /* clear the gauge area */
    wmove(win, y, x);
    setcolor(win, WINDOW_COLOR);
    waddnstr(win, rillyrillylongblankstring, obj->width);

    if (obj->width > 4) {
	/* draw the percentage in the middle of the progress bar,
	 * appropriately shaded */
	sprintf(bfr, "%d%%", percent);

	wmove(win, y, x + ((obj->width-strlen(bfr))/2) );
	waddstr(win, bfr);
    }

#if WITH_NCURSES
    /* highlight the progress bar as appropriate */
    mvwchgat(win, y, x, fillwidth, A_REVERSE, PAIR_NUMBER(WINDOW_COLOR), 0);
#else
    wstandout(win);
    for (rc = 0; rc < fillwidth; rc++)
	mvwaddch(win, y, x+rc, mvwinch(win, y, x+rc));
    wstandend(win);
#endif

} /* drawGauge */
Screen::Screen() :
    okno_glowne_x_(0),
    okno_glowne_y_(0) {
    
    initscr();
    start_color();
    curs_set(FALSE);
    init_pair(1, COLOR_WHITE, COLOR_YELLOW);
    init_pair(2, COLOR_WHITE, COLOR_RED);
    init_pair(3, COLOR_WHITE, COLOR_GREEN);
    
    getmaxyx(stdscr, okno_glowne_y_, okno_glowne_x_);
    int punkt_podzialu = okno_glowne_x_ / 2;
    
    watki_ = newwin(okno_glowne_y_, okno_glowne_x_ - punkt_podzialu,0,0);
    zasoby_ = newwin(okno_glowne_y_, punkt_podzialu, 0, okno_glowne_x_ - punkt_podzialu);
    getmaxyx(zasoby_, zasoby_max_y_, zasoby_max_x_);
    mvwprintw(watki_, 0, 0, "Watki:");
    mvwprintw(zasoby_,0, 0, "Zasoby:");
    mvwprintw(zasoby_, 2, 0, "Ostatni urodzaj:");
    mvwprintw(zasoby_, 3, 0, "Stan Pola:");
    mvwprintw(zasoby_, 5, 0, "Stan Ziemniaczarni:");
    mvwprintw(zasoby_, 7, 0, "Stan Magazyn Glowny:");
    mvwprintw(zasoby_, 8, 0, "Stan Magazyn Awarjyny:");
    mvwprintw(zasoby_, 10, 0, "Stan Sklep:");
    mvwprintw(watki_, 2, 0, "   Sloneczko           : Czekam");
    mvwprintw(watki_, 3, 0, "   Rolnik Adam         : Czekam");
    mvwprintw(watki_, 4, 0, "   Rolnik Zbigniew     : Czekam");
    mvwprintw(watki_, 5, 0, "   Rolnik Stanislaw    : Czekam");
    mvwprintw(watki_, 6, 0, "   Kurier Roman        : Czekam");
    mvwprintw(watki_, 7, 0, "   Kurier Marek        : Czekam");
    mvwprintw(watki_, 8, 0, "   Hurtownik Marian    : Czekam");
    mvwprintw(watki_, 9, 0, "   Hurtownik Wladyslaw : Czekam");
    mvwprintw(watki_, 10, 0, "   Kupujacy Mariola    : Czekam");
    mvwprintw(watki_, 11, 0, "   Kupujacy Anna       : Czekam");
    mvwprintw(watki_, 12, 0, "   Kupujacy Piotr      : Czekam");
    mvwprintw(watki_, 13, 0, "   Kupujacy Pawel      : Czekam");
    mvwprintw(watki_, 14, 0, "   Zlodziej Walter     : Czekam");
    
    for (int i=2; i < 15; ++i) {
        mvwchgat(watki_, i, 0, 2, A_BLINK | A_COLOR, 2, NULL);
    }
    wrefresh(watki_);
    wrefresh(zasoby_);
    sleep(2);
}