예제 #1
0
void ncursesWindow::setborder(char ls, char rs, char ts, char bs, char tl, char tr, char bl, char br){

    m_border->m_ls = ls;
    m_border->m_rs = rs;
    m_border->m_ts = ts;
    m_border->m_bs = bs;
    m_border->m_tl = tl;
    m_border->m_tr = tr;
    m_border->m_bl = bl;
    m_border->m_br = br;
    
    wborder(m_window, ls, rs, ts, bs, tl, tr, bl, br);

}
예제 #2
0
void popup(const char *mes, ...)
{
 va_list ap;
 va_start(ap, mes);
 char buff[8192];
 vsprintf(buff, mes, ap);
 va_end(ap);
 std::string tmp = buff;
 int width = 0;
 int height = 2;
 size_t pos = tmp.find_first_of('\n');
 while (pos != std::string::npos) {
  height++;
  if (pos > width)
   width = pos;
  tmp = tmp.substr(pos + 1);
  pos = tmp.find_first_of('\n');
 }
 if (width == 0 || tmp.length() > width)
  width = tmp.length();
 width += 2;
 if (height > 25)
  height = 25;
 WINDOW* w = newwin(height + 1, width, int((25 - height) / 2),
                    int((80 - width) / 2));
 wborder(w, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
            LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );
 tmp = buff;
 pos = tmp.find_first_of('\n');
 int line_num = 0;
 while (pos != std::string::npos) {
  std::string line = tmp.substr(0, pos);
  line_num++;
  mvwprintz(w, line_num, 1, c_white, line.c_str());
  tmp = tmp.substr(pos + 1);
  pos = tmp.find_first_of('\n');
 }
 line_num++;
 mvwprintz(w, line_num, 1, c_white, tmp.c_str());

 wrefresh(w);
 char ch;
 do
  ch = getch();
 while(ch != ' ' && ch != '\n' && ch != KEY_ESCAPE);
 werase(w);
 wrefresh(w);
 delwin(w);
 refresh();
}
예제 #3
0
int wgotonum(int xpos, WINDOW *win) {
    int orig = xpos;

    /* wborder(win, 0, 0, 0, 0, 0, 0, 0, 0); */
    wborder(win, '|', '|', '-', '-', '+', '+', '+', '+');

    mvwprintw(win, 1, 2, "Goto base:                       ", xpos);
    mvwprintw(win, 1, 13, "%-d", xpos);

    for (;;) {
        int c;
        wrefresh(win);

        switch (c = wgetch(win)) {
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
            xpos = xpos * 10 + c - '0';
            break;

        case KEY_BACKSPACE:
        case '\010':
        case '\177':
            xpos /= 10;
            break;

        case '\027': /* control w */
            xpos = 0;
            break;

        case '\033': /* escape */
            return orig;

        case KEY_ENTER:
        case '\012':
        case '\015':
            return xpos;
        }

        mvwprintw(win, 1, 13, "            ");
        mvwprintw(win, 1, 13, "%-d", xpos);
    }
}
예제 #4
0
std::string string_input_popup(std::string title, int max_length, std::string input)
{
 std::string ret = input;

 int startx = title.size() + 2;
 WINDOW *w = newwin(3, FULL_SCREEN_WIDTH, (TERMY-3)/2,
                    ((TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 0));
 wborder(w, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
            LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );
 for (int i = startx + 1; i < 79; i++)
  mvwputch(w, 1, i, c_ltgray, '_');

 mvwprintz(w, 1, 1, c_ltred, "%s", title.c_str());

 if (input != "")
  mvwprintz(w, 1, startx, c_magenta, "%s", input.c_str());

 int posx = startx + input.size();
 mvwputch(w, 1, posx, h_ltgray, '_');
 do {
  wrefresh(w);
  long ch = getch();
  if (ch == 27) {	// Escape
   werase(w);
   wrefresh(w);
   delwin(w);
   refresh();
   return "";
  } else if (ch == '\n') {
   werase(w);
   wrefresh(w);
   delwin(w);
   refresh();
   return ret;
  } else if (ch == KEY_BACKSPACE || ch == 127) {
// Move the cursor back and re-draw it
   if( posx > startx ) { // but silently drop input if we're at 0, instead of adding '^'
       ret = ret.substr(0, ret.size() - 1);
       mvwputch(w, 1, posx, c_ltgray, '_');
       posx--;
       mvwputch(w, 1, posx, h_ltgray, '_');
   }
  } else if(ret.size() < max_length || max_length == 0) {
   ret += ch;
   mvwputch(w, 1, posx, c_magenta, ch);
   posx++;
   mvwputch(w, 1, posx, h_ltgray, '_');
  }
 } while (true);
}
예제 #5
0
파일: curses.c 프로젝트: cosmo-ray/yirl
void resize(YWidgetState *wid, int renderType)
{
  CWidget *state = wid->renderStates[renderType].opac;
  Entity *pos = yeGet(wid->entity, "wid-pos");

  state->h = yeGetInt(yeGet(pos, "h")) * LINES / 1000;
  state->w = yeGetInt(yeGet(pos, "w")) * COLS / 1000;
  state->x = yeGetInt(yeGet(pos, "x")) * COLS / 1000;
  state->y = yeGetInt(yeGet(pos, "y")) * LINES / 1000;

  wresize(state->win, state->h, state->w);
  mvwin(state->win, state->y, state->x);
  wborder(state->win, '|', '|', '-','-','+','+','+','+');
  refresh();
}
예제 #6
0
void InterfaceCLI::drawStatusWin()
{
    wclear(_statusWin);
    wborder(_statusWin, 
        ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, 
        ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER);
    wattrset(_statusWin, A_BOLD | A_UNDERLINE);
    mvwprintw(_statusWin, 1, 1, "Status");
    wattrset(_statusWin, A_NORMAL);
    mvwprintw(_statusWin, 3, 1, "Delta (parameter)       %0.4f", _paramsDelta);
    for (size_t i=0;i<_userStatus.size();i++) {
        mvwprintw(_statusWin, 4+i, 1, "%s", _userStatus[i]->c_str());
    }
    wrefresh(_statusWin);
}
예제 #7
0
//Updates the window size:
void updateWindows()
{
    //Clears the windows:
    wclear(fileview.window);
    wclear(fileinfo.window);
    wclear(extrainfo.window);

    //Gets the screen size:
    getmaxyx(stdscr, screenY, screenX);

    //Initialises the windows:
    fileview.x = 0;
    fileview.y = 1;
    fileview.width = screenX * 0.75;
    fileview.height = screenY - 2;

    fileinfo.x = fileview.width + 1;
    fileinfo.y = 1;
    fileinfo.width = (screenX - fileview.width) - 1;
    fileinfo.height = ((screenY - 2) * 0.75) - 1;

    extrainfo.x = fileinfo.x;
    extrainfo.y = fileinfo.y + fileinfo.height;
    extrainfo.width = fileinfo.width;
    extrainfo.height = (screenY - fileinfo.height) - 2;

    //Creates new window objects with the new values:
    fileview.window = newwin(fileview.height, fileview.width, fileview.y, fileview.x);
    fileinfo.window = newwin(fileinfo.height, fileinfo.width, fileinfo.y, fileinfo.x);
    extrainfo.window = newwin(extrainfo.height, extrainfo.width, extrainfo.y, extrainfo.x);

    //Creates a border around each of the windows:
    wborder(fileview.window, '|', '|', '-', '-', '+', '+', '+', '+');
    wborder(fileinfo.window, '|', '|', '-', '-', '+', '+', '+', '+');
    wborder(extrainfo.window, '|', '|', '-', '-', '+', '+', '+', '+');
}
예제 #8
0
static int SCW_Border( lua_State *L ){
	WINDOW **w = checkSelCWindow(L);
	chtype ls, rs, ts, bs, tl, tr, bl, br;
	ls = rs = ts = bs = tl = tr = bl = br = 0;

/* TODO :Here argument reading from an associtiative table */

	if(wborder( *w, ls, rs, ts, bs, tl, tr, bl, br ) == ERR){
		lua_pushnil(L);
		lua_pushstring(L, "wborder() returned an error");
		return 2;
	}

	return 0;
}
예제 #9
0
void computer::print_error(const char *mes, ...)
{
// Translate the printf flags
 va_list ap;
 va_start(ap, mes);
 char buff[6000];
 vsprintf(buff, mes, ap);
 va_end(ap);
// Print the line.
 wprintz(w_terminal, c_red, " %s%s", buff, "\n");
// Reprint the border, in case we pushed a line over it
 wborder(w_terminal, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
                     LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );
 wrefresh(w_terminal);
}
예제 #10
0
파일: output.cpp 프로젝트: 8Z/Cataclysm-DDA
std::string string_input_popup(std::string title, int width, std::string input, std::string desc, std::string identifier, int max_length ) {
  nc_color title_color = c_ltred;
  nc_color desc_color = c_green;

  std::vector<std::string> descformatted;

  int titlesize = utf8_width(title.c_str());
  int startx = titlesize + 2;
  if ( max_length == 0 ) max_length = width;
  int w_height=3;
  int iPopupWidth = (width == 0) ? FULL_SCREEN_WIDTH : width + titlesize + 4;
  if (iPopupWidth > FULL_SCREEN_WIDTH) {
    iPopupWidth = FULL_SCREEN_WIDTH;
  }
  if ( desc.size() > 0 ) {
    int twidth = utf8_width(desc.c_str());
    if ( twidth > iPopupWidth-4 ) {
      twidth=iPopupWidth-4;
    }
    descformatted = foldstring(desc, twidth);
    w_height+=descformatted.size();
  }
  int starty=1+descformatted.size();

  if ( max_length == 0 ) max_length = 1024;
  int w_y=(TERMY-w_height)/2;
  int w_x=((TERMX > iPopupWidth) ? (TERMX-iPopupWidth)/2 : 0);
  WINDOW *w = newwin(w_height, iPopupWidth, w_y,
    ((TERMX > iPopupWidth) ? (TERMX-iPopupWidth)/2 : 0));

  wborder(w, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
             LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );

  int endx=iPopupWidth-3;

  for(int i=0; i < descformatted.size(); i++ ) {
    mvwprintz(w, 1+i, 1, desc_color, "%s", descformatted[i].c_str() );
  }
  mvwprintz(w, starty, 1, title_color, "%s", title.c_str() );
  long key=0;
  int pos = -1;
  std::string ret = string_input_win(w, input, max_length, startx, starty, endx, true, key, pos, identifier, w_x, w_y, true );
      werase(w);
      wrefresh(w);
      delwin(w);
      refresh();
  return ret;
}
예제 #11
0
void	prompt_credits(t_tetris *game)
{
  wborder(game->credits, '|', '|', '-', '-', '/', '\\', '\\', '/');
  wrefresh(game->credits);
  attron(COLOR_PAIR(7));
  if (game->score > game->highscore)
    game->highscore = game->score;
  mvprintw(9, 2, "High Score\t%d", game->highscore);
  mvprintw(10, 2, "Score\t        %d", game->score);
  mvprintw(12, 2, "Lines\t        %d", game->score_lines);
  mvprintw(13, 2, "Level\t        %d", game->level);
  mvprintw(15, 2, "Timer:   %d%d:%d%d", game->timer[0], game->timer[1],
	   game->timer[2], game->timer[3]);
  mvprintw(2 + game->board_lines, 0, "Uberti_l & Wadel_n ©Tetris 2016");
  attroff(COLOR_PAIR(7));
}
예제 #12
0
void		print_hs_title(void)
{
    wborder(stdscr, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE,
            ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER);
    mvwprintw(stdscr, 4, (COLS / 2) - 22,
              " :::===  :::===== :::====  :::====  :::=====");
    mvwprintw(stdscr, 5, (COLS / 2) - 22,
              " :::     :::      :::  === :::  === :::     ");
    mvwprintw(stdscr, 6, (COLS / 2) - 22,
              "  =====  ===      ===  === =======  ======  ");
    mvwprintw(stdscr, 7, (COLS / 2) - 22,
              "     === ===      ===  === === ===  ===     ");
    mvwprintw(stdscr, 8, (COLS / 2) - 22,
              " ======   =======  ======  ===  === ========");
    mvwprintw(stdscr, 13, (COLS / 2) - 8, "10 bests scores :");
}
예제 #13
0
void	tab_score(t_program *tetris)
{
  int	i;

  werase(tetris->tet.over.game);
  wborder(tetris->tet.over.game,
	  '|', '|', '-', '-', '/', '\\', '\\', '/');
  mvwprintw(tetris->tet.over.game, 0, 1, "HIGHSCORE");
  i = -1;
  while (++i < 10)
    {
      mvwprintw(tetris->tet.over.game, i + 1, 2, "%s",
		tetris->hscore[i].name);
      put_score(tetris, tetris->hscore[i].name, 2, i + 1);
    }
}
예제 #14
0
void drawplay (int lvl) { /* redraws the entire screen. */
  int backcol, nextcol, x, y;

  backcol = lvl % (COLORS / 2); nextcol = (lvl + 1) % (COLORS / 2);
  wattrset (pwin, COLOR_PAIR (backcol));
  wborder(pwin, 0, 0, ' ', 0, ACS_VLINE,  ACS_VLINE, 0, 0);
  for (y = 0; y < HEIGHT; y++) for (x = 1; x <= col_width; x++) {
    wattrset (pwin, COLOR_PAIR((buf[y][x]) ? buf[y][x] % (COLORS / 2) + (COLORS / 2) : lvl % (COLORS / 2)));
    mvwaddstr (pwin, y, x * 2 - 1, "  ");
  }
  wattrset (nwin, COLOR_PAIR (nextcol));
  box (nwin,0,0);
  wfillrect (nwin, 1, 1, 4, 8);
  mvwaddstr (nwin, 0, 3, "NEXT");
  wrefresh (pwin); wrefresh (nwin);
}
예제 #15
0
char popup_getkey(const char *mes, ...)
{
 va_list ap;
 va_start(ap, mes);
 char buff[8192];
 vsprintf(buff, mes, ap);
 va_end(ap);
 std::string tmp = buff;
 int width = 0;
 int height = 2;
 size_t pos = tmp.find_first_of('\n');
 while (pos != std::string::npos) {
  height++;
  if (pos > width)
   width = pos;
  tmp = tmp.substr(pos + 1);
  pos = tmp.find_first_of('\n');
 }
 if (width == 0 || tmp.length() > width)
  width = tmp.length();
 width += 2;
 if (height > FULL_SCREEN_HEIGHT)
  height = FULL_SCREEN_HEIGHT;
 WINDOW *w = newwin(height+1, width, (TERMY-(height+1))/2, (TERMX > width) ? (TERMX-width)/2 : 0);
 wborder(w, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
            LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );
 tmp = buff;
 pos = tmp.find_first_of('\n');
 int line_num = 0;
 while (pos != std::string::npos) {
  std::string line = tmp.substr(0, pos);
  line_num++;
  mvwprintz(w, line_num, 1, c_white, line.c_str());
  tmp = tmp.substr(pos + 1);
  pos = tmp.find_first_of('\n');
 }
 line_num++;
 mvwprintz(w, line_num, 1, c_white, tmp.c_str());

 wrefresh(w);
 char ch = getch();;
 werase(w);
 wrefresh(w);
 delwin(w);
 refresh();
 return ch;
}
예제 #16
0
std::string string_input_popup(int max_length, const char *mes, ...)
{
 std::string ret;
 va_list ap;
 va_start(ap, mes);
 char buff[1024];
 vsprintf(buff, mes, ap);
 va_end(ap);
 int startx = strlen(buff) + 2;
 WINDOW* w = newwin(3, 80, 11, 0);
 wborder(w, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
            LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );
 mvwprintz(w, 1, 1, c_ltred, "%s", buff);
 for (int i = startx + 1; i < 79; i++)
  mvwputch(w, 1, i, c_ltgray, '_');
 int posx = startx;
 mvwputch(w, 1, posx, h_ltgray, '_');
 do {
  wrefresh(w);
  long ch = getch();
  if (ch == 27) {	// Escape
   werase(w);
   wrefresh(w);
   delwin(w);
   refresh();
   return "";
  } else if (ch == '\n') {
   werase(w);
   wrefresh(w);
   delwin(w);
   refresh();
   return ret;
  } else if ((ch == KEY_BACKSPACE || ch == 127) && posx > startx) {
// Move the cursor back and re-draw it
   ret = ret.substr(0, ret.size() - 1);
   mvwputch(w, 1, posx, c_ltgray, '_');
   posx--;
   mvwputch(w, 1, posx, h_ltgray, '_');
  } else if(ret.size() < max_length || max_length == 0) {
   ret += ch;
   mvwputch(w, 1, posx, c_magenta, ch);
   posx++;
   mvwputch(w, 1, posx, h_ltgray, '_');
  }
 } while (true);
}
예제 #17
0
void drawMiddle(WINDOW *middle, unsigned char field[16][16]){
    unsigned int i, n;

    //Borders
    wborder(middle, ' ', ' ', ' ', '-', ' ', ' ', '-', '-');
    
    //The field stats completely unrevealed
    wcolor_set(middle, 11, NULL);

    for(i = 0; i < 16; i++){
        //Reset the cursor
        wmove(middle, i, ((COLS-42)/2)-8);
        for(n = 0; n < 16; n++){
            waddch(middle, '#');
        }
    }
}
예제 #18
0
int menu_vec(const char *mes, std::vector<std::string> options)
{
 if (options.size() == 0) {
  debugmsg("0-length menu (\"%s\")", mes);
  return -1;
 }
 std::string title = mes;
 int height = 3 + options.size(), width = title.length() + 2;
 for (int i = 0; i < options.size(); i++) {
  if (options[i].length() + 6 > width)
   width = options[i].length() + 6;
 }
 WINDOW *w = newwin(height, width, (TERMY-height)/2, (TERMX > width) ? (TERMX-width)/2 : 0);
 wattron(w, c_white);
 wborder(w, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX,
            LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX );
 mvwprintw(w, 1, 1, title.c_str());
 for (int i = 0; i < options.size(); i++)
  mvwprintw(w, i + 2, 1, "%c: %s", (i < 9? i + '1' :
                                   (i == 9? '0' : 'a' + i - 10)),
            options[i].c_str());
 long ch;
 wrefresh(w);
 int res;
 do
 {
  ch = getch();
  if (ch >= '1' && ch <= '9')
   res = ch - '1' + 1;
  else
  if (ch == '0')
   res = 10;
  else
  if (ch >= 'a' && ch <= 'z')
   res = ch - 'a' + 11;
  else
   res = -1;
  if (res > options.size())
   res = -1;
 }
 while (res == -1);
 werase(w);
 wrefresh(w);
 delwin(w);
 return (res);
}
예제 #19
0
char *wgotoseq(WINDOW *win) {
    static char name[1024];
    int cursor = 0;

    /* wborder(win, 0, 0, 0, 0, 0, 0, 0, 0); */
    wborder(win, '|', '|', '-', '-', '+', '+', '+', '+');

    mvwprintw(win, 1, 2, "Goto seq.:                       ");
    *name = 0;

    for (;;) {
        int c;

        mvwprintw(win, 1, 13, "%s", name);
        wrefresh(win);

        switch (c = wgetch(win)) {
        case KEY_BACKSPACE:
        case '\010':
        case '\177':
            if (cursor > 0)
                name[--cursor] = 0;
            break;

        case '\027': /* control w */
            cursor = 0;
            name[cursor] = 0;
            break;

        case '\033': /* escape */
            return "";

        case KEY_ENTER:
        case '\012':
        case '\015':
            return name;

        default:
            name[cursor++] = c;
            name[cursor] = 0;
        }

        mvwprintw(win, 1, 13, "            ");
        mvwprintw(win, 1, 13, "%s", name);
    }
}
예제 #20
0
파일: gfx.c 프로젝트: norips/projetEPP
WINDOW *create_newscore(int height, int width, int starty, int startx, int score, char *message)
{
    WINDOW *local_win;

    local_win = newwin(height, width, starty, startx);
    wborder(local_win, '|', '|', '-', '-', '+', '+', '+', '+'); /* 0, 0 gives default characters 
                                                                    * for the vertical and horizontal
                                             * lines			*/
    char msg[] = "Status : ";
    char msg2[] = "Score : ";
    wmove(local_win, 0, 0); //Set cur pos to top left car
    mvwprintw(local_win, 0, 0, "%s%s", msg, message);
    mvwprintw(local_win, height / 2, (width - (strlen(msg2) + 1)) / 2, "%s%d", msg2, score);
    wrefresh(local_win); /* Show that box 		*/

    return local_win;
}
예제 #21
0
int InitErrorWin(GameStats* Game)
{
	if ((ErrFrame=newwin(3,42,LINES-4,(COLS/2)-21))==NULL)
	{
		return 1;
	}
	else if ((ErrWin=derwin(ErrFrame,1,40,1,1))==NULL)
	{
		return 1;
	}
	wborder(ErrFrame,CharSet.VLine,CharSet.VLine,CharSet.HLine,CharSet.HLine,
		CharSet.ULCorner, CharSet.URCorner,CharSet.LLCorner,CharSet.LRCorner); 
	wnoutrefresh(ErrWin);
	wnoutrefresh(ErrFrame);
	ErrAlert=Game->Alert;
	return 0;
}
예제 #22
0
파일: cecho.c 프로젝트: Ma3aXuCT/cecho
void do_wborder(state *st) {
  int arity;
  long slot, ls, rs, ts, bs, tl, tr, bl, br;
  ei_decode_tuple_header(st->args, &(st->index), &arity);
  ei_decode_long(st->args, &(st->index), &slot);
  ei_decode_long(st->args, &(st->index), &ls);
  ei_decode_long(st->args, &(st->index), &rs);
  ei_decode_long(st->args, &(st->index), &ts);
  ei_decode_long(st->args, &(st->index), &bs);
  ei_decode_long(st->args, &(st->index), &tl);
  ei_decode_long(st->args, &(st->index), &tr);
  ei_decode_long(st->args, &(st->index), &bl);
  ei_decode_long(st->args, &(st->index), &br);
  encode_ok_reply(st, wborder(st->win[slot], (chtype)ls, (chtype)rs, (chtype)ts,
			      (chtype)bs, (chtype)tl, (chtype)tr, (chtype)bl,
			      (chtype)br));
}
예제 #23
0
static bool superstar2_initialize(void)
{
    int i;

    /* "heavily inspired" by monitor_nmea.c */
    if ((satwin = derwin(devicewin, 15, 27, 7, 0)) == NULL)
	return false;
    (void)wborder(satwin, 0, 0, 0, 0, 0, 0, 0, 0), (void)syncok(satwin, true);
    (void)wattrset(satwin, A_BOLD);
    (void)mvwprintw(satwin, 1, 1, "Ch PRN  Az El S/N Fl U");
    for (i = 0; i < 12; i++)
	(void)mvwprintw(satwin, (int)(i + 2), 1, "%2d", i);
    (void)mvwprintw(satwin, 14, 1, " Satellite Data & Status ");
    (void)wattrset(satwin, A_NORMAL);

    return true;
}
예제 #24
0
void
show_timeframe_dialog (WINDOW *parent, int x, int y)
{
    WINDOW *win = subwin(parent, 5, 20, y, x); 
    wborder(win, 0, 0, 0, 0, 0, 0, 0, 0);
    wmove(win, 0, 2);
    waddstr(win, "[ Timeframe ]");

    wmove(win, 1, 3);
    waddstr(win, "1 hour");
    wmove(win, 2, 1);
    waddstr(win, "> 2 hours");
    wmove(win, 3, 3);
    waddstr(win, "8 hours");

    wmove(win, 4, 18);
    waddch(win, 'v');
}
예제 #25
0
void StatisticsWindow::updateProtocol(AbstractProtocol* p)
{
    if(p != nullptr)
        _activeProtocol = p;
    if(_window == nullptr)
    {
        return;
    }
    werase(_window);
    wborder(_window, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE, ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER);

    std::string tmp("  ");
    for_each(_allProtocols.begin(), _allProtocols.end(), [&](std::string& s) {
        if(!s.compare(_activeProtocol->getProtocolName()))
        {
            tmp += std::string(" < ") + s + std::string(" > ");
        }
        else
        {
            tmp += std::string("   ") + s + std::string("   ");
        }

    });
    mvwprintw(_window, STATISTICS::PROTOCOLS_LINE, FIRST_CHAR_POS, "%s", tmp.c_str());

    unsigned int line = STATISTICS::FIRST_OPERATION_LINE;
    for(unsigned int i = STATISTICS::DEFAULT_GROUP; i <= _activeProtocol->getGroups(); i++)
    {
        if(canWrite(line))
        {
            mvwprintw(_window, line - (_scrollOffset.at(p)), FIRST_CHAR_POS, "%s", "Total:");
        }
        line++;
        for(unsigned int j = _activeProtocol->getGroupBegin(i); j < _activeProtocol->getGroupBegin(i + 1); j++)
        {
            if(canWrite(line))
            {
                mvwprintw(_window, line - (_scrollOffset.at(p)), FIRST_CHAR_POS, "%s", p->printProcedure(j));
            }
            line++;
        }
        line++;
    }
}
예제 #26
0
파일: menu.c 프로젝트: AdriDlu/coreboot
void draw_menu(void)
{
	struct payload *s;
	int i;

	wattrset(menuwin, COLOR_PAIR(3));
	wclear(menuwin);
	wborder(menuwin, ACS_VLINE, ACS_VLINE, ACS_HLINE, ACS_HLINE,
		ACS_ULCORNER, ACS_URCORNER, ACS_LLCORNER, ACS_LRCORNER);

	wattrset(menuwin, COLOR_PAIR(4) | A_BOLD);
	mvwprintw(menuwin, 0, (menu_width - 17) / 2, " Payload Chooser ");

	wattrset(menuwin, COLOR_PAIR(3));

	for (i = 0; i < m_entries; i++) {
		char *name = payload_get_name(mpayloads[i]);
		int col = (menu_width - (2 + strlen(name))) / 2;

		if (i == selected)
			wattrset(menuwin, COLOR_PAIR(5) | A_BOLD);
		else
			wattrset(menuwin, COLOR_PAIR(3));

		mvwprintw(menuwin, 2 + i, col, name);
	}

	s = mpayloads[selected];

	wclear(status);

	if (s->params[BAYOU_PARAM_DESC] != NULL) {
		char buf[66];
		int len = strnlen(s->params[BAYOU_PARAM_DESC], 65);

		snprintf(buf, 65, s->params[BAYOU_PARAM_DESC]);
		buf[65] = 0;

		mvwprintw(status, 0, (80 - len) / 2, buf);
	}

	wrefresh(menuwin);
	wrefresh(status);
}
예제 #27
0
static struct result
draw_window(struct selection *selection)
{
    int result = wborder(selection->window, '|', '|', '-', '-', '+', '+', '+', '+');
    if (OK != result) return result_ncurses_err();
        
    // TODO: handle UTF-8 correctly
    size_t title_string_length = strlen(selection->title);
    if (title_string_length > (size_t)INT_MAX) {
        return result_set_system_error(ERANGE);
    }
    
    if (title_string_length) {
        int title_string_width = (int)title_string_length;
        int window_height;
        int window_width;
        getmaxyx(selection->window, window_height, window_width);
        
        char const left_frame[] = "- ";
        char const right_frame[] = " -";
        
        int const left_frame_width = sizeof(left_frame) - 1;
        int const right_frame_width = sizeof(right_frame) - 1;
        
        int const left_border_width = 1;
        int const right_border_width = 1;
        
        int window_top_width = window_width - left_border_width - right_border_width;
        int title_width = left_frame_width + title_string_width + right_frame_width;
        if (window_top_width >= title_width) {
            int start = left_border_width + (window_top_width - title_width) / 2;
            result = mvwprintw(selection->window, 0, start, "%s%s%s",
                               left_frame, selection->title, right_frame);
            if (ERR == result) return result_ncurses_err();
        } else {
            // TODO: elide title
        }
    }
    
    result = wrefresh(selection->window);
    if (ERR == result) return result_ncurses_err();
    
    return result_success();
}
예제 #28
0
NMessageBox::NMessageBox(const char* text) : NGroup(NRect(3, 40, 1, 1))
{
    //расчитать сколько строк нужно для отображения контента
    int contentheight = 0;
    int bsize = strlen(text); //количество байт
    int result = 0; //подсчитанное кол-во символов
    int nbytes = 0; //просмотренное кол-во байтов
    int nlines = 0; //количество экранных строк
    int col = getwidth() - 4;
    const char* p = text;
    do
    {
	col++;
	if ((col >= getwidth() - 4)||(*p == '\n'))
	{
	    if (*p == '\n')
		col = 0;
	    else
		col = 1;
	    contentheight++; //след строка
	}
	int symlen = mblen(p,bsize-nbytes);
	nbytes = nbytes + symlen;
	result++;
	p = p + symlen; //адрес начала след символа
    }
    while ( (*p != 0)&&(nbytes < bsize) ); //дошли до конца
    //заполняем содержимое
    content = new NStaticText(NRect(contentheight, getwidth()-4, 2, 2));
    content->setbgcolor(getcolorpair(COLOR_WHITE, COLOR_BLACK));
    insert(content);
    content->appendstring(getcolorpair(COLOR_WHITE, COLOR_BLACK) | A_BOLD, text);
    modalflag = true;
    resize(contentheight + 6,getwidth());
    wattrset(win,getcolorpair(COLOR_WHITE, COLOR_BLACK) | A_BOLD);
    if(asciilinedraw == 1)
	wborder(win, '|', '|', '-', '-', '+', '+', '+', '+');
    else
	box(win,0,0);
    //content->setalign(1);
    move(getmaxy(stdscr)/2-getheight()/2,getmaxx(stdscr)/2-getwidth()/2); //центрируем

}
예제 #29
0
void showHelp() {
    flushinp();
    wclear(helpwindow);
    wbkgd(helpwindow,COLOR_PAIR(2) | A_DIM);
    wborder(helpwindow,0,0,0,0,0,0,0,0);
    wattrset(helpwindow,A_BOLD);
    mvwprintw(helpwindow,0,2,"Help");
    mvwprintw(helpwindow,2,2,"Q - Quit");
    mvwprintw(helpwindow,3,2,"F1 - Help (this screen)");
    mvwprintw(helpwindow,4,2,"Left Arrow - Move Left");
    mvwprintw(helpwindow,5,2,"Right Arrow - Move Right");
    mvwprintw(helpwindow,6,2,"Down Arrow - Move Down");
    mvwprintw(helpwindow,7,2,"Up Arrow - Move Up");
    wattrset(helpwindow,A_REVERSE);
    mvwprintw(helpwindow,18,2,"Press any key to resume");
    wattrset(helpwindow,A_NORMAL);
    wrefresh(helpwindow);
    wgetch(helpwindow);
}
예제 #30
0
파일: curses.cpp 프로젝트: drakargx/ADWIF
  void CursesRenderer::drawMessage(const std::string & message)
  {
    std::string text = wrapText(message, this->width() / 2);
    std::vector<std::string> msgBuf;
    boost::split(msgBuf, text, boost::is_any_of("\n"));
    unsigned int width = 0;
    for (auto & s : msgBuf)
      width = (s.size() > width ? s.size() : width);
    width += 2;
    int msgHeight = msgBuf.size();
    int height = 2 + msgHeight;

    startWindow(this->width() / 2 - width / 2,
                this->height() / 2 - height / 2, width, height);
    style(Colour::White, Colour::Black, Style::Normal);
    wborder(win(), 0,0,0,0,0,0,0,0);
    mvwaddstr(win(), 1, 1, text.c_str());
    endWindow();
  }