Skip to content

Commit d825356

Browse files
committed
Fix windows console bug
Line input cursor was going crazy when input reached right side of the screen
1 parent c031349 commit d825356

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

library/Console-windows.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,13 @@ namespace DFHack
223223
size_t plen = prompt.size();
224224
const char * buf = raw_buffer.c_str();
225225
size_t len = raw_buffer.size();
226+
int cooked_cursor = raw_cursor;
226227

227-
while ((plen + raw_cursor) >= cols)
228+
while ((plen + cooked_cursor) >= cols)
228229
{
229230
buf++;
230231
len--;
231-
raw_cursor--;
232+
cooked_cursor--;
232233
}
233234
while (plen + len > cols)
234235
{
@@ -247,7 +248,7 @@ namespace DFHack
247248
output(tmp, inf.dwSize.X - (plen + len), len + plen, inf.dwCursorPosition.Y);
248249
free(tmp);
249250
}
250-
inf.dwCursorPosition.X = (SHORT)(raw_cursor + plen);
251+
inf.dwCursorPosition.X = (SHORT)(cooked_cursor + plen);
251252
SetConsoleCursorPosition(console_out, inf.dwCursorPosition);
252253
}
253254

0 commit comments

Comments
 (0)