cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
event.hpp
Go to the documentation of this file.
1/*
2* cpp-terminal
3* C++ library for writing multi-platform terminal applications.
4*
5* SPDX-FileCopyrightText: 2019-2024 cpp-terminal
6*
7* SPDX-License-Identifier: MIT
8*/
9
10#pragma once
11
14#include "cpp-terminal/key.hpp"
17
18#include <cstdint>
19#include <string>
20
21namespace Term
22{
23
24class Event
25{
26public:
27 enum class Type
28 {
29 Empty,
30 Key,
31 Screen,
32 Cursor,
33 Focus,
34 Mouse,
36 };
37 ~Event();
39 Event(const std::string& str);
40 Event(const Term::Key& key);
41 Event(const Term::Screen& screen);
42 Event(const Term::Cursor& cursor);
43 Event(const Term::Focus& focus);
44 Event(const Term::Mouse& mouse);
45 Event(const Term::Event& event);
46 Event(Term::Event&& event) noexcept;
47 Event& operator=(Event&& other) noexcept;
48 Event& operator=(const Term::Event& event);
49 bool empty() const;
50 Type type() const;
51 operator Term::Key() const;
52 operator Term::Screen() const;
53 operator Term::Cursor() const;
54 operator Term::Focus() const;
55 operator Term::Mouse() const;
56 operator std::string() const;
57
58 // getters
59 Key* get_if_key();
60 const Key* get_if_key() const;
62 const Screen* get_if_screen() const;
64 const Cursor* get_if_cursor() const;
66 const Focus* get_if_focus() const;
68 const Mouse* get_if_mouse() const;
69 std::string* get_if_copy_paste();
70 const std::string* get_if_copy_paste() const;
71
72private:
73 void parse(const std::string& str);
91};
92
93} // namespace Term
container m_container
Definition event.hpp:90
Type type() const
Definition event.cpp:203
Mouse * get_if_mouse()
Definition event.cpp:47
void parse(const std::string &str)
Definition event.cpp:207
bool empty() const
Definition event.cpp:179
operator Term::Cursor() const
Definition event.cpp:458
operator Term::Key() const
Definition event.cpp:452
Screen * get_if_screen()
Definition event.cpp:41
operator Term::Focus() const
Definition event.cpp:464
operator Term::Screen() const
Definition event.cpp:193
Key * get_if_key()
Definition event.cpp:29
Type m_Type
Definition event.hpp:89
Cursor * get_if_cursor()
Definition event.cpp:65
Focus * get_if_focus()
Definition event.cpp:91
std::string * get_if_copy_paste()
Definition event.cpp:77
operator Term::Mouse() const
Definition event.cpp:181
Event & operator=(Event &&other) noexcept
Definition event.cpp:161
Class to return the focus of the terminal.
Definition focus.hpp:22
Definition args.cpp:13
@ Cursor
Show the cursor.
Term::Screen m_Screen
Definition event.hpp:84
container(container &&)=delete
Term::Cursor m_Cursor
Definition event.hpp:83
Term::Focus m_Focus
Definition event.hpp:85
container & operator=(const container &)=delete
container(const container &)=delete
Term::Mouse m_Mouse
Definition event.hpp:86
std::string m_string
Definition event.hpp:87
container & operator=(container &&)=delete