-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAttachDocumentMenu.cpp
More file actions
39 lines (34 loc) · 1.31 KB
/
AttachDocumentMenu.cpp
File metadata and controls
39 lines (34 loc) · 1.31 KB
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
#include "AttachDocumentMenu.hpp"
#include "ComposeWindow.hpp"
namespace tdcurses {
void AttachDocumentMenu::build_menu() {
for (size_t i = 0; i < attached_files_.size(); i++) {
auto &x = attached_files_[i];
Outputter out;
out << x << Outputter::RightPad{"<remove>"};
add_element("file", out.as_str(), out.markup(), [self = this, self_id = window_unique_id(), root = root(), i]() {
if (!root->window_exists(self_id)) {
return false;
}
self->del_file(i);
return false;
});
}
if (attached_files_.size() < 10) {
add_element("add", "new file", {},
create_menu_window_spawn_function<FileSelectionWindow>(create_file_selection_callback()));
}
add_element("save", "update attachments", {},
[self_id = window_unique_id(), root = root(), type = attach_type_, files = attached_files_,
compose_window = compose_window_, compose_window_id = compose_window_id_]() mutable {
if (!root->window_exists(self_id)) {
return false;
}
if (!root->window_exists(compose_window_id)) {
return true;
}
compose_window->update_attach(type, std::move(files));
return true;
});
}
} // namespace tdcurses