summaryrefslogtreecommitdiff
path: root/include/listformatter.h
blob: 9d4fb8a52ae6a0552b5f1ded9baa543bcc801d4e (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
#ifndef NEWSBOAT_LISTFORMATTER_H_
#define NEWSBOAT_LISTFORMATTER_H_

#include <climits>
#include <string>
#include <utility>
#include <vector>

#include "regexmanager.h"

namespace newsboat {

class ListFormatter {
	typedef std::pair<std::string, unsigned int> LineIdPair;

public:
	ListFormatter();
	~ListFormatter();
	void add_line(const std::string& text,
		unsigned int id = UINT_MAX,
		unsigned int width = 0);
	void add_lines(const std::vector<std::string>& lines,
		unsigned int width = 0);
	void set_line(const unsigned int itempos,
		const std::string& text,
		unsigned int id = UINT_MAX,
		unsigned int width = 0);
	void clear()
	{
		lines.clear();
	}
	std::string format_list(RegexManager* r = nullptr,
		const std::string& location = "");
	unsigned int get_lines_count()
	{
		return lines.size();
	}

private:
	std::vector<LineIdPair> lines;
	std::string format_cache;
};

} // namespace newsboat

#endif /* NEWSBOAT_LISTFORMATTER_H_ */