cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
screen.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
12Term::Screen::Screen(const Term::Size& size) : m_size(size) {}
13
14const Term::Rows& Term::Screen::rows() const noexcept { return m_size.rows(); }
15
16const Term::Columns& Term::Screen::columns() const noexcept { return m_size.columns(); }
17
18bool Term::Screen::empty() const { return (0 == m_size.rows()) && (0 == m_size.columns()); }
19
20std::string Term::clear_screen() { return "\u001b[2J"; }
21
22std::string Term::screen_save()
23{
24 return "\u001b7\u001b[?1049h"; // save current cursor position, save screen FIXME
25}
26
27std::string Term::screen_load()
28{
29 return "\u001b[?1049l\u001b8"; // restores screen, restore current cursor position FIXME
30}
31
32bool Term::Screen::operator==(const Term::Screen& screen) const { return (this->rows() == screen.rows()) && (this->columns() == screen.columns()); }
33
34bool Term::Screen::operator!=(const Term::Screen& screen) const { return !(*this == screen); }
Screen()=default
const Columns & columns() const noexcept
Definition screen.cpp:16
const Rows & rows() const noexcept
Definition screen.cpp:14
bool operator==(const Term::Screen &screen) const
Definition screen.cpp:32
bool empty() const
Definition screen.cpp:18
bool operator!=(const Term::Screen &screen) const
Definition screen.cpp:34
std::string clear_screen()
Definition screen.cpp:20
std::string screen_save()
Definition screen.cpp:22
std::string screen_load()
Definition screen.cpp:27