Skip to content

Commit f7e4643

Browse files
committed
Remove m_grabbed
1 parent 44c04be commit f7e4643

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

src/utils/terminal_pager.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "terminal_pager.hpp"
1414

1515
terminal_pager::terminal_pager()
16-
: m_grabbed(false), m_rows(0), m_columns(0), m_start_row_index(0)
16+
: m_rows(0), m_columns(0), m_start_row_index(0)
1717
{
1818
maybe_grab_cout();
1919
}
@@ -46,11 +46,14 @@ std::string terminal_pager::get_input() const
4646
void terminal_pager::maybe_grab_cout()
4747
{
4848
// Unfortunately need to access _internal namespace of termcolor to check if a tty.
49-
if (!m_grabbed && termcolor::_internal::is_atty(std::cout))
49+
if (termcolor::_internal::is_atty(std::cout))
5050
{
5151
// Should we do anything with cerr?
5252
m_cout_rdbuf = std::cout.rdbuf(&m_stringbuf);
53-
m_grabbed = true;
53+
}
54+
else
55+
{
56+
m_cout_rdbuf = std::cout.rdbuf();
5457
}
5558
}
5659

@@ -98,11 +101,7 @@ bool terminal_pager::process_input(const std::string& input)
98101

99102
void terminal_pager::release_cout()
100103
{
101-
if (m_grabbed)
102-
{
103-
std::cout.rdbuf(m_cout_rdbuf);
104-
m_grabbed = false;
105-
}
104+
std::cout.rdbuf(m_cout_rdbuf);
106105
}
107106

108107
void terminal_pager::render_terminal() const
@@ -166,11 +165,6 @@ void terminal_pager::scroll(bool up, bool page)
166165

167166
void terminal_pager::show()
168167
{
169-
if (!m_grabbed)
170-
{
171-
return;
172-
}
173-
174168
release_cout();
175169

176170
split_input_at_newlines(m_stringbuf.view());

src/utils/terminal_pager.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class terminal_pager
5454
void update_terminal_size();
5555

5656

57-
bool m_grabbed;
5857
std::stringbuf m_stringbuf;
5958
std::streambuf* m_cout_rdbuf;
6059
std::vector<std::string> m_lines;

0 commit comments

Comments
 (0)