summaryrefslogtreecommitdiffstats
path: root/src/history.h
blob: c006d4acd5892e565d3f88d205b22673c1c042f4 (plain) (blame)
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
46
47
#pragma once 

#include "list.h"

#define HISTORY_MAX 100

struct inputln {
	char *buf;
	int len, cap;
	int cur;
	int curpos;

	struct list_link link;
};

struct history {
	struct list list;
	struct inputln *sel, *input;
};

void history_init(struct history *history);
void history_deinit(struct history *history);

void history_submit(struct history *history);

void history_prev(struct history *history);
void history_next(struct history *history);

void history_add(struct history *history, struct inputln *line);

void inputln_init(struct inputln *ln);
void inputln_deinit(struct inputln *ln);

struct inputln *inputln_alloc(void);
void inputln_free(struct inputln *ln);

void inputln_resize(struct inputln *ln, size_t size);

void inputln_left(struct inputln *line);
void inputln_right(struct inputln *line);

void inputln_addch(struct inputln *line, char c);
void inputln_del(struct inputln *line, int n);

void inputln_copy(struct inputln *dst, struct inputln *src);
void inputln_replace(struct inputln *line, const char *str);