aboutsummaryrefslogtreecommitdiff
path: root/include/keycombination.h
blob: b9194b38676d8865bf469e20154aebd7584d139e (plain) (blame)
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
#ifndef NEWSBOAT_KEYCOMBINATION_H_
#define NEWSBOAT_KEYCOMBINATION_H_

#include <string>

namespace newsboat {

enum class ShiftState {
	Shift,
	NoShift,
};

enum class ControlState {
	Control,
	NoControl,
};

enum class AltState {
	Alt,
	NoAlt,
};

class KeyCombination {
public:
	explicit KeyCombination(const std::string& key,
		ShiftState shift = ShiftState::NoShift,
		ControlState control = ControlState::NoControl,
		AltState alt = AltState::NoAlt);

	static KeyCombination from_bindkey(const std::string& input);
	std::string to_bindkey_string() const;

	bool operator==(const KeyCombination& other) const;
	bool operator<(const KeyCombination& rhs) const;

	std::string get_key() const;
	bool has_shift() const;
	bool has_control() const;
	bool has_alt() const;

private:
	std::string key;
	ShiftState shift;
	ControlState control;
	AltState alt;
};

} // namespace newsboat

#endif /* NEWSBOAT_KEYCOMBINATION_H_ */