File: listwidgetbackend.h

package info (click to toggle)
newsboat 2.38-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,540 kB
  • sloc: cpp: 90,216; xml: 606; sh: 429; makefile: 369; ruby: 258; python: 239; ansic: 211; php: 63; awk: 59; perl: 38
file content (50 lines) | stat: -rw-r--r-- 1,282 bytes parent folder | download | duplicates (2)
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
#ifndef NEWSBOAT_LISTWIDGETBACKEND_H_
#define NEWSBOAT_LISTWIDGETBACKEND_H_

#include <cstdint>
#include <functional>
#include <map>
#include <string>

#include "listformatter.h"
#include "regexmanager.h"
#include "stflpp.h"
#include "stflrichtext.h"

namespace newsboat {

class ListWidgetBackend {
public:
	ListWidgetBackend(const std::string& list_name, const std::string& context,
		Stfl::Form& form, RegexManager& rxman);
	ListWidgetBackend(const std::string& list_name, Stfl::Form& form);
	virtual ~ListWidgetBackend() = default;

	void stfl_replace_list(std::string stfl);

	std::uint32_t get_width();
	std::uint32_t get_height();
	std::uint32_t get_num_lines();

	void invalidate_list_content(std::uint32_t num_lines,
		std::function<StflRichText(std::uint32_t, std::uint32_t)> get_line_method);

protected:
	virtual void on_list_changed() = 0;
	void update_position(std::uint32_t pos, std::uint32_t scroll_offset);

private:
	void render();

	const std::string list_name;
	Stfl::Form& form;
	ListFormatter listfmt;
	std::uint32_t num_lines;
	std::uint32_t scroll_offset;
	std::map<std::uint32_t, StflRichText> line_cache;
	std::function<StflRichText(std::uint32_t, std::uint32_t)> get_formatted_line;
};

} // namespace newsboat

#endif /* NEWSBOAT_LISTWIDGETBACKEND_H_ */