~kiwec/ke

ref: 2133c126a17a4627ffb76143c19c287e9c272749 ke/src/Status.h -rw-r--r-- 471 bytes
2133c126 — Wolf Clément Add error, info and success messages 3 years ago
                                                                                
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
#pragma once
#include <memory>
#include <termbox.h>
#include "Prompt.h"

class Buffer;

enum class StatusType {
	DEFAULT,
	INFO,
	ERROR,
	SUCCESS,
//	PROMPT,
};

class Status {
private:
	wchar_t* _msg = nullptr;
	StatusType _type;

public:
	std::unique_ptr<Prompt> prompt = nullptr;

	~Status() {
		if(_msg != nullptr) {
			free(_msg);
		}
	}

	void draw(Buffer& buf);
	int height();
	void handle_key(tb_event* ev);
	void set_msg(const wchar_t* msg, StatusType type);
};