forked from aristocratos/btop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbtop_menu.hpp
More file actions
96 lines (76 loc) · 2.26 KB
/
btop_menu.hpp
File metadata and controls
96 lines (76 loc) · 2.26 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
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
/* Copyright 2021 Aristocratos (jakob@qvantnet.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
indent = tab
tab-size = 4
*/
#pragma once
#include <atomic>
#include <bitset>
#include <string>
#include <string_view>
#include <vector>
#include "btop_input.hpp"
using std::atomic;
using std::bitset;
using std::string;
using std::vector;
namespace Menu {
extern atomic<bool> active;
extern string output;
extern int signalToSend;
extern bool redraw;
//? line, col, height, width
extern std::unordered_map<string, Input::Mouse_loc> mouse_mappings;
//* Creates a message box centered on screen
//? Height of box is determined by size of content vector
//? Boxtypes: 0 = OK button | 1 = YES and NO with YES selected | 2 = Same as 1 but with NO selected
//? Strings in content vector is not checked for box width overflow
class msgBox {
string box_contents, button_left, button_right;
int height{};
int width{};
int boxtype{};
int selected{};
int x{};
int y{};
public:
enum BoxTypes { OK, YES_NO, NO_YES };
enum msgReturn {
Invalid,
Ok_Yes,
No_Esc,
Select
};
msgBox();
msgBox(int width, int boxtype, const vector<string>& content, std::string_view title);
//? Draw and return box as a string
string operator()();
//? Process input and returns value from enum Ret
int input(const string& key);
//? Clears content vector and private strings
void clear();
};
extern bitset<8> menuMask;
//* Enum for functions in vector menuFuncs
enum Menus {
SizeError,
SignalChoose,
SignalSend,
SignalReturn,
Options,
Help,
Main
};
//* Handles redirection of input for menu functions and handles return codes
void process(const std::string_view key = "");
//* Show a menu from enum Menu::Menus
void show(int menu, int signal=-1);
}