summaryrefslogtreecommitdiff
path: root/include/searchresultslistformaction.h
blob: 4388e3a28bd347f195145a9a0cee421e566c1610 (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
#ifndef NEWSBOAT_SEARCHRESULTSLISTFORMACTION_H_
#define NEWSBOAT_SEARCHRESULTSLISTFORMACTION_H_

#include <stack>

#include "configcontainer.h"
#include "itemlistformaction.h"
#include "regexmanager.h"
#include "rssfeed.h"
#include "view.h"
#include "keymap.h"
#include "fmtstrformatter.h"

namespace newsboat {

struct SearchResult {
	std::shared_ptr<RssFeed> search_result_feed;
	std::string search_phrase;
};

class SearchResultsListFormAction : public ItemListFormAction {
public:
	SearchResultsListFormAction(View* vv,
		std::string formstr,
		Cache* cc,
		FilterContainer& f,
		ConfigContainer* cfg,
		RegexManager& r);

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

	void set_searchphrase(const std::string& s)
	{
		search_phrase = s;
	}

	const std::vector<KeyMapHintEntry>& get_keymap_hint() const override;

	void add_to_history(const std::shared_ptr<RssFeed>& feed, const std::string& str);

	void set_head(const std::string& s,
		unsigned int unread,
		unsigned int total,
		const std::string& url) override;

	std::string title() override;

protected:
	FmtStrFormatter setup_head_formatter(const std::string& s,
		unsigned int unread,
		unsigned int total,
		const std::string& url) override;

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

private:
	std::stack<SearchResult> search_results;
	std::string search_phrase;
};

} // namespace newsboat

#endif /* NEWSBOAT_SEARCHRESULTSLISTFORMACTION_H_ */