Пример #1
0
//удаление клиента с указанного номера позиции
void RemoveClient(int pos)
{
    int i,p;
    p=pos;
    char c,st='q';
    //начиная с заданной позиции просто циклически затираем текущую строку нижней
    while(st!=' ')
    {
        wmove(mpanel[1],p,1);
        for(i=1;;i++)
        {
            c=mvwinch(mpanel[1],p+1,i);
            wmove(mpanel[1],p,i);
            wprintw(mpanel[1],"%c",c);
            if(c==' ')
            {
                wprintw(mpanel[1],"    ");
                break;
            }
        }
        p++;
        st=mvwinch(mpanel[1],p,1);
    }
    wrefresh(mpanel[1]);
}
Пример #2
0
// 属性と色を変える
//
void CWindows::chg_attr_color(int x, int y, long attr, int cpair)
{
	chtype ch1 = mvwinch(m_this, y, adjx(x))	& A_CHARTEXT;
	chtype ch2 = mvwinch(m_this, y, adjx(x) + 1)	& A_CHARTEXT;

	wattrset(m_this, attr | COLOR_PAIR(cpair));

	mvwaddch(m_this, y, adjx(x),     ch1);
	mvwaddch(m_this, y, adjx(x) + 1, ch2);
}
Пример #3
0
void normal_set(int r, int c)
{
	char h, l;
	
	h = ((mvwinch(set_win,(r+1),((c*2)+1))) & A_CHARTEXT);
	l = ((mvwinch(set_win,(r+1),((c*2)+2))) & A_CHARTEXT);
	wattroff(set_win,A_REVERSE);
	mvwprintw(set_win,(r+1),((c*2)+1),"%c%c",h,l);
	wmove(set_win,(r+1),((c*2)+1));
}
Пример #4
0
// 属性は変えずに色を変える
//
void CWindows::chg_color(int x, int y, int cpair)
{
	chtype ch1 = mvwinch(m_this, y, adjx(x))	| !A_COLOR;
	chtype ch2 = mvwinch(m_this, y, adjx(x) + 1)	| !A_COLOR;

	ch1 += COLOR_PAIR(cpair);
	ch2 += COLOR_PAIR(cpair);

	mvwaddch(m_this, y, adjx(x),     ch1);
	mvwaddch(m_this, y, adjx(x) + 1, ch2);
}
Пример #5
0
// 色は変えずに属性を変える
//
void CWindows::chg_attr(int x, int y, long attr)
{
	chtype ch1 = mvwinch(m_this, y, adjx(x))	& A_CHARTEXT;
	chtype ch2 = mvwinch(m_this, y, adjx(x) + 1)	& A_CHARTEXT;
	chtype ch1c = mvwinch(m_this, y, adjx(x))	& A_COLOR;

	wattrset(m_this, attr | ch1c);

	mvwaddch(m_this, y, adjx(x),     ch1);
	mvwaddch(m_this, y, adjx(x) + 1, ch2);
}
Пример #6
0
void *move_player(void *i)	// routine run by the player thread to move the player
{
    int ch, pposx, pposy;
    playerposx = 15; playerposy = 10;
    while (1) {
        pposy = playerposy;
        pposx = playerposx;
        ch = getch();
        switch (ch) {
        case KEY_UP:
            if (playerposy > 1) playerposy--;
            break;
        case KEY_DOWN:
            if (playerposy < 20) playerposy++;
            break;
        case KEY_LEFT:
            if (playerposx > 1) playerposx--;
            break;
        case KEY_RIGHT:
            if (playerposx < 30) playerposx++;
            break;
        }
        pthread_mutex_lock(&mutex);
        if ((mvwinch(battle_win, playerposy, playerposx)) != ' ') lose = 0; // COLLISION! BUT THIS TIME YOU DID IT!
        mvwaddch(battle_win, pposy, pposx, ' ');
        mvwaddch(battle_win, playerposy, playerposx, '@');
        wrefresh(battle_win);
        pthread_mutex_unlock(&mutex);
    }
}
static void flip_pixel(int x, int y, chip_8_cpu cpu) {
    int scr_height, scr_width;
    getmaxyx(stdscr, scr_height, scr_width);
    int max_height = (default_window_height < scr_height) ? default_window_height : scr_height;
    int max_width = (default_window_width < scr_width) ? default_window_width : scr_width;
    int draw_x = x + 1;
    int draw_y = y + 1;
    while (draw_x >= max_width) {
        draw_x -= max_width;
    }
    if (draw_x == 0) {
        draw_x = 1;
    }
    if (draw_x == max_width) {
        draw_x = max_width - 1;
    }

    // https://www.mkssoftware.com/docs/man3/curs_inch.3.asp
    chtype char_info = mvwinch(cpu->chip_8_screen, draw_y, draw_x);
    char char_at = char_info & A_CHARTEXT;

    char new_pixel = (char_at == ACTIVE_PIXEL) ? INACTIVE_PIXEL : ACTIVE_PIXEL;
    mvwaddch(cpu->chip_8_screen, draw_y, draw_x, new_pixel);
    set_vf_if(char_at == ACTIVE_PIXEL, cpu);

    refresh_window(cpu->chip_8_screen);
}
Пример #8
0
void delete_user (pid_t pid_name) {
    int name,i,c,int_name;
    char r[getmaxx(user_list)-2];
    int_name=(int)pid_name; // приводим ПИД к Int (???)
    /*Считываем поочерёдно номера текущих пользователей в чате в строку*/
    for (i=0;i<=(getmaxy(user_list));i++){
        wmove(user_list,i,0);
        for (c=0;c<=getmaxx(user_list);c++){
            r[c]=mvwinch(user_list,i,c);

        }
        name=atoi(r); // приводим строку к INT
        /*если номер совпадает, то удаляем пользователя и подтягиваем список вверх*/
        if (name==int_name) {
            wdeleteln(user_list);
            wrefresh(user_list);
            y_ptr_list--;
            return;

        }
    }

    return;


}
/*
 * whgtchk:
 *	See if the hero can carry his pack
 */
void
wghtchk(void)
{
    reg int dropchk, err = TRUE;
    reg int ch;

    inwhgt = TRUE;
    if (pstats.s_pack > pstats.s_carry) {
        ch = CCHAR( mvwinch(stdscr, hero.y, hero.x) );
        if((ch != FLOOR && ch != PASSAGE)) {
            extinguish(wghtchk);
            fuse(wghtchk,(void *)TRUE,1,AFTER);
            inwhgt = FALSE;
            return;
        }
        extinguish(wghtchk);
        msg("Your pack is too heavy for you.");
        do {
            dropchk = drop(NULL);
            if(dropchk == 0) {
                mpos = 0;
                msg("You must drop something.");
            }
            if(dropchk == TRUE)
                err = FALSE;
        } while(err);
    }
    inwhgt = FALSE;
}
Пример #10
0
//выделение директории
//на вход функции: номер  панели, номер позиции относительно верха
//режим 1 - выделение, 0 - развыделение
void SelectDir(int mngnum,int pos,int mode)
{
    char *name;
    int len,i;
    len=getmaxx(mng[mngnum]);
    name=(char*)calloc(len,sizeof(char));
    if(name==NULL)
    {
        perror("bad calloc\n");
        exit(EXIT_FAILURE);
    }
    //забираем все символы
    for(i=1;i<(len-1);i++)
    {
        name[i-1]=mvwinch(mng[mngnum],pos,i);
    }
    //перепечатываем с нyжным цветом
    if(mode)
    {
        wattron(mng[mngnum],COLOR_PAIR(2)| A_BOLD);
    }
    else
    {
        wattron(mng[mngnum],COLOR_PAIR(1)| A_BOLD);
    }
    wmove(mng[mngnum],pos,1);
    wprintw(mng[mngnum],name);
    wattron(mng[mngnum],COLOR_PAIR(1)| A_BOLD);
    wrefresh(mng[mngnum]);
    free(name);
}
Пример #11
0
void
dlg_trace_win(WINDOW *win)
{
    if (myFP != 0) {
	int y, x;
	int j, k;
	int rc = getmaxy(win);
	int cc = getmaxx(win);
	chtype ch, c2;

	fprintf(myFP, "window %dx%d at %d,%d\n",
		rc, cc, getbegy(win), getbegx(win));

	getyx(win, y, x);
	for (j = 0; j < rc; ++j) {
	    fprintf(myFP, "%3d:", j);
	    for (k = 0; k < cc; ++k) {
		ch = mvwinch(win, j, k) & (A_CHARTEXT | A_ALTCHARSET);
		c2 = dlg_asciibox(ch);
		if (c2 != 0) {
		    ch = c2;
		} else if (unctrl(ch) == 0 || strlen(unctrl(ch)) > 1) {
		    ch = '.';
		}
		fputc((int) (ch & 0xff), myFP);
	    }
	    fputc('\n', myFP);
	}
	wmove(win, y, x);
	fflush(myFP);
    }
}
Пример #12
0
int len(int lin,int line,WINDOW * win)
{
	int linelen = line;
	while (linelen >= 0 && mvwinch(win,lin,linelen) == ' ')
		linelen--;
	return linelen;
}
Пример #13
0
void window_modify_border(WINDOW *window,gint attrs,gshort colors)
{
	chtype	char_attr;
	gint	width,height;
	gint	x,y;
	
	if(window==NULL) return;
	
	getmaxyx(window,height,width);
	
	for(y=0;y<height+1;y++)
	{
		for(x=0;x<width+1;x++)
		{
			if((x%(width-1)==0) || (y%(height-1)==0))
			{
				char_attr=mvwinch(window,y,x);
				if((char_attr & A_ALTCHARSET)==A_ALTCHARSET)
			 		mvwchgat(window,y,x,1,attrs | A_ALTCHARSET,colors,NULL);
				else mvwchgat(window,y,x,1,attrs,colors,NULL);
			}
		}
	}
	
	return;
}
Пример #14
0
void save_file(WINDOW * win)
{
	int fd;
	if ((fd = open(dir,O_RDWR|O_CREAT|O_TRUNC,S_IRWXO|S_IRWXU|S_IRWXG)) == -1)
	{
		perror("Can't open!");
		exit(1);
	}
	int i,j,row,col,n,res;
	char  ch[1];
	getmaxyx(win,row,col);
	for (i=1;i<row-1;i++)
	{
		n = len(i,col-2,win);
		for (j=1;j<n;j++)
		{
			ch[0] = mvwinch(win,i,j);
			if ((res = write(fd,ch,1) == -1))
			{
				perror("Can't write file");
				exit(1);
			}
		}
		ch[0] = '\n';
		write(fd,ch,1);
	}
	close(fd);
}
Пример #15
0
//проверка наличия клиента
//на входе pid клиента, на выходе 0 при отсутствии такого и позиция записи при
//нахождении
int CheckClient(long pid)
{
    int pos,i;
    long cmp;
    char str[10];
    for(pos=1;;pos++)
    {
        for(i=1;i<10;i++)
        {
            str[i-1]=mvwinch(mpanel[1],pos,i);
            if(str[0]==' ')
            {
                return 0; //такого клиента нет
            }
            if(str[i-1]==':')
            {
                str[i-1]='\0';
                break;
            }
        }
        cmp=atol(str);
        if(cmp==pid)
        {
            return pos;
        }

    }

}
Пример #16
0
void save(WINDOW *wnd, char str[100])
{
   int fd,l,n,i,nwritten;
   char ch[1];
   if((fd = open( str, O_RDWR))==-1)
   {
      perror("can't open file1");
      exit(1);
   }
   for (l = 1; l < LINES - 4; l++) 
   {
      n = len(l);
      for (i = 1; i < n; i++)
      {
         ch[0]=mvwinch(wnd,l,i);
         if ((nwritten = write(fd,ch,1)==-1))
         {
            perror("can't write file2");
            exit(1);
         }
      }
      ch[0]='\n';
         if ((nwritten = write(fd,ch,1)==-1))
         {
            perror("can't write file3");
            exit(1);
         }
   }
   close(fd);
};
/*
 * do the actual motion on the screen done by an object traveling
 * across the room
 */
void
do_motion(struct object *obj, int ydelta, int xdelta, struct thing *tp)
{

	/*
	* Come fly with us ...
	*/
	obj->o_pos = tp->t_pos ;
	for ( ; ;) {
		register int ch ;
		/*
		* Erase the old one
		*/
		if (!ce(obj->o_pos, tp->t_pos) &&
		    cansee(unc(obj->o_pos)) &&
		    mvwinch(cw, obj->o_pos.y, obj->o_pos.x) != ' ') {
			mvwaddch(cw, obj->o_pos.y, obj->o_pos.x, show(obj->o_pos.y, obj->o_pos.x)) ;
		}
		/*
		* Get the new position
		*/
		obj->o_pos.y += ydelta ;
		obj->o_pos.x += xdelta ;
		if (shoot_ok(ch = winat(obj->o_pos.y, obj->o_pos.x)) && ch != DOOR && !ce(obj->o_pos, hero)) {
			/*
			* It hasn't hit anything yet, so display it
			* If it alright.
			*/
			if (cansee(unc(obj->o_pos)) &&
			    mvwinch(cw, obj->o_pos.y, obj->o_pos.x) != ' ') {
				mvwaddch(cw, obj->o_pos.y, obj->o_pos.x, obj->o_type) ;
				draw(cw) ;
			}
			continue ;
		}
		/* don't want objects to end up in wall, or fall through
		 * so back it up.
		 */
		if (ch == '|' || ch == '-' || ch == SECRETDOOR || ch == ' ')
			{
			obj->o_pos.y -= ydelta ;
			obj->o_pos.x -= xdelta ;
			}
			
		break ;
	}
}
Пример #18
0
coord
do_motion(int ob, int ydelta, int xdelta, struct thing *tp)
{
    coord pos;
    /* Come fly with us ... */

    pos = tp->t_pos;

    for (;;)
    {
        int ch;

        /* Erase the old one */

        if (!ce(pos, tp->t_pos) &&
            cansee(pos.y, pos.x) &&
            mvwinch(cw, pos.y, pos.x) != ' ')
        {
            mvwaddch(cw, pos.y, pos.x, show(pos.y, pos.x));
        }

        /* Get the new position */

        pos.y += ydelta;
        pos.x += xdelta;

        if (shoot_ok(ch = winat(pos.y, pos.x)) &&
            ch != DOOR && !ce(pos, hero))
        {
            /* It hasn't hit anything yet, so display it if it alright. */

            if (cansee(pos.y, pos.x) &&
                mvwinch(cw, pos.y, pos.x) != ' ')
            {
                mvwaddch(cw, pos.y, pos.x, ob);
                wrefresh(cw);
            }
			
            continue;

        }
        break;
    }

    return(pos);
}
Пример #19
0
void update_map_array(int map_col,char map[][map_col+1],WINDOW *game_window){
	
	for(int i=0; i<35; i++){
		for(int k=0;k<map_col;k++){
			int characters = (int)mvwinch(game_window, i, k);
 			
			map[i][k]=getTranslatedChar(characters);
		}
	}	
}
Пример #20
0
void normal_uset(int r, int c)
{
	char h, l;

	h = ((mvwinch(set_win,(r+1),((c*2)+1))) & A_CHARTEXT);
	l = ((mvwinch(set_win,(r+1),((c*2)+2))) & A_CHARTEXT);
	
	wattroff(set_win,A_UNDERLINE);
	mvwprintw(set_win,(r+1),((c*2)+1),"%c%c",h,l);
	wmove(set_win,(r+1),((c*2)+1));

	if((r==sr) && (c==sc))
	{
		wattron(set_win,A_REVERSE);
		mvwprintw(set_win,(r+1),((c*2)+1),"%c%c",h,l);
		wattroff(set_win,A_REVERSE);		
		wmove(set_win,(r+1),((c*2)+1));
	}	
}
Пример #21
0
char
display_atyx(int y, int x)
{
	int oy, ox;
	char c;

	display_getyx(&oy, &ox);
	c = mvwinch(stdscr, y, x) & 0x7f;
	display_move(oy, ox);
	return (c);
}
Пример #22
0
int is_wall_ahead(WINDOW *game_window,WINDOW *title, int x_pos, int y_pos){
	int result = 1;
	int characters = (int)mvwinch(game_window, x_pos, y_pos);

	if(characters==4195169 || characters==4195710 || characters==4195686 || characters==4195453 || 
		characters==32 || characters==288 ||characters == 4194912){
		result = 0;
	}

	return result;
}
Пример #23
0
int win_quinatri(int f, int c)
{
  int result = 0;
  chtype wc;

  if (hi_ha_win)
  { wc = mvwinch(win,f,c);	/* captura caracter */
    result = wc & A_REVERSE;	/* determina si es invers o no */
  }
  return(result);
}
Пример #24
0
nc_window_streambuf::nc_window_streambuf(WINDOW* _p, std::ostream& _os, unsigned long _cursesAttr):
	m_pnl(_p),
	m_flags(_cursesAttr),
	m_os(&_os),
	m_old(_os.rdbuf())
{
	setp(0, 0);
	setg(0, 0, 0);
	_os.rdbuf(this);
	scrollok(_p, true);
	mvwinch(_p, 0, 0);
}
Пример #25
0
void DS::ShadowView::draw_shadow()
{
 for (int i=0 ; i < 2 ; i++)
  for (int x=_rect.tl().x()+3 ; x < _rect.br().x()+3 ; x++) // draw x
  {
   chtype c;
   c=mvwinch(stdscr,_rect.br().y()+i,x);
   mvaddch(_rect.br().y()+i,x,(c & A_CHARTEXT) >= 128 ? c & A_CHARTEXT | A_ALTCHARSET : (c & A_CHARTEXT));
  }

 for (int i=0 ; i < 3 ; i++)
  for (int y=_rect.tl().y()+3 ; y < _rect.br().y() ; y++) // draw y
  {
   chtype c;
   c=mvwinch(stdscr,y,_rect.br().x()+i);
   mvaddch(y,_rect.br().x()+i,(c & A_CHARTEXT) >= 128 ? c & A_CHARTEXT | A_ALTCHARSET  : (c & A_CHARTEXT));
   //mvaddch(y,_rect.br().x()+i,ACS_BOARD | COLOR_PAIR(0));
  }


}
Пример #26
0
nc_window_streambuf::nc_window_streambuf(WINDOW * p, unsigned long _cursesAttr):
	m_pnl(p),
	m_flags(_cursesAttr),
	m_os(0),
	m_old(0)
{
	// Tell parent class that we want to call overflow() for each
	// input char:
	setp(0, 0);
	setg(0, 0, 0);
	scrollok(p, true);
	mvwinch(p, 0, 0);
}
Пример #27
0
char win_quincar(int f, int c)
{
  char result;
  chtype wc;

  result = 0;			/* resultat per defecte */
  if (hi_ha_win)
  { wc = mvwinch(win,f,c);		/* captura caracter */
    result = wc & A_CHARTEXT;		/* elimina atributs */
    if ((result < ' ') || (result > '~')) /* filtra valors fora del rang */
	result = ' ';	/* retorna blanc si no es un caracter ASCII */
  }
  return(result);
}
Пример #28
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;
}
Пример #29
0
//добавить клиента на панель
void AddClient(long pid)
{
    int pos;
    char s;
    //ищем первую свободную строку по пробелу
    for(pos=1;pos<200;pos++)
    {
        s=mvwinch(mpanel[1],pos,1);
        if(s==' ')
        {
            break;
        }
    }
    PrintClient(pos,pid);
}
Пример #30
0
static void viper_kmio_show_mouse(MEVENT *mouse_event)
{
   extern VIPER      *viper;
   extern WINDOW     *SCREEN_WINDOW;
   WINDOW            *screen_window;
   static chtype     color;
   gshort            fg,bg;

   screen_window=SCREEN_WINDOW;

   if(viper->console_mouse==NULL)
   {
      viper->console_mouse=newwin(1,1,0,0);
      color=mvwinch(screen_window,0,0);
      pair_content(PAIR_NUMBER(color & A_COLOR),&fg,&bg);
      if(bg==COLOR_RED || bg==COLOR_YELLOW || bg==COLOR_MAGENTA)
         color=VIPER_COLORS(COLOR_CYAN,COLOR_CYAN);
      if(bg==COLOR_CYAN || bg==COLOR_BLUE)
         color=VIPER_COLORS(COLOR_YELLOW,COLOR_YELLOW);
   }

   if(mouse_event!=NULL)
   {
      color=mvwinch(screen_window,mouse_event->y,mouse_event->x);
      pair_content(PAIR_NUMBER(color & A_COLOR),&fg,&bg);
      if(bg==COLOR_RED || bg==COLOR_YELLOW || bg==COLOR_MAGENTA) 
         color=VIPER_COLORS(COLOR_CYAN,COLOR_CYAN);
      else
         color=VIPER_COLORS(COLOR_YELLOW,COLOR_YELLOW);
      mvwin(viper->console_mouse,mouse_event->y,mouse_event->x);
   }

   mvwaddch(viper->console_mouse,0,0,' ' | color);

   return;
}