cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
terminal_initializer.cpp
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
11
16
17#include <new>
18
20
22try
23{
24 if(0 == m_counter)
25 {
26 static const Private::FileInitializer files_init;
27 static std::vector<sighandler_t> m_handlers;
29 static Term::Private::Signals signals(m_handlers);
30 sighandler_t handler = [](int signum) { Term::Private::Signals::reset_and_raise(signum, m_handlers, Term::terminal); };
31 signals.setHandler(handler);
32 }
33 ++m_counter;
34}
35catch(...)
36{
38}
39
41try
42{
43 --m_counter;
44 if(0 == m_counter) { (&Term::terminal)->~Terminal(); }
45}
46catch(...)
47{
49}
static void reset_and_raise(int sign, std::vector< sighandler_t > &m_han, Term::Terminal &) noexcept
Definition signals.cpp:64
void setHandler(const sighandler_t &handler) noexcept
Definition signals.cpp:23
Term::Terminal & terminal
Definition terminal.cpp:19
void(*)(int) sighandler_t
Definition signals.hpp:14