summaryrefslogtreecommitdiff
path: root/include/itemviewformaction.h
blob: a6f05dbec3d40228bbcfee45d41e23b10cba76a9 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef NEWSBOAT_ITEMVIEWFORMACTION_H_
#define NEWSBOAT_ITEMVIEWFORMACTION_H_

#include "formaction.h"
#include "htmlrenderer.h"
#include "regexmanager.h"
#include "textformatter.h"
#include "textviewwidget.h"

namespace newsboat {

class Cache;
class ItemListFormAction;
class RssItem;

class ItemViewFormAction : public FormAction {
public:
	ItemViewFormAction(View*,
		std::shared_ptr<ItemListFormAction> il,
		std::string formstr,
		Cache* cc,
		ConfigContainer* cfg,
		RegexManager& r);
	~ItemViewFormAction() override;
	void prepare() override;
	void init() override;
	void set_guid(const std::string& guid_)
	{
		guid = guid_;
	}
	void set_feed(std::shared_ptr<RssFeed> fd)
	{
		feed = fd;
	}
	void set_highlightphrase(const std::string& text);
	const std::vector<KeyMapHintEntry>& get_keymap_hint() const override;
	void handle_cmdline(const std::string& cmd) override;

	std::string id() const override
	{
		return "article";
	}
	std::string title() override;

	void finished_qna(Operation op) override;

	void render_html(
		const std::string& source,
		std::vector<std::pair<LineType, std::string>>& lines,
		std::vector<LinkPair>& thelinks,
		const std::string& url);

	void update_percent();

private:
	void register_format_styles();

	bool process_operation(Operation op,
		bool automatic = false,
		std::vector<std::string>* args = nullptr) override;

	bool open_link_in_browser(const std::string& link, bool interactive) const;

	void update_head(const std::shared_ptr<RssItem>& item);
	void set_head(const std::string& s,
		const std::string& feedtitle,
		unsigned int unread,
		unsigned int total);
	void highlight_text(const std::string& searchphrase);

	void render_source(std::vector<std::pair<LineType, std::string>>& lines,
		std::string source);

	void do_search();
	void handle_save(const std::string& filename_param);

	std::string guid;
	std::shared_ptr<RssFeed> feed;
	std::shared_ptr<RssItem> item;
	bool show_source;
	std::vector<LinkPair> links;
	RegexManager& rxman;
	unsigned int num_lines;
	std::shared_ptr<ItemListFormAction> itemlist;
	bool in_search;
	Cache* rsscache;
	TextviewWidget textview;
};

} // namespace newsboat

#endif /* NEWSBOAT_ITEMVIEWFORMACTION_H_ */