Exemplo n.º 1
0
void			history_next_evt(t_nboon *l, int cmd)
{
	int				status;

	if (l->save_line != NULL)
		update_line(l->buf);
	status = (cmd == NB_HISTORY_NEXT) ? nb_history_next() : nb_history_prev();
	if (status && g_history[g_history_pos] != NULL)
	{
		if (l->save_line == NULL)
		{
			l->save_line = nb_strdup(l->buf);
			nb_history_next();
		}
		reset_line(l, g_history[g_history_pos]);
	}
	else if (l->save_line != NULL && cmd == NB_HISTORY_NEXT)
	{
		reset_line(l, l->save_line);
		free(l->save_line);
		l->save_line = NULL;
	}
	else
		write(STDERR_FILENO, "\x7", 1);
	move_end_evt(l);
}
Exemplo n.º 2
0
void Buffer::insert(){
	if (mode == INSERT){
		if (line == --itens.end()){
			itens.push_back(line_buffer);
			reset_line();
		}
		else
		{
			list<string>::iterator aux = line;
			itens.insert(++aux, line_buffer);
			line++;
		}
		line_buffer.clear();
	}
	else if(mode == EDIT)
	{
		*line = line_buffer;
	}
	else{
		list<string>::iterator aux = line;
		if(line != itens.begin())
		{
			itens.insert(aux, line_buffer);
		}
		line_buffer.clear();
	}
}
Exemplo n.º 3
0
int	execute_pipe_start(t_tree *tree, t_shell *st_shell)
{
  int	flag;
  int	statut;
  int	fd[2];
  pid_t	pid;

  if ((flag = prepare_all_commands(tree, st_shell)) != EXIT_SUCCESS)
    return (flag);
  if ((pid = xfork()) == 0)
    {
      if (xpipe(fd) == -1)
	exit(EXIT_FAILURE);
      reset_line(st_shell);
      set_fd_out(tree->right, fd[1]);
      set_fd_in(tree->left, fd[0]);
      if (tree->right->type == IS_CMD)
	init_first_pipe(tree, st_shell, fd);
      init_first_pipe_spe(tree, st_shell, fd);
    }
  else if (pid > 0)
    {
      if (waitpid(-1, &statut, 0) == -1)
	perror("Waitpid() :");
      return (write_statut(statut));
    }
  return (FATAL_ERROR);
}
Exemplo n.º 4
0
void Buffer::removeLine(int l){
	if ((l > 0) && (l <= itens.size())){
		list<string>::iterator it = itens.begin();
		advance(it, l - 1);
		itens.erase(it);
		reset_line();
	}
}
Exemplo n.º 5
0
// check serial in and handle the character
void read_line(void)
{
	if (serial_available()) {
		uint8_t c;
		c = serial_read();
		if (line_pos >= cols - 1) {
			exec_line();
			reset_line();
			char_to_line(c);
		} else if (c == '\n') {
			// ignore '\n' 
		} else if (c == '\r') {
			exec_line();
			reset_line();
		} else {
			char_to_line(c);
		}
	}
}
Exemplo n.º 6
0
Arquivo: ex.c Projeto: xbot/c-ex
int main(void)
{
    int x = 2938472;
    char a[MAX_LINE_LEN];

    reset_line(a);
    itoa(x, a);
    printf("%d, %s\n", x, a);

    return 0;
}
Exemplo n.º 7
0
void Buffer::removeLines(int start, int end){
	if ((start < end) && (start > 0) && (end <= itens.size())){
		list<string>::iterator s = itens.begin();
		list<string>::iterator e = itens.begin();

		advance(s, start - 1);
		advance(e, end - 1);

		itens.erase(s, e);
		reset_line();
	}
}
Exemplo n.º 8
0
void Buffer::change_line(int l){
	if ((l <= itens.size()) && (l > 0)){
		line = itens.begin();
		advance(line, l - 1);
		if (mode == EDIT)
			line_buffer = *line;
	}
	else
	{
		reset_line();
	}
}
Exemplo n.º 9
0
void init_fractal_polyline (fractal_line_struct *f,
	gint sizex, gint sizey,
	gint x0, gint y0,
	gint x1, gint y1) {

	// When using the fault or crack pens,
	// create a fractal line for the preview window or for initializing the drawing buffer

	gdouble cos, sin, ddist;

	// Subdivide and draw the line
	srand (f->seed);
	ddist = DIST2(x0,y0,x1,y1);
	sin = -((gdouble) (y1-y0)) / ddist;
	cos = ((gdouble)(x1-x0)) / ddist;;

	reset_line (f->polyline, (gint) pow(2.0,(gdouble) f->steps),1);
	set_line_translation (f->polyline, x0, y0, sizex, sizey);
	set_line_scale (f->polyline,(gdouble) (sizex-1), (gdouble) (sizey-1));

	divide_n_draw (f, f->steps, 0.0, 0.0,
		(gdouble) (x1-x0), (gdouble) (y1-y0), ddist, cos, sin);
}
Exemplo n.º 10
0
// Arduino master setup
void setup(void)
{
	// set font for the console window
	u8g.setFont(u8g_font_6x10);

	// set upper left position for the string draw procedure
	u8g.setFontPosTop();

	// calculate the number of rows for the display
	rows = u8g.getHeight() / u8g.getFontLineSpacing();
	if (rows > ROW_MAX)
		rows = ROW_MAX;

	// estimate the number of columns for the display
	cols = u8g.getWidth() / u8g.getStrWidth("m");
	if (cols > LINE_MAX - 1)
		cols = LINE_MAX - 1;

	clear_screen();		// clear screen
	delay(1000);		// do some delay
	serial_begin(115200);	// init serial
	exec_line();		// place the input buffer into the screen
	reset_line();		// clear input buffer
}
Exemplo n.º 11
0
void Buffer::removeLine(){
	if (!(itens.empty())){
		itens.erase(line);
		reset_line();
	}
}