void win_show_subwin(ProfWin *window) { int cols = getmaxx(stdscr); int subwin_cols = 0; switch (window->type) { case WIN_CONSOLE: subwin_cols = win_roster_cols(); window->wins.cons.subwin = newpad(PAD_SIZE, subwin_cols); wbkgd(window->wins.cons.subwin, theme_attrs(THEME_TEXT)); wresize(window->win, PAD_SIZE, cols - subwin_cols); win_redraw(window); break; case WIN_MUC: subwin_cols = win_occpuants_cols(); window->wins.muc.subwin = newpad(PAD_SIZE, subwin_cols); wbkgd(window->wins.muc.subwin, theme_attrs(THEME_TEXT)); wresize(window->win, PAD_SIZE, cols - subwin_cols); win_redraw(window); break; default: break; } }
/* Create a new input Input ( -- required int width, int height, int begin_x, int begin_y, -- not required int off ) 3 cases for off: - if height = 1 off is the number of off-screen cols - if height > 1 off is the number of off-screen lines - if off is not set the field is not growable FIXME: check NULL pad */ int lui_new_input(lua_State *L) { INPUT *i; i = malloc(sizeof(*i)); *i = default_input; luasoul_checkint(L, 1, i->width); luasoul_checkint(L, 2, i->height); luasoul_checkint(L, 3, i->begin_x); luasoul_checkint(L, 4, i->begin_y); luasoul_optint(L, 5, i->off, 0); if (i->height == 1) i->pad = newpad(i->height, i->width + i->off); else i->pad = newpad(i->height + i->off, i->width); if (i->pad == NULL || alloc_cchar_buffer(i)) { luasoul_error(L, "can't create input"); return 0; } *((INPUT **) lua_newuserdata(L, sizeof(i))) = i; /* set instance metatable to registered methods */ luaL_getmetatable(L, INPUT_CLASS); lua_setmetatable(L, -2); return 1; }
ProfWin* win_create(const char * const title, win_type_t type) { ProfWin *new_win = malloc(sizeof(ProfWin)); int cols = getmaxx(stdscr); new_win->type = type; switch (new_win->type) { case WIN_CONSOLE: new_win->win = newpad(PAD_SIZE, (cols)); wbkgd(new_win->win, theme_attrs(THEME_TEXT)); new_win->wins.cons.subwin = NULL; new_win->wins.cons.sub_y_pos = 0; break; case WIN_MUC: if (prefs_get_boolean(PREF_OCCUPANTS)) { int subwin_cols = win_occpuants_cols(); new_win->win = newpad(PAD_SIZE, cols - subwin_cols); wbkgd(new_win->win, theme_attrs(THEME_TEXT)); new_win->wins.muc.subwin = newpad(PAD_SIZE, subwin_cols);; wbkgd(new_win->wins.muc.subwin, theme_attrs(THEME_TEXT)); } else { new_win->win = newpad(PAD_SIZE, (cols)); wbkgd(new_win->win, theme_attrs(THEME_TEXT)); new_win->wins.muc.subwin = NULL; } new_win->wins.muc.sub_y_pos = 0; break; default: new_win->win = newpad(PAD_SIZE, (cols)); wbkgd(new_win->win, theme_attrs(THEME_TEXT)); break; } if (new_win->type == WIN_MUC_CONFIG) { new_win->wins.conf.form = NULL; } new_win->from = strdup(title); new_win->buffer = buffer_create(); new_win->y_pos = 0; new_win->paged = 0; new_win->unread = 0; if (new_win->type == WIN_CHAT) { new_win->wins.chat.resource = NULL; new_win->wins.chat.is_otr = FALSE; new_win->wins.chat.is_trusted = FALSE; new_win->wins.chat.history_shown = FALSE; } scrollok(new_win->win, TRUE); return new_win; }
void Terminal::Initialize(){ if(init){ return; } original = std::cout.rdbuf(); // Back-up cout's streambuf pbuf = stream.rdbuf(); // Get stream's streambuf std::cout.flush(); std::cout.rdbuf(pbuf); // Assign streambuf to cout main = initscr(); if(main == NULL ){ // Attempt to initialize ncurses std::cout.rdbuf(original); // Restore cout's original streambuf fprintf(stderr, " Error: failed to initialize ncurses!\n"); } else{ getmaxyx(stdscr, _winSizeY, _winSizeX); output_window = newpad(_scrollbackBufferSize, _winSizeX); input_window = newpad(1, _winSizeX); wmove(output_window, _scrollbackBufferSize-1, 0); // Set the output cursor at the bottom so that new text will scroll up if (halfdelay(5) == ERR) { // Timeout after 5/10 of a second std::cout << "WARNING: Unable to set terminal blocking half delay to 0.5s!\n"; std::cout << "\tThis will increase CPU usage in the command thread.\n"; if (nodelay(input_window, true) == ERR) { //Disable the blocking timeout. std::cout << "ERROR: Unable to remove terminal blocking!\n"; std::cout << "\tThe command thread will be locked until a character is entered. This will reduce functionality of terminal status bar and timeout.\n"; } } keypad(input_window, true); // Capture special keys noecho(); // Turn key echoing off scrollok(output_window, true); scrollok(input_window, true); if (NCURSES_MOUSE_VERSION > 0) { mousemask(ALL_MOUSE_EVENTS,NULL); mouseinterval(0); } init = true; offset = 0; // Set the position of the physical cursor cursX = 0; cursY = _winSizeY-1; update_cursor_(); refresh_(); init_colors_(); } setup_signal_handlers(); }
void loadAndAddText(WINDOW **pad, int *textrows, char *filename) { FILE *f = fopen(filename, "r"); char buf[1000]; int line; if (f) { line = 0; while(fgets(buf, 1000, f)) { line++; } *textrows = line; delwin(*pad); *pad = newpad(*textrows, 1000); rewind(f); line = 0; while(fgets(buf, 1000, f)) { mvwaddstr(*pad, line, 0, buf); line++; } } scrollok(*pad, TRUE); // enable scrolling prefresh(*pad, 0, 0, 1, 1, MAIN_HEIGHT-2, MAIN_WIDTH-2); wmove(*pad, 0, 0); // reset cursor to upper-left corner }
int main(void) { WINDOW *pad_ptr; int x, y; int pad_lines; int pad_cols; char disp_char; initscr(); pad_lines = LINES + 50; pad_cols = COLS + 50; pad_ptr = newpad(pad_lines, pad_cols); disp_char = 'a'; for (x = 0; x < pad_lines; ++x) { for (y = 0; y < pad_cols; ++y) { mvwaddch(pad_ptr, x, y, disp_char); if (disp_char == 'z') { disp_char = 'a'; } else { disp_char++; } } } prefresh(pad_ptr, 5, 7, 2, 2, 9, 9); sleep(1); prefresh(pad_ptr, LINES + 5, COLS + 7, 5, 5, 21, 19); sleep(1); delwin(pad_ptr); endwin(); return 0; }
/* protected function definitions */ void scdk::SCPad::createWindow(int h,int w,int l,int t) { /* TODO : Check for errors in the various parameters*/ if(l<0) _left=0; else _left=l; if(t<0) _top=0; else _top=t; if(w>COLS) _width=COLS; else _width=w; if(h>LINES) _height=LINES; else _height=h; _canScroll=false; _cursorType=1; _bgChar=' '; _hidden=true; _win = newpad(_height,_width); wbkgd(_win,_bgChar | COLOR_PAIR(_color.getColorPair())); keypad(_win,TRUE); }
void boot_editor_update(struct boot_editor *boot_editor, const struct system_info *sysinfo) { int height; if (boot_editor->cui->current != boot_editor_scr(boot_editor)) { boot_editor->need_update = true; return; } widgetset_unpost(boot_editor->widgetset); height = pad_height(sysinfo ? sysinfo->n_blockdevs : 0); if (getmaxy(boot_editor->pad) < height) { delwin(boot_editor->pad); boot_editor->pad = newpad(height, COLS); widgetset_set_windows(boot_editor->widgetset, boot_editor->scr.main_ncw, boot_editor->pad); } boot_editor_populate_device_select(boot_editor, sysinfo); boot_editor_layout_widgets(boot_editor); widgetset_post(boot_editor->widgetset); pad_refresh(boot_editor); }
/** Create a window having specified parent and dimensions. * @param pPad Pointer to the new window. * @param pParent Parent window. * @param uiRows Number of rows for new window. * @param uiCols Number of columnss for new window. */ static bool create_pad(APPPAD* pPad, WINDOW* pParent, unsigned int uiRows, unsigned int uiCols) { bool bStatus = false; assert(pParent); if (pPad->pPad) { delwin(pPad->pPad); } if (NULL != pPad && NULL == (pPad->pPad = newpad(uiRows, uiCols))) { goto newpad_fail; } pPad->uiRows = uiRows; pPad->uiColumns = uiCols; pPad->uiPadRow = 0; pPad->uiPadCol = 0; pPad->uiWinLeft = application_windows.pDetailsWin->_begx + 1; pPad->uiWinTop = application_windows.pDetailsWin->_begy + 1; pPad->uiWinColumns = application_windows.pDetailsWin->_maxx - 2; pPad->uiWinRows = application_windows.pDetailsWin->_maxy - 2; bStatus = true; newpad_fail: return bStatus; }
int main() { WINDOW *p; initscr(); /* create a new pad */ p = newpad(50,100); if( p == NULL ) { addstr("Unable to create new pad"); refresh(); endwin(); return(1); } addstr("New pad created"); refresh(); getch(); if( delwin(p)==OK) addstr("...and now it's gone!\n"); else addstr("...and it's still there!\n"); refresh(); getch(); endwin(); return 0; }
/* Create a new chatbox Chatbox ( -- required int width, int height, int begin_x, int begin_y, -- not required int histsize ) FIXME: error handling, negative values */ int lui_new_chatbox(lua_State *L) { CHATBOX *c; c = malloc(sizeof(*c)); /* FIXME: if NULL */ *c = default_chatbox; c->width = luaL_checkint(L, 1); c->height = luaL_checkint(L, 2); c->begin_x = luaL_checkint(L, 3); c->begin_y = luaL_checkint(L, 4); c->histsize = luaL_optint(L, 5, 0); /* default histsize is 0 */ c->pad = newpad(c->height + c->histsize, c->width); scrollok(c->pad, TRUE); /* skip beginning of history */ wmove(c->pad, c->histsize, 0); /* don't refresh, in case set_style is call for example */ /* refresh_chatbox(c); */ *((CHATBOX **) lua_newuserdata(L, sizeof(c))) = c; /* set instance metatable to registered methods */ luaL_getmetatable(L, CHATBOX_CLASS); lua_setmetatable(L, -2); return 1; }
int main(int argc, char *argv[]) { WINDOW *p; int x, c; initscr(); refresh(); /* create a new pad */ p = newpad(50, 100); if(p == NULL) { addstr("Unable to create a new pad"); refresh(); endwin(); return(1); } addstr("New pad created"); refresh(); getch(); endwin(); return 0; }
int main(void) { WINDOW *pad_ptr; int x, y, pad_lines, pad_cols; char disp_char; initscr(); pad_lines = LINES + 50; pad_cols = COLS + 50; pad_ptr = newpad(pad_lines, pad_cols); disp_char = 'a'; for(x = 0; x < pad_lines; x++) for(y = 0; y < pad_cols; y++) { /* move ch and put ch at given postition */ mvwaddch(pad_ptr, x, y, disp_char); if(disp_char == 'z') disp_char = 'a'; else disp_char++; } prefresh(pad_ptr, 5, 7, 2, 2, 9, 9); sleep(1); prefresh(pad_ptr, LINES + 5, COLS + 7, 5, 5, 21, 19); sleep(1); delwin(pad_ptr); endwin(); exit(EXIT_SUCCESS); }
ProfWin* win_create_chat(const char * const barejid) { ProfWin *new_win = malloc(sizeof(ProfWin)); int cols = getmaxx(stdscr); new_win->type = WIN_CHAT; new_win->win = newpad(PAD_SIZE, (cols)); wbkgd(new_win->win, theme_attrs(THEME_TEXT)); new_win->from = strdup(barejid); new_win->buffer = buffer_create(); new_win->y_pos = 0; new_win->paged = 0; new_win->unread = 0; new_win->wins.chat.resource = NULL; new_win->wins.chat.is_otr = FALSE; new_win->wins.chat.is_trusted = FALSE; new_win->wins.chat.history_shown = FALSE; scrollok(new_win->win, TRUE); return new_win; }
CursesBase::CursesBase(QSize size, int colorPair) { _window=newpad(size.height(), size.width()); if(!_window) throw "Unable to allocate pad"; wbkgd(_window, COLOR_PAIR(colorPair)); _dirty=true; }
int main(void) { WINDOW *p; initscr(); p = newpad(50,100); /* create a new pad */ if( p == NULL ) { endwin(); puts("Unable to create new pad"); return(1); } waddstr(p,"This is pad data"); addstr("New pad created\n"); prefresh(p,0,0,12,0,13,40); printw("Pad y data is %d.\n",p->_pad._pad_y); printw("Pad x data is %d.\n",p->_pad._pad_x); printw("Pad top data is %d.\n",p->_pad._pad_top); printw("Pad left data is %d.\n",p->_pad._pad_left); printw("Pad bottom data is %d.\n",p->_pad._pad_bottom); printw("Pad right data is %d.\n",p->_pad._pad_right); refresh(); prefresh(p,0,0,12,0,13,40); getch(); endwin(); return 0; }
/* * Create ncurses pad with a frame. */ static void pad_create(struct subwin *w) { assert(sub_current); main_pad->wd = newpad(SUBWIN_ROWS, SUBWIN_COLS); if(!main_pad->wd) prg_exit("pad_create(): cannot create details window. [1]"); set_size(main_pad); w->offset = w->lines = w->xoffset = 0; border_wd = newpad(BORDER_ROWS+1, BORDER_COLS+1); if(!border_wd) prg_exit("pad_create(): cannot create details window. [2]"); wbkgd(border_wd, COLOR_PAIR(8)); werase(border_wd); box(border_wd, ACS_VLINE, ACS_HLINE); print_titles(); wbkgd(main_pad->wd, COLOR_PAIR(8)); werase(main_pad->wd); }
post_menu(MENU * menu) { T((T_CALLED("post_menu(%p)"), (void *)menu)); if (!menu) RETURN(E_BAD_ARGUMENT); if (menu->status & _IN_DRIVER) RETURN(E_BAD_STATE); if (menu->status & _POSTED) RETURN(E_POSTED); if (menu->items && *(menu->items)) { int y; int h = 1 + menu->spc_rows * (menu->rows - 1); WINDOW *win = Get_Menu_Window(menu); int maxy = getmaxy(win); if ((menu->win = newpad(h, menu->width))) { y = (maxy >= h) ? h : maxy; if (y >= menu->height) y = menu->height; if (!(menu->sub = subpad(menu->win, y, menu->width, 0, 0))) RETURN(E_SYSTEM_ERROR); } else RETURN(E_SYSTEM_ERROR); if (menu->status & _LINK_NEEDED) _nc_Link_Items(menu); } else RETURN(E_NOT_CONNECTED); menu->status |= _POSTED; if (!(menu->opt & O_ONEVALUE)) { ITEM **items; for (items = menu->items; *items; items++) { (*items)->value = FALSE; } } _nc_Draw_Menu(menu); Call_Hook(menu, menuinit); Call_Hook(menu, iteminit); _nc_Show_Menu(menu); RETURN(E_OK); }
NWindowEdit::NWindowEdit (int _x, int _y, int w, int h, int _ex, int _ey, int _ew, int _eh, bool border):NWindow (_x, _y, w, h, border) { ex = _ex; ey = _ey; eh = _eh; ew = _ew; comwin = newpad (_eh, _ew); }
void Terminal::Initialize(){ if(init){ return; } original = std::cout.rdbuf(); // Back-up cout's streambuf pbuf = stream.rdbuf(); // Get stream's streambuf std::cout.flush(); std::cout.rdbuf(pbuf); // Assign streambuf to cout main = initscr(); if(main == NULL ){ // Attempt to initialize ncurses std::cout.rdbuf(original); // Restore cout's original streambuf fprintf(stderr, " Error: failed to initialize ncurses!\n"); } else{ getmaxyx(stdscr, _winSizeY, _winSizeX); output_window = newpad(_scrollbackBufferSize, _winSizeX); input_window = newpad(1, _winSizeX); wmove(output_window, _scrollbackBufferSize-1, 0); // Set the output cursor at the bottom so that new text will scroll up halfdelay(5); // Timeout after 5/10 of a second keypad(input_window, true); // Capture special keys noecho(); // Turn key echoing off scrollok(output_window, true); scrollok(input_window, true); if (NCURSES_MOUSE_VERSION > 0) { mousemask(ALL_MOUSE_EVENTS,NULL); mouseinterval(0); } init = true; text_length = 0; offset = 0; // Set the position of the physical cursor cursX = 0; cursY = _winSizeY-1; update_cursor_(); refresh_(); init_colors_(); } setup_signal_handlers(); }
/*** Create a new pad. @function newpad @int nlines @int ncols @treturn bool `true`, if successful @see newpad(3x) */ static int Pnewpad(lua_State *L) { int nlines = checkint(L, 1); int ncols = checkint(L, 2); lc_newwin(L, newpad(nlines, ncols)); return 1; }
/* * Create a new window and its associated pad, which is used to make the * scrolling faster. */ void wins_scrollwin_init (struct scrollwin *sw) { EXIT_IF (sw == NULL, "null pointer"); sw->win.p = newwin (sw->win.h, sw->win.w, sw->win.y, sw->win.x); sw->pad.p = newpad (sw->pad.h, sw->pad.w); sw->first_visible_line = 0; sw->total_lines = 0; }
pad::pad(int const width, int const height) : _width(width) , _height(height) , _window(newpad(height, width)) { if (_window == nullptr) { throw "failed to initialize pad"; } }
ProfWin* win_create_muc(const char *const roomjid) { ProfMucWin *new_win = malloc(sizeof(ProfMucWin)); int cols = getmaxx(stdscr); new_win->window.type = WIN_MUC; ProfLayoutSplit *layout = malloc(sizeof(ProfLayoutSplit)); layout->base.type = LAYOUT_SPLIT; if (prefs_get_boolean(PREF_OCCUPANTS)) { int subwin_cols = win_occpuants_cols(); layout->base.win = newpad(PAD_SIZE, cols - subwin_cols); wbkgd(layout->base.win, theme_attrs(THEME_TEXT)); layout->subwin = newpad(PAD_SIZE, subwin_cols);; wbkgd(layout->subwin, theme_attrs(THEME_TEXT)); } else { layout->base.win = newpad(PAD_SIZE, (cols)); wbkgd(layout->base.win, theme_attrs(THEME_TEXT)); layout->subwin = NULL; } layout->sub_y_pos = 0; layout->memcheck = LAYOUT_SPLIT_MEMCHECK; layout->base.buffer = buffer_create(); layout->base.y_pos = 0; layout->base.paged = 0; scrollok(layout->base.win, TRUE); new_win->window.layout = (ProfLayout*)layout; new_win->roomjid = strdup(roomjid); new_win->unread = 0; new_win->unread_mentions = FALSE; new_win->unread_triggers = FALSE; if (prefs_get_boolean(PREF_OCCUPANTS_JID)) { new_win->showjid = TRUE; } else { new_win->showjid = FALSE; } new_win->memcheck = PROFMUCWIN_MEMCHECK; return &new_win->window; }
void Scrollpad::clear() { m_real_height = m_height; m_buffer.clear(); werase(m_window); delwin(m_window); m_window = newpad(m_height, m_width); setTimeout(m_window_timeout); setColor(m_color); }
void Create() { _border = newwin(_screen_ymax-_screen_ymin+1, _screen_xmax-_screen_xmin+1, _screen_ymin,_screen_xmin); box(_border,0,0); /* 0, 0 gives default characters * for the vertical and horizontal * lines */ wrefresh(_border); _pad = newpad(_max_lines,_max_cols); }
void curses_add_nhwin(winid wid, int height, int width, int y, int x, orient orientation, boolean border) { WINDOW *win; nethack_window *new_win; nethack_window *winptr = nhwins; int real_width = width; int real_height = height; new_win = malloc(sizeof(nethack_window)); new_win->nhwin = wid; new_win->border = border; new_win->width = width; new_win->height = height; new_win->x = x; new_win->y = y; new_win->orientation = orientation; if (border) { real_width += 2; /* leave room for bounding box */ real_height += 2; } new_win->next_window = NULL; if (winptr == NULL) { new_win->prev_window = NULL; nhwins = new_win; } else { while (winptr->next_window != NULL) winptr = winptr->next_window; new_win->prev_window = winptr; winptr->next_window = new_win; } if (wid != MAP_WIN) { win = newwin(real_height, real_width, y, x); if (border) { box(win, 0, 0); } } else { if (border) { box(mapborderwin, 0, 0); } win = newpad(ROWNO, COLNO); } new_win->curwin = win; }
/*#DOC*/ Canvas canvas_new(int w, int h) { Canvas c = malloc(sizeof(struct View)); if (NULL == c) return NULL; c->_win = newpad(h, w); c->_pan = NULL; c->_sty = (Style) 0; if (NULL == view_win(c)) { free(c); return NULL; } return c; }
/* * Add box to a widget (if not exists yet ) * and eventually place some text in it. */ void scr_box(struct wdgt *w, char *s, u8 c) { if(w->decor) { scr_box_text(w, s, c); return; } /* box not yet created, do it now */ DBG("Creating box for '%s'", w->name); w->decor = newpad(w->ysize - w->y + 3, w->xsize - w->x + 3); if(!w->decor) return; sadd_box(w); wbkgd(w->decor, COLOR_PAIR(c)); scr_box_text(w, s, c); }
unique_window_ptr make_pad(const point& dimension) { unique_window_ptr handle { newpad(dimension.y, dimension.x), &::delwin }; if(!handle) { std::ostringstream oss; oss << "unable to create pad with dimension: " << dimension; throw CONS_MAKE_EXCEPTION(oss.str()); } return handle; }