MCPcopy Create free account
hub / github.com/demoth/jake2 / CheckResize

Method CheckResize

client/src/main/java/jake2/client/Console.java:209–262  ·  view source on GitHub ↗

If the line width has changed, reformat the buffer.

()

Source from the content-addressed store, hash-verified

207 * If the line width has changed, reformat the buffer.
208 */
209 static void CheckResize() {
210
211 int width = (ClientGlobals.viddef.getWidth() >> 3) - 2;
212 if (width > Defines.MAXCMDLINE)
213 width = Defines.MAXCMDLINE;
214
215 if (width == ClientGlobals.con.linewidth)
216 return;
217
218 if (width < 1) { // video hasn't been initialized yet
219 width = 38;
220 ClientGlobals.con.linewidth = width;
221 ClientGlobals.con.backedit = 0; // sfranzyshen
222 ClientGlobals.con.totallines = Defines.CON_TEXTSIZE
223 / ClientGlobals.con.linewidth;
224 Arrays.fill(ClientGlobals.con.text, (byte) ' ');
225 } else {
226 int oldwidth = ClientGlobals.con.linewidth;
227 ClientGlobals.con.linewidth = width;
228 ClientGlobals.con.backedit = 0; // sfranzyshen
229 int oldtotallines = ClientGlobals.con.totallines;
230 ClientGlobals.con.totallines = Defines.CON_TEXTSIZE
231 / ClientGlobals.con.linewidth;
232 int numlines = oldtotallines;
233
234 if (ClientGlobals.con.totallines < numlines)
235 numlines = ClientGlobals.con.totallines;
236
237 int numchars = oldwidth;
238
239 if (ClientGlobals.con.linewidth < numchars)
240 numchars = ClientGlobals.con.linewidth;
241
242 byte[] tbuf = new byte[Defines.CON_TEXTSIZE];
243 System
244 .arraycopy(ClientGlobals.con.text, 0, tbuf, 0,
245 Defines.CON_TEXTSIZE);
246 Arrays.fill(ClientGlobals.con.text, (byte) ' ');
247
248 for (int i = 0; i < numlines; i++) {
249 for (int j = 0; j < numchars; j++) {
250 ClientGlobals.con.text[(ClientGlobals.con.totallines - 1 - i)
251 * ClientGlobals.con.linewidth + j] = tbuf[((ClientGlobals.con.current
252 - i + oldtotallines) % oldtotallines)
253 * oldwidth + j];
254 }
255 }
256
257 Console.ClearNotify();
258 }
259
260 ClientGlobals.con.current = ClientGlobals.con.totallines - 1;
261 ClientGlobals.con.display = ClientGlobals.con.current;
262 }
263
264 static void ClearNotify() {
265 int i;

Callers 2

DrawConsoleMethod · 0.95
InitMethod · 0.95

Calls 2

ClearNotifyMethod · 0.95
getWidthMethod · 0.80

Tested by

no test coverage detected