summaryrefslogtreecommitdiff
path: root/src/history.cpp
blob: e8fd0efd0034ede88030c6fbfb61f6bd93292e0c (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "history.h"

#include <fstream>

#include "ruststring.h"

extern "C" {
	void* rs_history_new();

	void rs_history_free(void* hst);

	void rs_history_add_line(
		void* hst,
		const char* line);

	char* rs_history_previous_line(void* hst);

	char* rs_history_next_line(void* hst);

	void rs_history_load_from_file(
		void* hst,
		const char* file);

	void rs_history_save_to_file(
		void* fmt,
		const char* file,
		unsigned int limit);
}

namespace newsboat {

History::History()
{
	rs_hst = rs_history_new();
}

History::~History()
{
	rs_history_free(rs_hst);
}

void History::add_line(const std::string& line)
{
	rs_history_add_line(rs_hst, line.c_str());
}

std::string History::previous_line()
{
	return RustString(rs_history_previous_line(rs_hst));
}

std::string History::next_line()
{
	return RustString(rs_history_next_line(rs_hst));
}

void History::load_from_file(const std::string& file)
{
	rs_history_load_from_file(rs_hst, file.c_str());
}

void History::save_to_file(const std::string& file, unsigned int limit)
{
	rs_history_save_to_file(rs_hst, file.c_str(), limit);
}

} // namespace newsboat