Esempio n. 1
0
void	refresh_command_line(t_char **list)
{
	t_char	*temp;
	t_char	**activechar;
	int		i;
	char	*tempstr;

	cursor_move_left(*(getcurpos()));
	tputs(tgetstr("cd", NULL), 1, t_write);
	activechar = getactivechar();
	ft_putstr_fd("$> ", *(gettty()));
	if (*list)
	{
		tempstr = char_to_str((*list)->next);
		*(getcurpos()) = 3 + ft_strlen(tempstr);
		ft_putstr_fd(tempstr, *(gettty()));
		ft_memdel((void **)&tempstr);
		temp = (*list)->next;
		i = 3;
		while (temp && temp != *activechar)
		{
			i++;
			temp = temp->next;
		}
		cursor_move_left(*(getcurpos()) - i);
	}
}
Esempio n. 2
0
File: LUA.c Progetto: Mattykins/Luna
int l_move_cursor(lua_State *L) {
  int drow, dcol;
  Buffer *target;

  target = get_buffer(active_buffer);

  if (target == NULL) {
    lua_pushnumber(L, -1);
  } else {
    Cursor *curs = &target->curs;
    Row *row = curs->row;
    int i = 0;

    drow = lua_tonumber(L, 1);
    dcol = lua_tonumber(L, 2);

    if (drow > 0) {
      for(i = 0; i <= drow; i++) { cursor_move_up(curs, row, target->id); }
    } else if (drow < 0) {
      for(i = 0; i >= drow; i--) { cursor_move_down(curs, row, target->id); }
    }

    if (dcol > 0) {
      for(i = 0; i >= dcol; i--) { cursor_move_right(curs, row); }
    } else if (dcol < 0) {
      for(i = 0; i <= dcol; i++) { cursor_move_left(curs, row); }
    }
  }
  return 1;
}