Skip to content

Line Update #282

Answered by ArthurSonzogni
RoyalFoxy asked this question in Q&A
Discussion options

You must be logged in to vote

Hello:

I am using:
https://github.com/ArthurSonzogni/FTXUI/blob/master/src/ftxui/screen/screen.cpp

static const char MOVE_LEFT[] = "\r";
static const char MOVE_UP[] = "\x1B[1A";
static const char CLEAR_LINE[] = "\x1B[2K";

std::string Screen::ResetPosition(bool clear) {
  std::stringstream ss;
  if (clear) {
    ss << MOVE_LEFT << CLEAR_LINE;
    for (int y = 1; y < dimy_; ++y) {
      ss << MOVE_UP << CLEAR_LINE;
    }
  } else {
    ss << MOVE_LEFT;
    for (int y = 1; y < dimy_; ++y) {
      ss << MOVE_UP;
    }
  }
  return ss.str();
}

With \x1 being the byte with value 1.

More information on the specification:
https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-VT52-Mode

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ArthurSonzogni
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants