Exemplo n.º 1
0
void NWindowEdit::winrefresh ()
{
	int w, h;
	NWindow::winrefresh ();
	getbegyx (window, y, x);
	getmaxyx (window, h, w);
	// window coordinates
	int mwidth = x + w;
	int mheight = y + h;
	if (haveBox ())
	{
		mwidth -= 2;
		mheight -= 1;
	}

	if (pnoutrefresh (getWriteWindow (), 0, 0, y + ey, x + ex, MIN (y + ey + eh, mheight), MIN (x + ex + ew, mwidth)) == ERR)
	{
		if (y > 1 || x > 1)
		{
			if (y + ey + eh > LINES)
				y = 1;
			if (x + ex + ew > COLS)
				x = 1;
			winmove (x, y);
			NWindow::draw ();
			if (pnoutrefresh (getWriteWindow (), 0, 0, y + ey, x + ex, MIN (y + ey + eh, mheight), MIN (x + ex + ew, mwidth)) != ERR)
				return;
		}
		errorMove ("pnoutrefresh comwin", y + ey, x + ex,
			MIN (y + ey + eh, mheight), MIN (x + ex + ew, mwidth));
	}
}
Exemplo n.º 2
0
coordinate&
coordinate::set(coordinate_type type, dummy_window& r_win)
{
  switch (type)
  {
    case Absolutecoord:
    	getyx(r_win.get_WINDOW(), y, x);
	break;

    case Relativecoord:
    	getparyx(r_win.get_WINDOW(), y, x);
	break;

    case Beginningcoord:
       	getbegyx(r_win.get_WINDOW(), y, x);
	break;

    case windowSize:
    	getmaxyx(r_win.get_WINDOW(), y, x);
	break;

    default:
	set(type);
  }

  return *this;
}
Exemplo n.º 3
0
/*
 * test mvderwin().
 */
static bool
move_subwin(WINDOW *win)
{
    WINDOW *parent = parent_of(win);
    bool result = FALSE;

    if (parent != 0) {
	bool top = (parent == stdscr);
	if (!top) {
	    int min_col = top ? COL_MIN : 0;
	    int max_col = top ? COL_MAX : getmaxx(parent);
	    int min_line = top ? LINE_MIN : 0;
	    int max_line = top ? LINE_MAX : getmaxy(parent);
	    PAIR *tmp;

	    head_line("Select new position for subwindow");

	    if ((tmp = selectcell(parent,
				  min_line, min_col,
				  max_line, max_col)) != 0) {
		int y0, x0;
		getbegyx(parent, y0, x0);
		if (mvderwin(win, y0 + tmp->y, x0 + tmp->x) != ERR) {
		    refresh_all(win);
		    doupdate();
		    result = TRUE;
		}
	    }
	}
    }
    return result;
}
Exemplo n.º 4
0
int move_panel(PANEL *pan, int starty, int startx)
{
    WINDOW *win;
    int maxy, maxx;

    if (!pan)
        return ERR;

    if (_panel_is_linked(pan))
        _override(pan, 0);

    win = pan->win;

    if (mvwin(win, starty, startx) == ERR)
        return ERR;

    getbegyx(win, pan->wstarty, pan->wstartx);
    getmaxyx(win, maxy, maxx);
    pan->wendy = pan->wstarty + maxy;
    pan->wendx = pan->wstartx + maxx;

    if (_panel_is_linked(pan))
        _calculate_obscure();

    return OK;
}
Exemplo n.º 5
0
//------------------------------------------------------------------------------
int replace_panel( PANEL* pan, WINDOW* win )
{
	__QCS_FCONTEXT( "replace_panel" );

    int maxy, maxx;

    if( !pan )
	{
        return ERR;
	}

    if( _panel_is_linked( pan ) )
	{
        _override( pan, 0 );
	}

    pan->win = win;
    getbegyx( win, pan->wstarty, pan->wstartx );
    getmaxyx( win, maxy, maxx );
    pan->wendy = pan->wstarty + maxy;
    pan->wendx = pan->wstartx + maxx;

    if( _panel_is_linked( pan ) )
	{
		_calculate_obscure();
	}

    return 0;
}
Exemplo n.º 6
0
void Engine::render() {
	//Get screen dimensions
	int screen_min_x, screen_min_y, screen_max_x, screen_max_y;
	getbegyx(stdscr, screen_min_y, screen_min_x);
	getmaxyx(stdscr, screen_max_y, screen_max_x);

	//The status bar may exist at some point! Here are some placeholder values.
	int status_bar_size = 0;
	int status_bar_top_size = 0;

	//The view is going to be constantly centered on the player.
	//These variables should help with math.
	int view_offset_x = (screen_max_x - screen_min_x) / 2 - player->getX();
	int view_offset_y = (screen_max_y - screen_min_y) / 2 - player->getY();

	//Draw objects
	for(std::size_t i = 0; i < object_list.size(); i++) {
		//Only draw the object if it's on the screen.
		if(	object_list.at(i)->getY() + view_offset_y < screen_max_y - status_bar_size &&
			object_list.at(i)->getY() + view_offset_y > screen_min_y + status_bar_top_size &&
			object_list.at(i)->getX() + view_offset_x < screen_max_x &&
			object_list.at(i)->getX() + view_offset_x > screen_min_x) {

			mvaddch(
				object_list.at(i)->getY() + view_offset_y,
				object_list.at(i)->getX() + view_offset_x,
				object_list.at(i)->render()
			);
		}
	}

	//Draw cursor
	curs_set(0);
	drawPointer(0, 0);
}
Exemplo n.º 7
0
/* Set the PANEL_DATA structures for individual panels */
void set_user_ptrs(PANEL **panels, int n)
{   PANEL_DATA *ptrs;
    WINDOW *win;
    int x, y, w, h, i;
    char temp[80];
    
    ptrs = (PANEL_DATA *)calloc(n, sizeof(PANEL_DATA));

    for(i = 0;i < n; ++i)
    {   win = panel_window(panels[i]);
        getbegyx(win, y, x);
        getmaxyx(win, h, w);
        ptrs[i].x = x;
        ptrs[i].y = y;
        ptrs[i].w = w;
        ptrs[i].h = h;
        sprintf(temp, "Window Number %d", i + 1);
        strcpy(ptrs[i].label, temp);
        ptrs[i].label_color = i + 1;
        if(i + 1 == n)
            ptrs[i].next = panels[0];
        else
            ptrs[i].next = panels[i + 1];
        set_panel_userptr(panels[i], &ptrs[i]);
    }
}
Exemplo n.º 8
0
void gettextinfo(struct text_info *inforec)
{
   unsigned char xp,yp;
   unsigned char x1,x2,y1,y2;
   unsigned char cols,lines;
   unsigned char dattr,dnattr,a; /* The "d" stands for DOS */

   attr_store_type store_a_attr;

   if (initialized==0) init_lconio();
   getyx(conio_scr,yp,xp);
   getbegyx(conio_scr,y1,x1);
   getmaxyx(conio_scr,y2,x2);
   dattr=(bgc*16)+fgc;
   a = wattr_get(conio_scr,&store_a_attr.attrs,&store_a_attr.color_pair,&store_a_attr.opts);

   if (a==(a & A_BLINK)) dattr=dattr+128;
   dnattr=oldattr;  /* Well, this cannot be right, 
                       because we don't know the COLORPAIR values from before init_lconio() !*/
   inforec->winleft=x1+1;
   inforec->wintop=y1+1;
   if (x1==0) x2--;
   if (y1==0) y2--;
   inforec->winright=x1+x2+1;
   inforec->winbottom=y1+y2+1;
   inforec->curx=xp+1;
   inforec->cury=yp+1;
   inforec->screenheight=y2+1;
   inforec->screenwidth=x2+1;
   inforec->currmode=3; /* This is C80 */
   inforec->normattr=dnattr; /* Don't use this ! */
   inforec->attribute=dattr;
} 
Exemplo n.º 9
0
Arquivo: tduint.c Projeto: dse/tdu
void
tdu_interface_compute_visible_lines ()
{
	int bx, by, ex, ey;
	getbegyx(main_window, by, bx);
	getmaxyx(main_window, ey, ex);
	visible_lines = ey - by;
}
Exemplo n.º 10
0
bool NWindowEdit::setCursor ()
{
	getbegyx (getWriteWindow (), y, x);
	x += getCurX ();
	y += getCurY ();
	setsyx (y, x);
	return true;
}
Exemplo n.º 11
0
int main (const int argc, const char * const * argv)
{
	if (argc < 2)
	{
		Gtfo (__LINE__, "読み取るパッドが渡されませんでした。");
	}

	initscr ();
	keypad (stdscr, TRUE);
	noecho ();
	start_color ();
	curs_set (0);

	int nMaxY, nMaxX;
	getmaxyx (stdscr, nMaxY, nMaxX);
	nMaxY--;
	nMaxX--;

	FILE * file = fopen (argv[1], "r");
	if (file == NULL)
	{
		Gtfo (__LINE__, "%sを読み取れませんでした。", argv[1]);
	}

	// Load window and store dimensions.
	WINDOW * pad = getwin (file);
	int nPadH, nPadW;
	getmaxyx (pad, nPadH, nPadW);
	int nPadBegY, nPadBegX;
	getbegyx (pad, nPadBegY, nPadBegX);
	nPadH -= nPadBegY;
	nPadW -= nPadBegX;

	bool bEnd = false;
	unsigned uPosY = 0;
	while (!bEnd)
	{
		int n = getch ();
		switch (n)
		{
			case 'j':
				if (! (uPosY + 1 + nMaxY >= nPadH))
					uPosY++;
				break;
			case 'k':
				if (uPosY)
					uPosY--;
				break;
			case 'q':
				bEnd = true;
				break;
		}
		prefresh (pad, uPosY, 0, 0, 0, nMaxY, nMaxX);
	}

	endwin ();
}
Exemplo n.º 12
0
SCM
gucu_getbegyx (SCM win)
{
  int y, x;

  getbegyx (_scm_to_window (win), y, x);

  return (scm_list_2 (scm_from_int (y), scm_from_int (x)));
}
void initialize_display()
{
	// Start curses mode
	initscr();

	// Get screen/window size
	getbegyx(stdscr, min_y, min_x);
	getmaxyx(stdscr, max_y, max_x);
}
Exemplo n.º 14
0
static void pad_refresh(struct config_screen *screen)
{
	int y, x, rows, cols;

	getmaxyx(screen->scr.sub_ncw, rows, cols);
	getbegyx(screen->scr.sub_ncw, y, x);

	prefresh(screen->pad, screen->scroll_y, 0, y, x, rows, cols);
}
Exemplo n.º 15
0
static void pad_refresh(struct boot_editor *boot_editor)
{
	int y, x, rows, cols;

	getmaxyx(boot_editor->scr.sub_ncw, rows, cols);
	getbegyx(boot_editor->scr.sub_ncw, y, x);

	prefresh(boot_editor->pad, boot_editor->scroll_y, 0,
			y, x, rows, cols);
}
Exemplo n.º 16
0
//THIS CREATES ALL THE ENEMIES AND DROPS ALL ENEMIES ONE UNIT DOWN. ALSO CHECKS FOR PLAYER DEATH CONDITION
int drop_enemy(int *address_score,int player_y,int player_x)
{
	//increases the score
	(*address_score)++;
	time_t t;
	//this is an array of windows where each enemy is represented by a window
	static WINDOW *enemies[100];
	static int enemy_num=0;
	static int i=0;
	int j,x,y;

	srand((unsigned) time(&t));
	
				   
	//just creating the enemies the first time (create 2 enemies at a time)   
	if (enemy_num<81)
	{
		enemies[enemy_num]=create_enemywin(0,rand()%COLS); 
		enemies[++enemy_num]=create_enemywin(0,rand()%COLS); 
		enemy_num++;
	}
	//after the enemies have been created for the first time
	else
	{
		//destroy the enemy windows when they reach the bottom of the screen and recreate them at random positions at the top (2 at a time)
		destroy_win(enemies[i]);
		destroy_win(enemies[i+1]);
		enemies[i]=create_enemywin(0,rand()%COLS);  
		enemies[i+1]=create_enemywin(0,rand()%COLS);  
		i=i+2;
		if (i==80)
		{
			i=0;
		}
	}
	
	//move all enemy windows 2 spaces down by destroying them and recreating them 2 spaces down
	for (j=0;j<=enemy_num;j++)
	{
		getbegyx(enemies[j],y,x);
		//checks for player collision with enemies
		if ((player_x<x+7) && (player_x>x-5) && (player_y<=y+5) && (player_y>=y-3))
		{
			return 1;
		}
		destroy_win(enemies[j]);
		enemies[j]=create_enemywin(y+2,x); 
	}

	refresh();
	return 0;
}
Exemplo n.º 17
0
/* Show the window with a border and a label */
void win_show(WINDOW *win, char *label, int label_color)
{	int startx, starty, height, width;

	getbegyx(win, starty, startx);
	getmaxyx(win, height, width);

	box(win, 0, 0);
	mvwaddch(win, 2, 0, ACS_LTEE); 
	mvwhline(win, 2, 1, ACS_HLINE, width - 2); 
	mvwaddch(win, 2, width - 1, ACS_RTEE); 
	
	print_in_middle(win, 1, 0, width, label, COLOR_PAIR(label_color));
}
Exemplo n.º 18
0
WINDOW *winputbox(WINDOW *win, int nlines, int ncols)
{
    WINDOW *winp;
    int cury, curx, begy, begx;

    getyx(win, cury, curx);
    getbegyx(win, begy, begx);

    winp = newwin(nlines, ncols, begy + cury, begx + curx);
    colorbox(winp, INPUTBOXCOLOR, 1);

    return winp;
}
Exemplo n.º 19
0
int get_car_with_mouse(int y, int x, WINDOW** winCar, int nbPieces)
{
    for (int i = 0; i < nbPieces; i++) {
        int miny, minx, maxx, maxy;
        getbegyx(winCar[i], miny, minx); //Don't need to pass address because it's a macro
        getmaxyx(winCar[i], maxy, maxx); //Don't need to pass address because it's a macro
        if (x >= minx && x <= minx + maxx &&
                y >= miny && y <= miny + maxy) {
            return i;
        }
    }
    return -1;
}
Exemplo n.º 20
0
static void
init_status(WINDOW *win, STATUS * sp)
{
    memset(sp, 0, sizeof(*sp));
    sp->c = 99;
    sp->v = 99;
    sp->ch = ' ';

    keypad(win, TRUE);
    fill_window(win);

    getbegyx(win, sp->y_beg, sp->x_beg);
    getmaxyx(win, sp->y_max, sp->x_max);
}
Exemplo n.º 21
0
/**
 * take_bkgrnd -- modify a color pair so that it has the same bg as src 
 * @dst: the window which will be rendered with the new color pair
 * @src: the window whose background is to be taken
 * @pair: the color pair to be re-initialized with the new combination
 */
void take_bkgrnd(WINDOW *dst, WINDOW *src, short pair)
{
        short src_bg;
        short dst_fg;
        int y, x;

        getbegyx(dst, y, x);

        dst_fg = fgcolor(pair); 
        src_bg = bgcolor_yx(src, y, x);

        /* Re-init pair with src background */
        init_pair(pair, dst_fg, src_bg);
}
Exemplo n.º 22
0
/*
 * test mvwin().
 */
static bool
move_window(WINDOW *win, bool recur)
{
    WINDOW *parent = parent_of(win);
    bool result = FALSE;

    if (parent != 0) {
	bool top = (parent == stdscr);
	int min_col = top ? COL_MIN : 0;
	int max_col = top ? COL_MAX : getmaxx(parent);
	int min_line = top ? LINE_MIN : 0;
	int max_line = top ? LINE_MAX : getmaxy(parent);
	PAIR *tmp;
	bool more;

	head_line("Select new position for %swindow", top ? "" : "sub");

	while ((tmp = selectcell(parent,
				 win,
				 min_line, min_col,
				 max_line, max_col,
				 FALSE,
				 &more)) != 0) {
	    int y0, x0;
	    getbegyx(parent, y0, x0);
	    /*
	     * Moving a subwindow has the effect of moving a viewport around
	     * the screen.  The parent window retains the contents of the
	     * subwindow in the original location, but the viewport will show
	     * the contents (again) at the new location.  So it will look odd
	     * when testing.
	     */
	    if (mvwin(win, y0 + tmp->y, x0 + tmp->x) != ERR) {
		if (recur) {
		    recur_move_window(win, tmp->y, tmp->x);
		}
		refresh_all(win);
		doupdate();
		result = TRUE;
	    } else {
		result = FALSE;
	    }
	    if (!more)
		break;
	}
    }
    head_line("done");
    return result;
}
Exemplo n.º 23
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;
}
Exemplo n.º 24
0
static void
recur_move_window(WINDOW *parent, int dy, int dx)
{
    unsigned n;

    for (n = 0; n < num_windows; ++n) {
	if (all_windows[n].parent == parent) {
	    int y0, x0;

	    getbegyx(all_windows[n].child, y0, x0);
	    mvwin(all_windows[n].child, y0 + dy, x0 + dx);
	    recur_move_window(all_windows[n].child, dy, dx);
	}
    }
}
Exemplo n.º 25
0
/* Show the window with a border and a label */
void
mostrar_ventana (WINDOW * win, char *label, int label_color)
{
  int startx, starty, height, width;

  getbegyx (win, starty, startx);
  getmaxyx (win, height, width);

  box (win, 0, 0);
  mvwaddch (win, 2, 0, ACS_LTEE);
  mvwhline (win, 2, 1, ACS_HLINE, width - 2);
  mvwaddch (win, 2, width - 1, ACS_RTEE);

  imprimir_centrao (win, 1, 0, width, label, COLOR_PAIR (label_color));
}
Exemplo n.º 26
0
// returns a FRUIT if one is found on the given point, else NULL
FRUIT *fruit_is_on(FRUITS *fruits, int posy, int posx) {
  int i;
  int y,x;

  // iterate each fruit
  for(i = 0; i < fruits->length; i++) {
    // read the position of the current fruit
    getbegyx(fruits->fruits[i].win, y, x);
    // check if the positions are matching
    if(posy == y && posx == x) {
      // return a pointer to the current fruit
      return &fruits->fruits[i];
    }
  }
  return NULL;
}
Exemplo n.º 27
0
    void backspace(FILE *fp, char * filename, int curr, int end)
    {
				long lSize,y,x;
                char * buffer1=NULL, *buffer2=NULL;
        if(curr==end)
		{
			ftruncate(fileno(fp),ftell(fp)-1);
			erase();
			read_file(fp);
		}
		else
		{
                lSize = end - curr;//length from where you want to insert the chars and the eof
                buffer1 = (char*) malloc(sizeof(char) * (curr-1));
                buffer2 = (char*) malloc(sizeof(char) * lSize);
				if(buffer1!=NULL)
				{
				fseek(fp,0,SEEK_SET);
                fread(buffer1, sizeof(char), curr-1, fp);//Read from the beginning of the file till curr-1
				}
                if(buffer2!=NULL)
				{
                    fseek(fp, curr, SEEK_SET);//current "position" in the file
                    fread(buffer2,sizeof(char), lSize, fp);//fread (end - map) into buffer
				}
                fseek(fp,0,SEEK_SET);//move to begining of the file
                if(buffer1!=NULL)
				    fwrite(buffer1,sizeof(char),sizeof(buffer1),fp);//fwrite the buffer
                fseek(fp,curr-1,SEEK_SET);
                if(buffer2!=NULL)
				    fwrite(buffer2,sizeof(char),sizeof(buffer2),fp);//fwrite the buffer
                fseek(fp,0,SEEK_END);
                /*Fix for the meta characters at the end of the file*/
			    ftruncate(fileno(fp),ftell(fp)-1);
                erase();
                read_file(fp);
		        getbegyx(stdscr,y,x);
		        move(y,x+curr-1);
                refresh();
                free(buffer1);
                free(buffer2);
                buffer1=NULL;
                buffer2=NULL;
		}
		
    }
Exemplo n.º 28
0
// check if a part of the snake is on the given spot
// returns a WINDOW * if one is found, NULL if not
WINDOW *snake_part_is_on(SNAKE *snake, int posy, int posx) {
  int i;
  int cury, curx; // position of the current snake part we are iterating

  // iterate each part
  for(i = 0; i < snake->length; i++) {
    // get the position of the current part
    getbegyx(snake->parts[i], cury, curx);

    // compare the position
    if(cury == posy && curx == posx) {
      // return the current part
      return snake->parts[i];
    }
  }

  return NULL;
}
Exemplo n.º 29
0
void showPanel(struct panelw *panel, char *label)
{
    int startx, starty, x, y, h, w, len;

    getbegyx(panel->win, starty, startx);
    getmaxyx(panel->win, h, w);

    box(panel->win, 0, 0);

    snprintf(panel->title, 100, "%s", label);
    len = strlen(panel->title);
    x = ((w - len) / 2);
    y = 0;
    mvwprintw(panel->win, y, x, "%s", panel->title);
    show_panel(panel->panel);
    update_panels();
    refresh();
}
Exemplo n.º 30
0
static struct view *
find_clicked_view(MEVENT *event)
{
	struct view *view;
	int i;

	foreach_displayed_view (view, i) {
		int beg_y = 0, beg_x = 0;

		getbegyx(view->win, beg_y, beg_x);

		if (beg_y <= event->y && event->y < beg_y + view->height
		    && beg_x <= event->x && event->x < beg_x + view->width) {
			if (i != current_view) {
				current_view = i;
			}
			return view;
		}
	}