Exemplo n.º 1
0
char *fb_GfxReadStr(char *buffer, ssize_t maxlen)
{
	int key;
	ssize_t len = 0;
	char cursor_normal[2] = { 219, '\0' };
	char cursor_backspace[3] = { 219, ' ', '\0' };
	char space[2] = { ' ', '\0' };
	char character[2] = { 0, '\0' };
	char *cursor = cursor_normal;
	
	if (!__fb_gfx)
		return NULL;
	
	do {
		fb_GfxPrintBuffer(cursor, 0);
		
		if (cursor == cursor_backspace) {
			move_back();
			cursor = cursor_normal;
		}
		move_back();
		
		key = fb_Getkey();
		if (key < 0x100) {
			if (key == 8) {
				if (len > 0) {
					cursor = cursor_backspace;
					move_back();
					if (__fb_gfx->cursor_y < 0) {
						__fb_gfx->cursor_y = __fb_gfx->cursor_x = 0;
						cursor = cursor_normal;
					}
					len--;
				}
			}
			else if ((key != 7) && (len < maxlen - 1)) {
				if (key == 13) {
					fb_GfxPrintBuffer(space, 0);
					move_back();
				}
				buffer[len++] = key;
				character[0] = key;
				fb_GfxPrintBuffer(character, 0);
			}
		}
	} while (key != 13);
	
	buffer[len] = '\0';
	
	return buffer;
}
Exemplo n.º 2
0
void parser::skip_whitespace()
{
  int c;
  while ( (c = fgetchar()) != EOF && isspace(c) )
    ;
  move_back(c);
}
Exemplo n.º 3
0
void smart_object::attract(complex_object target)//object moves toward object B
{
    if(near_front(target))
        move_forward();
    if(near_back(target))
        move_back();
    if(near_left(target))
        move_left();
    if(near_right(target))
        move_right();
}
Exemplo n.º 4
0
void smart_object::repel(complex_object target)//object moves away from object B
{
    if(near_front(target))
        move_back();
    if(near_back(target))
        move_forward();
    if(near_left(target))
        move_right();
    if(near_right(target))
        move_left();
}
Exemplo n.º 5
0
int		move(int keyboard, t_pos *wolf)
{
	if (keyboard == 126)
		move_front(wolf);
	else if (keyboard == 125)
		move_back(wolf);
	else if (keyboard == 124)
		move_right(wolf);
	else if (keyboard == 123)
		move_left(wolf);
	return (0);
}
Exemplo n.º 6
0
	bool lexer::consume_next_if(char c) {
		if (current == end) {
			return false;
		}
		
		if (next_char() == c) {
			return true;
		}

		move_back();
		return false;
	}
Exemplo n.º 7
0
void			move_back_word(void)
{
	char		*tmp;
	int			i;

	tmp = g_main_line.cmd;
	i = g_main_line.curs_x;
	if (i > 0 && (tmp[i] != ' ' || tmp[i] != '\t'))
	{
		move_back();
		i--;
	}
	while (i >= 0 && (tmp[i] == ' ' || tmp[i] == '\t'))
	{
		move_back();
		i--;
	}
	while (i > 0 && tmp[i - 1] != ' ' && tmp[i - 1] != '\t')
	{
		move_back();
		i--;
	}
}
Exemplo n.º 8
0
void picture_move()
{
 if (current != last_value)
 {
    draw_picture(); 
 }
  if(current_beat)
  {
   move_back(true);
 
  
  }
 
}
Exemplo n.º 9
0
	string lexer::append_while(char initial, std::function<bool (char)> predicate) {
		string content;

		if (initial > 0) content += initial;

		while (current != end) {
			char c = next_char();
			if (!predicate(c)) {
				move_back();
				break;
			}

			content += c;
		}

		return content;
	}
Exemplo n.º 10
0
void snake()
{
   if (current_beat)
   {
      
      move_back(false);
      int amount = (float)current_volume/600 * 8;
      int length = (float)current_volume/600 * (float)num_panels* 16;
  
       for (int i = 0; i < length  ;i++)
       {
            picture[i][amount] =red;
       }
  
   }
  
}
Exemplo n.º 11
0
void snake()
{
   if (beat())
   {
      int vol = volume();
      move_back(0);
      int amount = (float)vol/600 * 8;
      int length = (float)vol/600 * (float)num_panels* 16;
  
       for (int i = 0; i < length  ;i++)
       {
            picture[i][amount] =red;
       }
  
   }
  
}
Exemplo n.º 12
0
Arquivo: move.c Projeto: rbejot/wolf3d
void		move(t_env *e, int keycode)
{
	double	movespeed;

	movespeed = 1;
	if (keycode == W)
	{
		if (e->wl_map[(int)(e->data.player.x + e->data.direction.x
					* movespeed)][(int)(e->data.player.y)] == 0)
			e->data.player.x += e->data.direction.x * movespeed;
		if (e->wl_map[(int)(e->data.player.x)][(int)(e->data.player.y
					+ e->data.direction.y * movespeed)] == 0)
			e->data.player.y += e->data.direction.y * movespeed;
		mlx_destroy_image(e->mlx, e->img_ptr);
		new_image(e);
		expose_hook(e);
	}
	move_back(e, keycode, movespeed);
}
Exemplo n.º 13
0
void fun(){
    int i;
    Matrix a,b;
    Vector v;
    
    assign(&a,&e);
    
    for(i=0;i<nodenum;i++){
        move_from(&b,vertex[i].x, vertex[i].y);
        multiply(&a,&b);
        rotate(&b,vertex[i].degree);
        multiply(&a,&b);
        move_back(&b,vertex[i].x, vertex[i].y);
        multiply(&a,&b);
        assign(&mat[i],&a);
    }
    for(i =0;i < 3;i++){
        printf("%.2lf %.2lf %.2lf\n", a[i][0], a[i][1], a[i][2]);
    }
    v[0] = a[2][1]*a[1][0]  + a[2][0]*(1-a[1][1]);
	v[0]/= ((1-a[1][1])*(1-a[0][0]) - a[0][1] * a[1][0]);
    
    v[1] = a[0][1] * v[0] + a[2][1]*a[1][0] ;
    v[1] /= (1 - a[1][1]);
    v[2] = 1;    
    
    vertex[0].x = v[0];
    vertex[0].y = v[1];
    
    for(i =0;i < nodenum-1;i++){
        V_mul_M(&v, &mat[i]);
        vertex[i+1].x = v[0];
        vertex[i+1].y = v[1];
		v[0] = vertex[0].x;
		v[1] = vertex[0].y;
		v[2] = 1;
    }    
    for(i=0;i<nodenum;i++){
        printf("%.2lf %.2lf\n", vertex[i].x, vertex[i].y);
    }
}
Exemplo n.º 14
0
void snake2()
{
    if (millis() > lasttime + analogRead(3))
   {
   lasttime = millis();
     
      move_back(false);
      int amount = (float)current_volume/512 * 8;
     
      int color =random(1,2);
      
       for (int i = 0; i < amount  ;i++)
       {
          picture[num_panels*16-1][i] =red;
  
       }
      
     
      
   }
  
}
Exemplo n.º 15
0
int key_hook(int keycode, t_w3d *w3d)
{
	if (keycode == 65307)
		w3d_exit(&w3d);
	else if (keycode == 65361 || keycode == 65363)
	{
		w3d->pos.a += (keycode == 65361) ? PI / 6 : -PI / 6;
		if (w3d->pos.a > 2 * PI)
			w3d->pos.a -= 2 * PI;
		else if (w3d->pos.a < 0)
			w3d->pos.a = (2 * PI) + w3d->pos.a;
	}
	else if (keycode == 65362 || keycode == 65364)
	{
		if (keycode == 65362)
			move_forward(&w3d);
		else
			move_back(&w3d);
	}
	w3d->change = 1;
	return (0);
}
Exemplo n.º 16
0
	char lexer::parse_escape_sequence() {
		char c = next_char();
		if (c == '\0') {
			return c;
		}

		switch (c) {
		case '\'':
			return '\'';
		case '"':
			return '"';
		case '?':
			return '?';
		case '\\':
			return '\\';
		case '0':
			return '\0';
		case 'a':
			return '\a';
		case 'b':
			return '\b';
		case 'f':
			return '\f';
		case 'n':
			return '\n';
		case 'r':
			return '\r';
		case 't':
			return '\t';
		case 'v':
			return '\v';
		case 'x':
		case 'X':
			{
				char firstDigit = next_char();
				if (firstDigit == '\0') {
					return firstDigit;
				}

				if (!isxdigit(firstDigit)) {
					logger.error(make_location(), format("invalid hex digit '%c' following hex escape")
						% firstDigit);
					move_back();
					return '\0';
				}

				uint8_t parsed_int = parse_hex_digit(firstDigit);
				// check if it's a two digit hex escape
				if (current != end && isxdigit(*current)) {
					parsed_int = (parsed_int * 16) + parse_hex_digit(next_char());
				}

				if (parsed_int & 0x80) {
					logger.warning(make_location(), boost::format("invalid 7-bit ASCII character '%#02x'")
						% parsed_int);
				}

				return parsed_int;
			}
		default:
			logger.error(make_location(), format("unrecognized escape character '%c'") % c);
			return c;
		}
	}
Exemplo n.º 17
0
int readline(lua_State *L) {
	int		rc;
	char	*temp;
	char	*termtype = getenv("TERM");

	if(!termtype) {
		fprintf(stderr, "no TERM defined!\n");
		exit(1);
	}

	ioctl(0, TCGETS, &old_termio);
	new_termio = old_termio;
	new_termio.c_lflag &= ~ECHO;
	new_termio.c_lflag &= ~ICANON;

	ioctl(0, TCSETS, &new_termio);
	

	signal(SIGQUIT, int_handler);
	signal(SIGINT, int_handler);
	signal(SIGWINCH, winch_handler);
	printf(sample);
	printf("\n");

	// Setup terminfo stuff...
	rc = setupterm((char *)0, 1, (int *)0);
	fprintf(stderr, "rc=%d\n", rc);
	
//	rc = tgetent(NULL, termtype);
//	fprintf(stderr, "rc=%d\n", rc);
//
/*	int y;
	for(y=0; strnames[y]; y++) {
		fprintf(stderr, "%d: %s\n", y, strnames[y]);
	}
	fprintf(stderr, "lines=%s\n", cursor_down);
*/
	height = lines;
	width = columns;
	printf("w=%d h=%d\n", width, height);

	col = 0;
	row = 0;

	init_terminfo_data();

	int t;
	char *x = parm_down_cursor;
	printf("p=%p (%d)\n", x, strlen(x));
//	for(t=0; t < strlen(x); t++) {
//		printf("> %d  [%c] %d\n", t, x[t], x[t]);
//	}

	printf("arm=%d, eng=%d\n",  auto_right_margin, eat_newline_glitch);

//	printf(tparm(setb, 4));
	printf("HELLO\n");
//	printf(tparm(setb, 0));

	line = malloc(8192);
	strcpy(line, sample);
	line_len = strlen(line);

	int c;

	move_to((line_len/width), line_len%width);

//	show_line();
//	fflush(stdout);

	int redraw = 1;

	while(1) {
		if(redraw) {
			redraw_line();
			redraw = 0;
		}
		fflush(stdout);


		c = read_key();

		switch(c) {

		case KEY_LEFT:
			if(((row * width)+col) > 0) move_back();
			break;

		case KEY_RIGHT:
			if(((row * width)+col) < line_len) move_on();
			break;

		case KEY_DC:
			if(((row * width)+col) < line_len) {
				remove_char_at((row * width) + col);
				redraw = 1;
			}
			break;

		case 27:
			printf("X");
			break;

		case 127:
		case 8:
			// if we are the first char of the screen then we need to backup to the
			// end of the previous line
			//
			if(((row * width)+col) > 0) {
				move_back();
				remove_char_at((row * width) + col);
				redraw = 1;
			}
			break;

		default:
			insert_char_at((row * width) + col, c);
			move_on();
			redraw = 1;
		}
	}

	return 0;
}