2021-05-09 00:56:48 +12:00
|
|
|
/* 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
|
|
|
|
|
2021-09-02 07:40:13 +12:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2021-05-09 00:56:48 +12:00
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
2021-06-20 00:57:27 +12:00
|
|
|
#pragma once
|
2021-05-09 00:56:48 +12:00
|
|
|
|
|
|
|
#include <string>
|
2021-05-10 08:25:41 +12:00
|
|
|
#include <atomic>
|
2021-09-02 07:40:13 +12:00
|
|
|
#include <vector>
|
|
|
|
#include <bitset>
|
2021-05-09 00:56:48 +12:00
|
|
|
|
2021-08-23 02:04:01 +12:00
|
|
|
#include <btop_input.hpp>
|
|
|
|
|
2021-09-02 07:40:13 +12:00
|
|
|
using std::string, std::atomic, std::vector, std::bitset;
|
2021-05-09 00:56:48 +12:00
|
|
|
|
2021-06-03 07:33:26 +12:00
|
|
|
namespace Menu {
|
2021-05-22 12:13:56 +12:00
|
|
|
|
2021-07-21 13:17:34 +12:00
|
|
|
extern atomic<bool> active;
|
|
|
|
extern string output;
|
2021-09-02 07:40:13 +12:00
|
|
|
extern int signalToSend;
|
|
|
|
extern bool redraw;
|
2021-05-14 07:11:10 +12:00
|
|
|
|
2021-09-02 07:40:13 +12:00
|
|
|
//? line, col, height, width
|
2021-08-23 02:04:01 +12:00
|
|
|
extern unordered_flat_map<string, Input::Mouse_loc> mouse_mappings;
|
2021-05-09 00:56:48 +12:00
|
|
|
|
2021-09-02 07:40:13 +12:00
|
|
|
//* 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 = 0, width = 0, boxtype = 0, selected = 0, x = 0, y = 0;
|
|
|
|
public:
|
2021-09-13 01:58:23 +12:00
|
|
|
enum BoxTypes { OK, YES_NO, NO_YES };
|
2021-09-02 07:40:13 +12:00
|
|
|
enum msgReturn {
|
|
|
|
Invalid,
|
|
|
|
Ok_Yes,
|
|
|
|
No_Esc,
|
|
|
|
Select
|
|
|
|
};
|
|
|
|
msgBox();
|
2021-09-13 01:58:23 +12:00
|
|
|
msgBox(int width, int boxtype, vector<string> content, string title);
|
2021-09-02 07:40:13 +12:00
|
|
|
|
|
|
|
//? Draw and return box as a string
|
|
|
|
string operator()();
|
|
|
|
|
|
|
|
//? Process input and returns value from enum Ret
|
|
|
|
int input(string key);
|
|
|
|
|
|
|
|
//? Clears content vector and private strings
|
|
|
|
void clear();
|
|
|
|
};
|
|
|
|
|
|
|
|
extern bitset<8> menuMask;
|
2021-09-13 01:58:23 +12:00
|
|
|
|
2021-09-02 07:40:13 +12:00
|
|
|
//* Enum for functions in vector menuFuncs
|
|
|
|
enum Menus {
|
2021-09-21 04:20:30 +12:00
|
|
|
SizeError,
|
2021-09-02 07:40:13 +12:00
|
|
|
SignalChoose,
|
|
|
|
SignalSend,
|
|
|
|
SignalReturn,
|
|
|
|
Options,
|
|
|
|
Help,
|
|
|
|
Main
|
|
|
|
};
|
|
|
|
|
|
|
|
//* Handles redirection of input for menu functions and handles return codes
|
|
|
|
void process(string key="");
|
|
|
|
|
2021-09-18 00:25:54 +12:00
|
|
|
//* Show a menu from enum Menu::Menus
|
|
|
|
void show(int menu, int signal=-1);
|
|
|
|
|
2021-05-17 08:58:16 +12:00
|
|
|
}
|