Esempio n. 1
0
int m_sol(motion_arg const *m, unsigned repeat, window *win, point_t *to)
{
	list_t *l = window_current_line(win, false);

	start_of_line_given(l, to);
	return MOTION_SUCCESS;
}
Esempio n. 2
0
static int m_linesearch(
		motion_arg const *arg, unsigned repeat, window *win, point_t *to,
		list_t *sfn(motion_arg const *, list_t *, int *, const void *),
		const void *ctx)
{
	list_t *l = window_current_line(win, false); /* fine - repeat handled */
	int n = 0;

	*to = *win->ui_pos;

	if(!l)
		goto limit;

	for(repeat = DEFAULT_REPEAT(repeat);
			repeat > 0;
			repeat--)
	{
		l = sfn(arg, l, &n, ctx);
		if(!l)
			goto limit;
	}

	to->y += n;

	return MOTION_SUCCESS;
limit:
	to->y = arg->dir > 0 ? buffer_nlines(win->buf) : 0;
	return MOTION_SUCCESS;
}
Esempio n. 3
0
static int m_findnext2(const int ch, enum find_type ftype, unsigned repeat, window *win, point_t *to)
{
	list_t *l = window_current_line(win, false); /* fine - repeat handled */

	if(!l)
		return MOTION_FAILURE;

	point_t bpos = *win->ui_pos;

	if(!(ftype & F_REV)){
		bpos.x++;
		if((unsigned)bpos.x >= l->len_line)
			return MOTION_FAILURE;
	}else{
		if(l->len_line == 0)
			return MOTION_FAILURE;

		/* if we're after the actual length, move from logical to it */
		if((unsigned)bpos.x >= l->len_line)
			bpos.x = l->len_line;

		bpos.x--;

		if(bpos.x < 0)
			return MOTION_FAILURE;
	}

	repeat = DEFAULT_REPEAT(repeat);

	for(;;){
		char *p = l->line + bpos.x;

		p = strchrdir(p, ch, ftype & F_REV, l->line, l->len_line);

		if(!p)
			return MOTION_FAILURE;

		bpos.x = p - l->line;

		if(--repeat == 0){
			const int adj = ftype & F_TIL ? ftype & F_REV ? 1 : -1 : 0;

			*to = bpos;
			to->x += adj;
			break;
		}else{
			bpos.x += ftype & F_REV ? -1 : +1;
		}
	}

	return MOTION_SUCCESS;
}
Esempio n. 4
0
int m_eol(motion_arg const *m, unsigned repeat, window *win, point_t *to)
{
	list_t *l = window_current_line(win, false);

	to->x = l && l->len_line > 0 ? l->len_line - 1 : 0;

	bool nonblank = m->i;
	if(nonblank){
		for(; to->x > 0 && isspace(l->line[to->x]); to->x--);
	}

	return MOTION_SUCCESS;
}
Esempio n. 5
0
void k_showch(const keyarg_u *a, unsigned repeat, const int from_ch)
{
	window *win = windows_cur();
	list_t *l = window_current_line(win, false);
	if(l){
		if((unsigned)win->ui_pos->x < l->len_line){
			const int ch = l->line[win->ui_pos->x];

			ui_status("<%s> %d Hex %x Octal %o",
					ch ? (char[]){ ch, 0 } : "^@",
					ch, ch, ch);
			return;
		}
	}