commit 76dc26fae1d0c179c5914b903b1640158801358a from: marcus date: Wed Jul 7 06:47:31 2010 UTC check selectBegin for out of bounds too (if you move the selection to the left or above the applet .x or .y would go < 0) commit - f9cda6a626cdf5ccc633e3d8366c2da17cdeeb8c commit + 76dc26fae1d0c179c5914b903b1640158801358a blob - c809580336a033ad7a076482efd664bb19fbc190 blob + 85b3cbde342132a95bb483ffeaacdd9625632cc4 --- de/mud/terminal/SwingTerminal.java +++ de/mud/terminal/SwingTerminal.java @@ -847,7 +847,15 @@ public class SwingTerminal extends Component return; } selection = ""; - // fix end.x and end.y, they can get over the border + // fix begin.x and begin.y, they can get over the borders + if (selectBegin.x < 0) selectBegin.x = 0; + if (selectBegin.y < 0) selectBegin.y = 0; + if (selectBegin.y >= buffer.charArray.length) + selectBegin.y = buffer.charArray.length - 1; + if (selectBegin.x > buffer.charArray[0].length) + selectBegin.x = buffer.charArray[0].length; + + // fix end.x and end.y, they can also get over the borders if (selectEnd.x < 0) selectEnd.x = 0; if (selectEnd.y < 0) selectEnd.y = 0; if (selectEnd.y >= buffer.charArray.length) @@ -857,7 +865,13 @@ public class SwingTerminal extends Component // NOTE: Selection includes invisible text as spaces! // (also leaves invisible non-whitespace selection ending as spaces) + if (debug > 0) System.err.println("selectEnd.x " + selectEnd.x); + if (debug > 0) System.err.println("selectEnd.y " + selectEnd.y); + if (debug > 0) System.err.println("selectBegin.x " + selectBegin.x); + if (debug > 0) System.err.println("selectBegin.y " + selectBegin.y); + if (selectBegin.y > selectEnd.y) System.err.println("selectBegin.y " + selectBegin.y + "larger than selectEnd.y " + selectEnd.y + "!"); + for (int l = selectBegin.y; l <= selectEnd.y; l++) { /* reinitialize buffer every loop */ StringBuffer selectionBuf = new StringBuffer(buffer.charArray[0].length);