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
93
94
95
96
97
98
|
#include "listformaction.h"
#include "rssfeed.h"
#include "view.h"
namespace newsboat {
ListFormAction::ListFormAction(View* v,
std::string formstr,
std::string list_name,
ConfigContainer* cfg)
: FormAction(v, formstr, cfg)
, list(list_name, FormAction::f, cfg->get_configvalue_as_int("scrolloff"))
{
}
bool ListFormAction::process_operation(Operation op,
bool,
std::vector<std::string>*)
{
switch (op) {
case OP_CMD_START_1:
FormAction::start_cmdline("1");
break;
case OP_CMD_START_2:
FormAction::start_cmdline("2");
break;
case OP_CMD_START_3:
FormAction::start_cmdline("3");
break;
case OP_CMD_START_4:
FormAction::start_cmdline("4");
break;
case OP_CMD_START_5:
FormAction::start_cmdline("5");
break;
case OP_CMD_START_6:
FormAction::start_cmdline("6");
break;
case OP_CMD_START_7:
FormAction::start_cmdline("7");
break;
case OP_CMD_START_8:
FormAction::start_cmdline("8");
break;
case OP_CMD_START_9:
FormAction::start_cmdline("9");
break;
case OP_SK_UP:
list.move_up(cfg->get_configvalue_as_bool("wrap-scroll"));
break;
case OP_SK_DOWN:
list.move_down(cfg->get_configvalue_as_bool("wrap-scroll"));
break;
case OP_SK_HOME:
list.move_to_first();
break;
case OP_SK_END:
list.move_to_last();
break;
case OP_SK_PGUP:
list.move_page_up(cfg->get_configvalue_as_bool("wrap-scroll"));
break;
case OP_SK_PGDOWN:
list.move_page_down(cfg->get_configvalue_as_bool("wrap-scroll"));
break;
default:
break;
}
return true;
}
nonstd::optional<std::uint8_t> ListFormAction::open_unread_items_in_browser(
std::shared_ptr<RssFeed> feed,
bool markread)
{
int tabcount = 0;
for (const auto& item : feed->items()) {
if (tabcount <
cfg->get_configvalue_as_int("max-browser-tabs")) {
if (item->unread()) {
const auto exit_code = v->open_in_browser(item->link(), item->feedurl());
if (!exit_code.has_value() || *exit_code != 0) {
return exit_code;
}
tabcount += 1;
item->set_unread(!markread);
}
} else {
break;
}
}
return 0;
}
} // namespace newsboat
|