Skip to content

Commit

Permalink
screen_buffer::set_cursor() should be relative to the visible area.
Browse files Browse the repository at this point in the history
  • Loading branch information
mridgers committed Jun 28, 2018
1 parent 5c624ed commit 8fb24ea
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions clink/terminal/src/win_screen_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,14 @@ void win_screen_buffer::set_cursor(int column, int row)
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(m_handle, &csbi);

COORD xy = {
clamp(column, 0, csbi.dwSize.X - 1),
clamp(row, 0, csbi.dwSize.Y - 1),
};
const SMALL_RECT& window = csbi.srWindow;
int width = (window.Right - window.Left) + 1;
int height = (window.Bottom - window.Top) + 1;

column = clamp(column, 0, width);
row = clamp(row, 0, height);

COORD xy = { window.Left + column, window.Top + row };
SetConsoleCursorPosition(m_handle, xy);
}

Expand Down

0 comments on commit 8fb24ea

Please sign in to comment.