@@ -55,6 +55,8 @@ int ScreenX;
55
55
int ScreenY ;
56
56
int ScrollTop ;
57
57
int ScrollBottom ;
58
+ int LastCursorX ;
59
+ int LastCursorY ;
58
60
59
61
char * pSavedScreen = NULL ;
60
62
static COORD ZeroCoord = {0 ,0 };
@@ -1092,7 +1094,7 @@ void ConScrollDownEntireBuffer()
1092
1094
1093
1095
if (!GetConsoleScreenBufferInfo (hOutputConsole , & ConsoleInfo ))
1094
1096
return ;
1095
- ConScrollDown (0 ,ConsoleInfo .dwSize .Y - 1 );
1097
+ ConScrollDown (0 , ConsoleInfo .dwSize .Y - 1 );
1096
1098
return ;
1097
1099
}
1098
1100
@@ -1102,7 +1104,7 @@ void ConScrollUpEntireBuffer()
1102
1104
1103
1105
if (!GetConsoleScreenBufferInfo (hOutputConsole , & ConsoleInfo ))
1104
1106
return ;
1105
- ConScrollUp (0 ,ConsoleInfo .dwSize .Y - 1 );
1107
+ ConScrollUp (0 , ConsoleInfo .dwSize .Y - 1 );
1106
1108
return ;
1107
1109
}
1108
1110
@@ -1141,15 +1143,15 @@ void ConScrollUp(int topline,int botline)
1141
1143
Fill .Attributes = ConsoleInfo .wAttributes ;
1142
1144
Fill .Char .AsciiChar = ' ' ;
1143
1145
1144
- ScrollConsoleScreenBuffer ( hOutputConsole ,
1146
+ BOOL bRet = ScrollConsoleScreenBuffer ( hOutputConsole ,
1145
1147
& ScrollRect ,
1146
1148
& ClipRect ,
1147
1149
destination ,
1148
1150
& Fill
1149
1151
);
1150
1152
}
1151
1153
1152
- void ConScrollDown (int topline ,int botline )
1154
+ void ConScrollDown (int topline , int botline )
1153
1155
{
1154
1156
SMALL_RECT ScrollRect ;
1155
1157
SMALL_RECT ClipRect ;
@@ -1160,32 +1162,32 @@ void ConScrollDown(int topline,int botline)
1160
1162
if (!GetConsoleScreenBufferInfo (hOutputConsole , & ConsoleInfo ))
1161
1163
return ;
1162
1164
1163
- if ((botline - topline ) == ConsoleInfo .dwSize .Y - 1 ) // scrolling whole buffer
1165
+ if ((botline - topline ) == ConsoleInfo .dwSize .Y - 1 ) // scrolling whole buffer
1164
1166
{
1165
1167
ScrollRect .Top = topline ;
1166
1168
ScrollRect .Bottom = botline ;
1167
1169
}
1168
1170
else
1169
1171
{
1170
- ScrollRect .Top = topline + ConsoleInfo .srWindow .Top + 1 ;
1172
+ ScrollRect .Top = topline + ConsoleInfo .srWindow .Top + 1 ;
1171
1173
ScrollRect .Bottom = botline + ConsoleInfo .srWindow .Top ;
1172
1174
}
1173
1175
1174
1176
ScrollRect .Left = 0 ;
1175
- ScrollRect .Right = ConScreenSizeX ()- 1 ;
1177
+ ScrollRect .Right = ConScreenSizeX () - 1 ;
1176
1178
1177
1179
ClipRect .Top = ScrollRect .Top ;
1178
1180
ClipRect .Bottom = ScrollRect .Bottom ;
1179
1181
ClipRect .Left = ScrollRect .Left ;
1180
1182
ClipRect .Right = ScrollRect .Right ;
1181
1183
1182
1184
destination .X = 0 ;
1183
- destination .Y = ScrollRect .Top - 1 ;
1185
+ destination .Y = ScrollRect .Top - 1 ;
1184
1186
1185
1187
Fill .Attributes = ConsoleInfo .wAttributes ;
1186
1188
Fill .Char .AsciiChar = ' ' ;
1187
1189
1188
- ScrollConsoleScreenBuffer ( hOutputConsole ,
1190
+ BOOL bRet = ScrollConsoleScreenBuffer ( hOutputConsole ,
1189
1191
& ScrollRect ,
1190
1192
NULL ,
1191
1193
destination ,
@@ -1224,8 +1226,20 @@ void ConSetCursorPosition(int x, int y)
1224
1226
Coord .X = (short )(x );
1225
1227
Coord .Y = (short )(y );
1226
1228
1229
+ if ((y > ConsoleInfo .dwSize .Y - 1 ) && y > LastCursorY ) {
1230
+ for (int n = LastCursorY ; n < y ; n ++ )
1231
+ GoToNextLine ();
1232
+ }
1233
+
1234
+ if (y >= ConsoleInfo .dwSize .Y ) {
1235
+ Coord .Y = ConsoleInfo .dwSize .Y - 1 ;
1236
+ }
1237
+
1227
1238
if (!SetConsoleCursorPosition (hOutputConsole , Coord ))
1228
1239
rc = GetLastError ();
1240
+
1241
+ LastCursorX = x ;
1242
+ LastCursorY = y ;
1229
1243
}
1230
1244
1231
1245
BOOL ConChangeCursor ( CONSOLE_CURSOR_INFO * pCursorInfo )
0 commit comments