예제 #1
0
int main(int argc, char *argv[])
{
        WINDOW *top, *bottom;
        int maxx, maxy, halfx, halfy, rc;
        char text1[] = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.";
        char text2[] = "Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.";

        initscr();
        refresh();

        /* get window sizes */
        getmaxyx(stdscr, maxy, maxx);
        halfy = maxy >> 1;
        halfx = maxx >> 1;

        /* build windows */
        top = newwin(halfy, maxx, 0, 0);     // remember to check for errors!
        bottom = newwin(halfy, halfx, halfy, halfx);

        waddstr(top, text1);          // add text to stdscr and wait
        wrefresh(top);
        waddstr(bottom, text2);
        wrefresh(bottom);

        /* wait for keypress */
        getch();

        /* copy text from top to bottom */
        rc = copywin(top, bottom, 0, 0, 0, 0, 4, 12, FALSE);
        wrefresh(bottom);
        getch();

        endwin();
        return 0;
}
예제 #2
0
int Window::copyto(Window *dstwin, int smincol, int sminrow,
    int dmincol, int dminrow, int dmaxcol, int dmaxrow,
    int overlay)
{
  return copywin(p->win, dstwin->p->win, sminrow, smincol, dminrow, dmincol,
      dmaxrow, dmaxcol, overlay);
}
예제 #3
0
파일: m_global.c 프로젝트: vocho/openqnx
/*---------------------------------------------------------------------------
|   Facility      :  libnmenu  
|   Function      :  void _nc_Show_Menu(const MENU *menu)
|   
|   Description   :  Update the window that is associated with the menu
|
|   Return Values :  -
+--------------------------------------------------------------------------*/
void _nc_Show_Menu(const MENU *menu)
{
  WINDOW *win;
  int maxy, maxx;
  
  assert(menu);
  if ( (menu->status & _POSTED) && !(menu->status & _IN_DRIVER) )
    {
      /* adjust the internal subwindow to start on the current top */
      assert(menu->sub);
      mvderwin(menu->sub,menu->spc_rows * menu->toprow,0);
      win = Get_Menu_Window(menu);
      
      maxy = getmaxy(win);
      maxx = getmaxx(win);	 
      
      if (menu->height < maxy) 
	maxy = menu->height;
      if (menu->width < maxx) 
	maxx = menu->width;
      
      copywin(menu->sub,win,0,0,0,0,maxy-1,maxx-1,0);
      pos_menu_cursor(menu);
    }	
}	
예제 #4
0
EIF_INTEGER c_ecurses_copywin (EIF_POINTER win1, EIF_POINTER win2,
                               EIF_INTEGER sminrow, EIF_INTEGER smincol, EIF_INTEGER dminrow, EIF_INTEGER dmincol,
                               EIF_INTEGER dmaxrow, EIF_INTEGER dmaxcol, EIF_INTEGER overlay_num)
{
    return copywin( (WINDOW *) win1, (WINDOW*)win2, (int) sminrow,(int) smincol,(int) dminrow,(int) dmincol,
                    (int) dmaxrow,(int) dmaxcol,(int) overlay_num) ;
};
예제 #5
0
void cCursesOsd::RestoreRegion(void)
{
  if (savedRegion) {
     copywin(savedRegion, window, 0, 0, savedRegion->_begy, savedRegion->_begx, savedRegion->_maxy - savedRegion->_begy, savedRegion->_maxx - savedRegion->_begx, false);
     delwin(savedRegion);
     savedRegion = NULL;
     }
}
예제 #6
0
파일: control.c 프로젝트: linehan/barnacle
void draw_zoom_box(struct map_t *map, int y, int x)
{
        /*------------------------------------------------------------*/
        copywin(PLATE(map, BGR), cursor->win, y, x, 0, 0, frame_h-1, frame_w-1, 0);
        copywin(PLATE(map, RIM), cursor->win, y, x, 0, 0, frame_h-1, frame_w-1, 1);
        /*------------------------------------------------------------*/
        take_bgcolor_yx(cursor->win, 0         , 0         , INSET_UL);
        take_bgcolor_yx(cursor->win, 0         , frame_w-1 , INSET_UR);
        take_bgcolor_yx(cursor->win, frame_h-1 , 0         , INSET_DL);
        take_bgcolor_yx(cursor->win, frame_h-1 , frame_w-1 , INSET_DR);
        /*------------------------------------------------------------*/
        mvwcch(cursor->win, 0         , 0         , L"▛" , 0 , INSET_UL);
        mvwcch(cursor->win, 0         , frame_w-1 , L"▜" , 0 , INSET_UR);
        mvwcch(cursor->win, frame_h-1 , 0         , L"▙" , 0 , INSET_DL);
        mvwcch(cursor->win, frame_h-1 , frame_w-1 , L"▟" , 0 , INSET_DR);
        /*------------------------------------------------------------*/
}
예제 #7
0
static void
gnt_box_expose(GntWidget *widget, int x, int y, int width, int height)
{
	WINDOW *win = newwin(height, width, widget->priv.y + y, widget->priv.x + x);
	copywin(widget->window, win, y, x, 0, 0, height - 1, width - 1, FALSE);
	wrefresh(win);
	delwin(win);
}
예제 #8
0
void cCursesOsd::SaveRegion(int x1, int y1, int x2, int y2)
{
  if (savedRegion) {
     delwin(savedRegion);
     savedRegion = NULL;
     }
  savedRegion = newwin(y2 - y1 + 1, x2 - x1 + 1, y1, x1);
  copywin(window, savedRegion, y1, x1, 0, 0, y2 - y1, x2 - x1, false);
}
예제 #9
0
static int
overlap(const WINDOW *const src, WINDOW *const dst, int const flag)
{
    int rc = ERR;
    int sx1, sy1, sx2, sy2;
    int dx1, dy1, dx2, dy2;
    int sminrow, smincol;
    int dminrow, dmincol;
    int dmaxrow, dmaxcol;

    T((T_CALLED("overlap(%p,%p,%d)"), src, dst, flag));

    if (src != 0 && dst != 0) {
	_nc_lock_global(curses);

	T(("src : begy %ld, begx %ld, maxy %ld, maxx %ld",
	   (long) src->_begy,
	   (long) src->_begx,
	   (long) src->_maxy,
	   (long) src->_maxx));
	T(("dst : begy %ld, begx %ld, maxy %ld, maxx %ld",
	   (long) dst->_begy,
	   (long) dst->_begx,
	   (long) dst->_maxy,
	   (long) dst->_maxx));

	sx1 = src->_begx;
	sy1 = src->_begy;
	sx2 = sx1 + src->_maxx;
	sy2 = sy1 + src->_maxy;

	dx1 = dst->_begx;
	dy1 = dst->_begy;
	dx2 = dx1 + dst->_maxx;
	dy2 = dy1 + dst->_maxy;

	if (dx2 >= sx1 && dx1 <= sx2 && dy2 >= sy1 && dy1 <= sy2) {
	    sminrow = max(sy1, dy1) - sy1;
	    smincol = max(sx1, dx1) - sx1;
	    dminrow = max(sy1, dy1) - dy1;
	    dmincol = max(sx1, dx1) - dx1;
	    dmaxrow = min(sy2, dy2) - dy1;
	    dmaxcol = min(sx2, dx2) - dx1;

	    rc = copywin(src, dst,
			 sminrow, smincol,
			 dminrow, dmincol,
			 dmaxrow, dmaxcol,
			 flag);
	}
	_nc_unlock_global(curses);
    }
    returnCode(rc);
}
예제 #10
0
/*
 * overlay --
 *	Writes win1 on win2 non-destructively.
 */
int
overlay(const WINDOW *win1, WINDOW *win2)
{

#ifdef DEBUG
	__CTRACE(__CTRACE_WINDOW, "overlay: (%p, %p);\n", win1, win2);
#endif
	return copywin(win1, win2,
			win2->begy - win1->begy, win2->begx - win1->begx,
			0, 0, win2->maxy - 1, win2->maxx - 1, TRUE);
}
예제 #11
0
파일: regedit.c 프로젝트: AIdrifter/samba
static void show_path(struct regedit *regedit)
{
	int start_pad = 0;
	int start_win = PATH_START_X;

	if (PATH_START_X + regedit->path_len > COLS) {
		start_pad = 3 + PATH_START_X + regedit->path_len - COLS;
		mvprintw(PATH_START_Y, start_win, "...");
		start_win += 3;
	}
	copywin(regedit->path_label, regedit->main_window, 0, start_pad,
		PATH_START_Y, start_win, PATH_START_Y, PATH_MAX_Y, false);
}
예제 #12
0
파일: show.c 프로젝트: apprisi/illumos-gate
void
_show(MENU *m)
{
	int r, c;
	WINDOW *us;

	if (Posted(m) || Indriver(m)) {
		(void) mvderwin(Sub(m), Top(m), 0);
		us = US(m);
		getmaxyx(us, r, c);
		r = min(Height(m), r);
		c = min(Width(m), c);
		(void) copywin(Sub(m), us, 0, 0, 0, 0, r-1, c-1, FALSE);
		_position_cursor(m);
	}
}
예제 #13
0
파일: nvramcui.c 프로젝트: 0ida/coreboot
void render_form(FORM *form)
{
	int y, x, line;
	WINDOW *w = form_win(form);
	WINDOW *inner_w = form_sub(form);
	int numlines = getmaxy(w)-2;
	getyx(inner_w, y, x);
	line = y - (y % numlines);
	WINDOW *der = derwin(w, getmaxy(w)-2, getmaxx(w)-2, 1, 1);
	wclear(der);
	wrefresh(der);
	delwin(der);
	copywin(inner_w, w, line, 0, 1, 1, min(numlines, getmaxy(inner_w)-line), 68, 0);
	wmove(w, y + 1 - line, x + 1);
	wrefresh(w);
}
예제 #14
0
void multilist_refresh(struct multilist *list)
{
	int window_start_row, height;

	if (list->nrows == 0) {
		return;
	}

	/* copy from pad, starting at start_row, to the window, accounting
	   for the column header (if present). */
	height = MIN(list->window_height, list->nrows);
	window_start_row = 0;
	if (list->cb->get_column_header) {
		window_start_row = 1;
		if (height < list->window_height) {
			height++;
		}
	}
	copywin(list->pad, list->window, list->start_row, 0,
		window_start_row, 0, height - 1, list->window_width - 1,
		false);
}
예제 #15
0
int
call_raw_draw(PANEL *panel)
{
    call_raw_info_t *info;
    sip_msg_t *msg = NULL;

    // Get panel information
    if(!(info = call_raw_info(panel)))
        return -1;

    if (info->group) {
        // Print the call group messages into the pad
        while ((msg = call_group_get_next_msg(info->group, info->last)))
            call_raw_print_msg(panel, msg);
    } else {
        call_raw_set_msg(info->msg);
    }

    // Copy the visible part of the pad into the panel window
    copywin(info->pad, panel_window(panel), info->scroll, 0, 0, 0, LINES - 1, COLS - 1, 0);
    touchwin(panel_window(panel));
    return 0;
}
예제 #16
0
main()
{
WINDOW *win1, *win2;
int h, i;

	initscr();
	cbreak();
	noecho();
	win1 = newwin(20, 50, 0, 20);
	for (h = 0; h < 20; h++)
		for (i = 0; i < 50; i++)
			mvwaddch(win1, h, i, 'X');
	wrefresh(win1);
	getch();

	win2 = newwin(20, 50, 3, 30);
	for (h = 0; h < 20; h++)
		for (i = 0; i < 50; i++)
			mvwaddch(win2, h, i, 'Y');
	wnoutrefresh(win1);
	wnoutrefresh(win2);
	doupdate();
	getch();

	/* now, remove window 2 and restore the contents of window 1 */
	i = copywin(win1, win2, 5, 10, 0, 0, 14, 39, 0);
	wnoutrefresh(win1);
	wnoutrefresh(win2);
	printw("copywin returns %d\n", i);
	wnoutrefresh(stdscr);
	doupdate();

	getch();

	endwin();
}
예제 #17
0
파일: window.c 프로젝트: waruqi/xmake
WINDOW *resize_window(WINDOW *win, int nlines, int ncols)
{
    WINDOW *new_;
    int i, save_cury, save_curx, new_begy, new_begx;

    PDC_LOG(("resize_window() - called: nlines %d ncols %d\n",
             nlines, ncols));

    if (!win)
        return (WINDOW *)NULL;

    if (win->_flags & _SUBPAD)
    {
        if ( !(new_ = subpad(win->_parent, nlines, ncols,
                            win->_begy, win->_begx)) )
            return (WINDOW *)NULL;
    }
    else if (win->_flags & _SUBWIN)
    {
        if ( !(new_ = subwin(win->_parent, nlines, ncols,
                            win->_begy, win->_begx)) )
            return (WINDOW *)NULL;
    }
    else
    {
        if (win == SP->slk_winptr)
        {
            new_begy = SP->lines - SP->slklines;
            new_begx = 0;
        }
        else
        {
            new_begy = win->_begy;
            new_begx = win->_begx;
        }

        if ( !(new_ = PDC_makenew(nlines, ncols, new_begy, new_begx)) )
            return (WINDOW *)NULL;
    }

    save_curx = min(win->_curx, (new_->_maxx - 1));
    save_cury = min(win->_cury, (new_->_maxy - 1));

    if (!(win->_flags & (_SUBPAD|_SUBWIN)))
    {
        if ( !(new_ = PDC_makelines(new_)) )
            return (WINDOW *)NULL;

        werase(new_);

        copywin(win, new_, 0, 0, 0, 0, min(win->_maxy, new_->_maxy) - 1,
                min(win->_maxx, new_->_maxx) - 1, FALSE);

        for (i = 0; i < win->_maxy && win->_y[i]; i++)
            if (win->_y[i])
                free(win->_y[i]);
    }

    new_->_flags = win->_flags;
    new_->_attrs = win->_attrs;
    new_->_clear = win->_clear;
    new_->_leaveit = win->_leaveit;
    new_->_scroll = win->_scroll;
    new_->_nodelay = win->_nodelay;
    new_->_delayms = win->_delayms;
    new_->_use_keypad = win->_use_keypad;
    new_->_tmarg = (win->_tmarg > new_->_maxy - 1) ? 0 : win->_tmarg;
    new_->_bmarg = (win->_bmarg == win->_maxy - 1) ?
                  new_->_maxy - 1 : min(win->_bmarg, (new_->_maxy - 1));
    new_->_parent = win->_parent;
    new_->_immed = win->_immed;
    new_->_sync = win->_sync;
    new_->_bkgd = win->_bkgd;

    new_->_curx = save_curx;
    new_->_cury = save_cury;

    free(win->_firstch);
    free(win->_lastch);
    free(win->_y);

    *win = *new_;
    free(new_);

    return win;
}
예제 #18
0
/*#DOC*/
int canvas_drawTo(Canvas c, View d, int x, int y)
{
	int w = MIN( view_w(c)-x-1, view_w(d)-1 );
	int h = MIN( view_h(c)-y-1, view_h(d)-1 );
	return copywin(view_win(c), view_win(d), y, x, 0, 0, h, w, 0);
}
예제 #19
0
/* layman's scrollable window... */
void show_scroll_win(WINDOW *main_window,
		const char *title,
		const char *text)
{
	int res;
	int total_lines = get_line_no(text);
	int x, y;
	int start_x = 0, start_y = 0;
	int text_lines = 0, text_cols = 0;
	int total_cols = 0;
	int win_cols = 0;
	int win_lines = 0;
	int i = 0;
	WINDOW *win;
	WINDOW *pad;
	PANEL *panel;

	/* find the widest line of msg: */
	total_lines = get_line_no(text);
	for (i = 0; i < total_lines; i++) {
		const char *line = get_line(text, i);
		int len = get_line_length(line);
		total_cols = max(total_cols, len+2);
	}

	/* create the pad */
	pad = newpad(total_lines+10, total_cols+10);
	wattrset(pad, attributes[SCROLLWIN_TEXT]);
	fill_window(pad, text);

	win_lines = min(total_lines+4, LINES-2);
	win_cols = min(total_cols+2, COLS-2);
	text_lines = max(win_lines-4, 0);
	text_cols = max(win_cols-2, 0);

	/* place window in middle of screen */
	y = (LINES-win_lines)/2;
	x = (COLS-win_cols)/2;

	win = newwin(win_lines, win_cols, y, x);
	keypad(win, TRUE);
	/* show the help in the help window, and show the help panel */
	wattrset(win, attributes[SCROLLWIN_BOX]);
	box(win, 0, 0);
	wattrset(win, attributes[SCROLLWIN_HEADING]);
	mvwprintw(win, 0, 3, " %s ", title);
	panel = new_panel(win);

	/* handle scrolling */
	do {

		copywin(pad, win, start_y, start_x, 2, 2, text_lines,
				text_cols, 0);
		print_in_middle(win,
				text_lines+2,
				0,
				text_cols,
				"<OK>",
				attributes[DIALOG_MENU_FORE]);
		wrefresh(win);

		res = wgetch(win);
		switch (res) {
		case KEY_NPAGE:
		case ' ':
			start_y += text_lines-2;
			break;
		case KEY_PPAGE:
			start_y -= text_lines+2;
			break;
		case KEY_HOME:
			start_y = 0;
			break;
		case KEY_END:
			start_y = total_lines-text_lines;
			break;
		case KEY_DOWN:
		case 'j':
			start_y++;
			break;
		case KEY_UP:
		case 'k':
			start_y--;
			break;
		case KEY_LEFT:
		case 'h':
			start_x--;
			break;
		case KEY_RIGHT:
		case 'l':
			start_x++;
			break;
		}
		if (res == 10 || res == 27 || res == 'q'
		    || res == KEY_F(F_BACK) || res == KEY_F(F_EXIT)) {
			break;
		}
		if (start_y < 0)
			start_y = 0;
		if (start_y >= total_lines-text_lines)
			start_y = total_lines-text_lines;
		if (start_x < 0)
			start_x = 0;
		if (start_x >= total_cols-text_cols)
			start_x = total_cols-text_cols;
	} while (res);

	del_panel(panel);
	delwin(win);
	refresh_all_windows(main_window);
}
예제 #20
0
void outputTest(WINDOW *win)
{
    WINDOW *win1;
    char Buffer[80];
    chtype ch;
    int by, bx;

    nl();
    wclear(win);
    mvwaddstr(win, 1, 1, "You should now have a screen in the upper "
                         "left corner, and this text should have wrapped");
    waddstr(win,"\nThis text should be down\n");
    waddstr(win,  "and broken into two here ^");
    Continue(win);

    wclear(win);
    wattron(win, A_BOLD);
    mvwaddstr(win, 1, 1, "A new window will appear with this text in it");
    mvwaddstr(win, 8, 1, "Press any key to continue");
    wrefresh(win);
    wgetch(win);

    getbegyx(win, by, bx);

    if (LINES < 24 || COLS < 75)
    {
        mvwaddstr(win, 5, 1, "Some tests have been skipped as they require a");
        mvwaddstr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS");
        Continue(win);
    }
    else
    {
        win1 = newwin(10, 50, 14, 25);

        if (win1 == NULL)
        {
            endwin();
            return;
        }

#ifdef A_COLOR
        if (has_colors())
        {
            init_pair(3, COLOR_BLUE, COLOR_WHITE);
            wbkgd(win1, COLOR_PAIR(3));
        }
        else
#endif
            wbkgd(win1, A_NORMAL);

        wclear(win1);
        mvwaddstr(win1, 5, 1, "This text should appear; using overlay option");
        copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE);
        box(win1, ACS_VLINE, ACS_HLINE);
        wmove(win1, 8, 26);
        wrefresh(win1);
        wgetch(win1);

        wclear(win1);

        wattron(win1, A_BLINK);
        mvwaddstr(win1, 4, 1,
                  "This blinking text should appear in only the second window");
        wattroff(win1, A_BLINK);

        mvwin(win1, by, bx);
        overlay(win, win1);
        mvwin(win1, 14, 25);
        wmove(win1, 8, 26);
        wrefresh(win1);
        wgetch(win1);

        delwin(win1);
    }

    clear();
    wclear(win);
    wrefresh(win);
    mvwaddstr(win, 6, 2, "This line shouldn't appear");
    mvwaddstr(win, 4, 2, "Only half of the next line is visible");
    mvwaddstr(win, 5, 2, "Only half of the next line is visible");
    wmove(win, 6, 1);
    wclrtobot(win);
    wmove(win, 5, 20);
    wclrtoeol(win);
    mvwaddstr(win, 8, 2, "This line also shouldn't appear");
    wmove(win, 8, 1);
    winsdelln(win, -1);
    Continue(win);

    wmove(win, 5, 9);
    ch = winch(win);

    wclear(win);
    wmove(win, 6, 2);
    waddstr(win, "The next char should be l:  ");
    winsch(win, ch);
    Continue(win);

    mvwinsstr(win, 6, 2, "A1B2C3D4E5");
    Continue(win);

    wmove(win, 5, 1);
    winsdelln(win, 1);
    mvwaddstr(win, 5, 2, "The lines below should have moved down");
    Continue(win);

    wclear(win);
    wmove(win, 2, 2);
    wprintw(win, "This is a formatted string in a window: %d %s\n",
            42, "is it");
    mvwaddstr(win, 10, 1, "Enter a string: ");
    wrefresh(win);
    echo();
    wscanw(win, "%s", Buffer);

    printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
    mvaddstr(10, 1, "Enter a string: ");
    scanw("%s", Buffer);

    wclear(win);
    curs_set(2);
    mvwaddstr(win, 1, 1, "The cursor should be in high-visibility mode");
    Continue(win);

    wclear(win);
    curs_set(0);
    mvwaddstr(win, 1, 1, "The cursor should have disappeared");
    Continue(win);

    wclear(win);
    curs_set(1);
    mvwaddstr(win, 1, 1, "The cursor should be normal");
    Continue(win);

#ifdef A_COLOR
    if (has_colors())
    {
        wclear(win);
        mvwaddstr(win, 1, 1, "Colors should change after you press a key");
        Continue(win);

        init_pair(1, COLOR_RED, COLOR_WHITE);
        wrefresh(win);
    }
#endif
    werase(win);
    mvwaddstr(win, 1, 1, "Information About Your Terminal");
    mvwaddstr(win, 3, 1, termname());
    mvwaddstr(win, 4, 1, longname());

    if (termattrs() & A_BLINK)
        mvwaddstr(win, 5, 1, "This terminal claims to support blinking.");
    else
        mvwaddstr(win, 5, 1, "This terminal does NOT support blinking.");

    mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16);
    wrefresh(win);

    mvwinnstr(win, 7, 5, Buffer, 18);
    mvaddstr(LINES - 2, 10, Buffer);
    refresh();
    Continue(win);
}
예제 #21
0
mvwin(WINDOW *win, int by, int bx)
{
    T((T_CALLED("mvwin(%p,%d,%d)"), win, by, bx));

    if (!win || (win->_flags & _ISPAD))
	returnCode(ERR);

    /*
     * mvwin() should only modify the indices.  See test/demo_menus.c and
     * test/movewindow.c for examples.
     */
#if 0
    /* Copying subwindows is allowed, but it is expensive... */
    if (win->_flags & _SUBWIN) {
	int err = ERR;
	WINDOW *parent = win->_parent;
	if (parent) {		/* Now comes the complicated and costly part, you should really
				 * try to avoid to move subwindows. Because a subwindow shares
				 * the text buffers with its parent, one can't do a simple
				 * memmove of the text buffers. One has to create a copy, then
				 * to relocate the subwindow and then to do a copy.
				 */
	    if ((by - parent->_begy == win->_pary) &&
		(bx - parent->_begx == win->_parx))
		err = OK;	/* we don't actually move */
	    else {
		WINDOW *clone = dupwin(win);
		if (clone) {
		    /* now we have the clone, so relocate win */

		    werase(win);	/* Erase the original place     */
		    /* fill with parents background */
		    wbkgrnd(win, CHREF(parent->_nc_bkgd));
		    wsyncup(win);	/* Tell the parent(s)           */

		    err = mvderwin(win,
				   by - parent->_begy,
				   bx - parent->_begx);
		    if (err != ERR) {
			err = copywin(clone, win,
				      0, 0, 0, 0, win->_maxy, win->_maxx, 0);
			if (ERR != err)
			    wsyncup(win);
		    }
		    if (ERR == delwin(clone))
			err = ERR;
		}
	    }
	}
	returnCode(err);
    }
#endif

    if (by + win->_maxy > screen_lines - 1
	|| bx + win->_maxx > screen_columns - 1
	|| by < 0
	|| bx < 0)
	returnCode(ERR);

    /*
     * Whether or not the window is moved, touch the window's contents so
     * that a following call to 'wrefresh()' will paint the window at the
     * new location.  This ensures that if the caller has refreshed another
     * window at the same location, that this one will be displayed.
     */
    win->_begy = by;
    win->_begx = bx;
    returnCode(touchwin(win));
}
예제 #22
0
int view_copy(View d, View s, int sx, int sy, int dx, int dy, int dw, int dh) {
	return copywin(view_win(s), view_win(d), sy, sx, dy, dx, dh-1, dw-1, 0);
}
예제 #23
0
/*
 * Update newscr with the given pad.  This allows newscr to
 * be updated with several windows before doing a doupdate().
 *
 * MKS extension permits windows that are not pads to be refreshed
 * using this function.
 */
int
pnoutrefresh(WINDOW *pad, int pminr, int pminc, int sminr, int sminc,
	int smaxr, int smaxc)
{
	WINDOW	*ns;
	int	row, dy, dx;

	ns = __m_screen->_newscr;

	/* Adjust regions to be within bounds. */
	if (pminr < 0)
		pminr = 0;
	if (pminc < 0)
		pminc = 0;
	if (sminr < 0)
		sminr = 0;
	if (sminc < 0)
		sminc = 0;
	if (ns->_maxy <= smaxr)
		smaxr = ns->_maxy-1;
	if (ns->_maxx <= smaxc)
		smaxc = ns->_maxx-1;

	if (pad->_maxy <= pminr || pad->_maxx <= pminc ||
		smaxr < sminr || smaxc < sminc)
		return (ERR);

	/* Clear displayed region. */
	for (row = sminr; row < smaxr; ++row) {
		(void) __m_cc_erase(ns, row, sminc, row, smaxc);
	}

	/*
	 * Determine the proper maximums in case smaxr and smaxc mapped
	 * beyond the bottom and right-hand edges of the pad.
	 */
	if (pad->_maxx <= pminc + smaxc-sminc + 1)
		smaxc = sminc + pad->_maxx - 1 - pminc;
	if (pad->_maxy <= pminr + smaxr-sminr + 1)
		smaxr = sminr + pad->_maxy - 1 - pminr;

	/* Remember refresh region (inclusive). */
	pad->_refy = (short) pminr;
	pad->_refx = (short) pminc;
	pad->_sminy = (short) sminr;
	pad->_sminx = (short) sminc;
	pad->_smaxy = (short) smaxr;
	pad->_smaxx = (short) smaxc;

	(void) copywin(pad, ns, pminr, pminc, sminr, sminc, smaxr, smaxc, 0);

	/* Last refreshed window controls W_LEAVE_CURSOR flag. */
	ns->_flags &= ~W_LEAVE_CURSOR;
	ns->_flags |= pad->_flags &
		(W_CLEAR_WINDOW | W_REDRAW_WINDOW | W_LEAVE_CURSOR);
	pad->_flags &= ~(W_CLEAR_WINDOW | W_REDRAW_WINDOW);

	/* Figure out where to leave the cursor. */
	dy = pad->_cury - pminr + pad->_begy;
	dx = pad->_curx - pminc + pad->_begx;

	ns->_cury = (dy < 0) ? 0 :
		((ns->_maxy <= dy) ? ns->_maxy - 1 : (short) dy);
	ns->_curx = (dx < 0) ? 0 :
		((ns->_maxx <= dx) ? ns->_maxx - 1 : (short) dx);

	return (OK);
}
예제 #24
0
static void
outputTest(WINDOW *win)
{
    WINDOW *win1;
    char Buffer[80];
    chtype ch;
    int by, bx;

#if !HAVE_TIGETSTR
#if HAVE_TGETENT
    char tc_buffer[4096];
    char tc_parsed[4096];
    char *area_pointer = tc_parsed;
    tgetent(tc_buffer, getenv("TERM"));
#else
#define tgetstr(a,b) 0
#endif
#endif /* !HAVE_TIGETSTR */

    nl();
    wclear(win);
    MvWAddStr(win, 1, 1,
	      "You should now have a screen in the upper left corner, and this text should have wrapped");
    mvwin(win, 2, 1);
    waddstr(win, "\nThis text should be down\n");
    waddstr(win, "and broken into two here ^");
    Continue(win);

    wclear(win);
    wattron(win, A_BOLD);
    MvWAddStr(win, 1, 1, "A new window will appear with this text in it");
    MvWAddStr(win, 8, 1, "Press any key to continue");
    wrefresh(win);
    wgetch(win);

    getbegyx(win, by, bx);

    if (LINES < 24 || COLS < 75) {
	MvWAddStr(win, 5, 1,
		  "Some tests have been skipped as they require a");
	MvWAddStr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS");
	Continue(win);
    } else {
	win1 = newwin(10, 50, 14, 25);
	if (win1 == NULL) {
	    endwin();
	    return;
	}
#ifdef A_COLOR
	if (has_colors()) {
	    init_pair(3, COLOR_BLUE, COLOR_WHITE);
	    wbkgd(win1, (chtype) COLOR_PAIR(3));
	} else
	    wbkgd(win1, A_NORMAL);
#else
	wbkgd(win1, A_NORMAL);
#endif
	wclear(win1);
	MvWAddStr(win1, 5, 1,
		  "This text should appear; using overlay option");
	copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE);

#if defined(PDCURSES) && !defined(XCURSES)
	box(win1, 0xb3, 0xc4);
#else
	box(win1, ACS_VLINE, ACS_HLINE);
#endif
	wmove(win1, 8, 26);
	wrefresh(win1);
	wgetch(win1);

	wclear(win1);
	wattron(win1, A_BLINK);
	MvWAddStr(win1, 4, 1,
		  "This blinking text should appear in only the second window");
	wattroff(win1, A_BLINK);
	mvwin(win1, by, bx);
	overlay(win, win1);
	mvwin(win1, 14, 25);
	wmove(win1, 8, 26);
	wrefresh(win1);
	wgetch(win1);
	delwin(win1);
    }

    clear();
    wclear(win);
    wrefresh(win);
    MvWAddStr(win, 6, 2, "This line shouldn't appear");
    MvWAddStr(win, 4, 2, "Only half of the next line is visible");
    MvWAddStr(win, 5, 2, "Only half of the next line is visible");
    wmove(win, 6, 1);
    wclrtobot(win);
    wmove(win, 5, 20);
    wclrtoeol(win);
    MvWAddStr(win, 8, 2, "This line also shouldn't appear");
    wmove(win, 8, 1);
    wdeleteln(win);
    Continue(win);

    wmove(win, 5, 9);
    ch = winch(win);

    wclear(win);
    wmove(win, 6, 2);
    waddstr(win, "The next char should be l:  ");
    winsch(win, ch);
    Continue(win);

#if HAVE_WINSSTR
    (void) mvwinsstr(win, 6, 2, "A1B2C3D4E5");
    Continue(win);
#endif

    wmove(win, 5, 1);
    winsertln(win);
    MvWAddStr(win, 5, 2, "The lines below should have moved down");
    Continue(win);

    wclear(win);
    wmove(win, 2, 2);
    wprintw(win, "This is a formatted string in a window: %d %s\n", 42,
	    "is it");
    MvWAddStr(win, 10, 1, "Enter a string: ");
    wrefresh(win);
    noraw();
    echo();
    *Buffer = 0;
    wscanw(win, "%s", Buffer);

    printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
    MvAddStr(10, 1, "Enter a string: ");
    *Buffer = 0;
    scanw("%s", Buffer);

    if (TIGETSTR("cvvis", "vs") != 0) {
	wclear(win);
	curs_set(2);
	MvWAddStr(win, 1, 1, "The cursor should appear as a block (visible)");
	Continue(win);
    }

    if (TIGETSTR("civis", "vi") != 0) {
	wclear(win);
	curs_set(0);
	MvWAddStr(win, 1, 1,
		  "The cursor should have disappeared (invisible)");
	Continue(win);
    }

    if (TIGETSTR("cnorm", "ve") != 0) {
	wclear(win);
	curs_set(1);
	MvWAddStr(win, 1, 1, "The cursor should be an underline (normal)");
	Continue(win);
    }
#ifdef A_COLOR
    if (has_colors()) {
	wclear(win);
	MvWAddStr(win, 1, 1, "Colors should change after you press a key");
	Continue(win);
	init_pair(1, COLOR_RED, COLOR_WHITE);
	wrefresh(win);
    }
#endif

    werase(win);

#if HAVE_TERMNAME
    MvWAddStr(win, 1, 1, "Information About Your Terminal");
    MvWAddStr(win, 3, 1, termname());
    MvWAddStr(win, 4, 1, longname());
    if (termattrs() & A_BLINK)
	MvWAddStr(win, 5, 1, "This terminal supports blinking.");
    else
	MvWAddStr(win, 5, 1, "This terminal does NOT support blinking.");
#endif

    (void) mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16);
    wrefresh(win);

    (void) mvwinnstr(win, 7, 5, Buffer, 18);
    MvAddStr(LINES - 2, 10, Buffer);
    refresh();
    Continue(win);
}
예제 #25
0
static int
_vdk_surface_blit(vdk_context_t *self,vdk_context_t *target)
{
    int     surface_type;
    int     target_type;
    WINDOW  *output;

    int     max_x;
    int     max_y;

    int     top;
    int     bottom;
    int     left;
    int     right;

	if(self == NULL) return -1;
    if(target == NULL) return -1;

	// ignore operation when state is set to hidden
	if(VDK_SURFACE(self)->state & VDK_SURFACE_HIDDEN) return -1;

    surface_type = vdk_object_get_raster_type(VDK_OBJECT(self));
    target_type = vdk_object_get_raster_type(VDK_OBJECT(target));

    if(target_type != VDK_RASTER_NULL)
    {
        max_x = VDK_RASTER(target)->width - 1;
        max_y = VDK_RASTER(target)->height - 1;

        // return OK if the terminal has been resized to 0 lines or 0 columns
        if(max_x == 0 || max_y == 0) return 0;

        // calculate our target rectangle
        left = VDK_RASTER(self)->rel_x;
        top = VDK_RASTER(self)->rel_y;
        right = VDK_RASTER(self)->rel_x + VDK_RASTER(self)->width - 1;
        bottom = VDK_RASTER(self)->rel_y + VDK_RASTER(self)->height - 1;

        // make sure our target stays on the screen--clipping as needed.
        if(bottom > max_y) bottom = max_y;
        if(right > max_x) right = max_x;

        // make sure top-left wouldn't be off the screen
        if(VDK_RASTER(self)->rel_x > max_x) return -1;
        if(VDK_RASTER(self)->rel_y > max_y) return -1;

        if(target_type == VDK_RASTER_SCR)
            output = stdscr;
        else
            output = *(WINDOW**)target;

        copywin(*((WINDOW**)self),
            output,
            0,0,
            top,left,bottom,right,
            FALSE);

        return 0;
    }

	return 0;
}