Skip to content

Commit e030186

Browse files
committed
Avoid include recursion
1 parent a975c2d commit e030186

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

cpp-terminal/terminal.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,3 @@ std::array<char, sizeof(Term::Terminal)> terminal_buffer; //NOLINT(fuchsia-stat
1919
Term::Terminal& Term::terminal = reinterpret_cast<Term::Terminal&>(::terminal_buffer); //NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)
2020

2121
std::string Term::terminal_title(const std::string& title) { return "\u001b]0;" + title + '\a'; }
22-
23-
std::string Term::clear_buffer() { return "\u001b[3J"; }

cpp-terminal/terminal.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,5 @@ extern Term::Terminal& terminal;
2222

2323
// change the title of the terminal, only supported by a few terminals
2424
std::string terminal_title(const std::string& title);
25-
// clear the screen and the scroll-back buffer
26-
std::string clear_buffer();
2725

2826
} // namespace Term

cpp-terminal/terminal_impl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#include "cpp-terminal/private/file.hpp"
1616
#include "cpp-terminal/screen.hpp"
1717
#include "cpp-terminal/style.hpp"
18-
#include "cpp-terminal/terminal.hpp" //FIXME avoid recursion
18+
19+
std::string Term::Terminal::clear() const noexcept { return "\u001b[3J"; }
1920

2021
Term::Options Term::Terminal::getOptions() const noexcept { return m_options; }
2122

@@ -36,7 +37,7 @@ void Term::Terminal::clean()
3637
unsetFocusEvents();
3738
unsetMouseEvents();
3839
if(getOptions().has(Option::NoCursor)) { Term::Private::out.write(cursor_on()); }
39-
if(getOptions().has(Option::ClearScreen)) { Term::Private::out.write(clear_buffer() + style(Style::Reset) + cursor_move(1, 1) + screen_load()); }
40+
if(getOptions().has(Option::ClearScreen)) { Term::Private::out.write(clear() + style(Style::Reset) + cursor_move(1, 1) + screen_load()); }
4041
set_unset_utf8();
4142
store_and_restore();
4243
}
@@ -53,7 +54,7 @@ catch(...)
5354

5455
void Term::Terminal::applyOptions() const
5556
{
56-
if(getOptions().has(Option::ClearScreen)) { Term::Private::out.write(screen_save() + clear_buffer() + style(Style::Reset) + cursor_move(1, 1)); }
57+
if(getOptions().has(Option::ClearScreen)) { Term::Private::out.write(screen_save() + clear() + style(Style::Reset) + cursor_move(1, 1)); }
5758
if(getOptions().has(Option::NoCursor)) { Term::Private::out.write(cursor_off()); }
5859
setMode();
5960
}

cpp-terminal/terminal_impl.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "cpp-terminal/terminal_initializer.hpp"
1515

1616
#include <cstddef>
17+
#include <string>
1718

1819
namespace Term
1920
{
@@ -34,6 +35,8 @@ class Terminal
3435
applyOptions();
3536
}
3637
Term::Options getOptions() const noexcept;
38+
// clear the screen and the scroll-back buffer
39+
std::string clear() const noexcept;
3740

3841
private:
3942
///

0 commit comments

Comments
 (0)