summaryrefslogtreecommitdiff
path: root/shed_move.c
blob: 09700851e1463a0a7ca3e4d6c85895ed26a4fcd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#define _POSIX_C_SOURCE 200809L
#include <ctype.h>
#include "shed.h"

int shed_move_forward(struct shed *e)
{
	shed_move_cursor(e->cur, e->count ? e->count : 1);
	return 1;
}

int shed_move_backward(struct shed *e)
{
	shed_move_cursor(e->cur, e->count ? -e->count : -1);
	return 1;
}

int shed_move_beginning(struct shed *e)
{
	shed_move_cursor(e->cur, -e->cur->pos);
	while (isspace(e->cur->buf[e->cur->pos])) {
		shed_move_cursor(e->cur, 1);
	}
	return 1;
}

int shed_move_end(struct shed *e)
{
	shed_move_cursor(e->cur, e->cur->nread);
	return 1;
}

int shed_move_0(struct shed *e)
{
	shed_move_cursor(e->cur, -e->cur->pos);
	return 1;
}

int shed_move_column(struct shed *e)
{
	if (e->count == 0) {
		e->count = 1;
	}
	shed_move_cursor(e->cur, e->count - e->cur->pos - 1);
	return 1;
}