Skip to content

Commit

Permalink
Avoid using DECDMAC when macros aren't supported
Browse files Browse the repository at this point in the history
Some terminals can end up echoing part of the sequence to the screen if
they don't have macro support.
  • Loading branch information
j4james committed Mar 21, 2024
1 parent 298362c commit d585f73
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ macro_manager::macro_manager(const capabilities& caps, const options& options)
: _caps{caps}, _options{options}
{
// Clear existing macros first to make sure we have space.
std::cout << "\033P0;1;0!z\033\\";
if (_caps.has_macros)
std::cout << "\033P0;1;0!z\033\\";
const auto x_indent = std::max((caps.width - engine::width * 2) / 4, 0);
const auto y_indent = std::max((caps.height - engine::height) / 2, 1);
_init_scrollers(x_indent, y_indent);
Expand All @@ -41,7 +42,8 @@ macro_manager::macro_manager(const capabilities& caps, const options& options)
macro_manager::~macro_manager()
{
// Clean out our macros on exit.
std::cout << "\033P0;1;0!z\033\\";
if (_caps.has_macros)
std::cout << "\033P0;1;0!z\033\\";
}

macro macro_manager::create(std::function<void(builder&)> callback)
Expand Down

0 comments on commit d585f73

Please sign in to comment.