summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-01-13 10:10:32 +0000
committerPaul Phillips <paulp@improving.org>2011-01-13 10:10:32 +0000
commit93b4e617dbf30bf8765197cbe892ac67b4b3aa9e (patch)
tree75ef08a6976b945dd2a7a3730ac7c270e6df00a8
parentc865d35d853452312654d026ea658c9e104388a9 (diff)
downloadscala-93b4e617dbf30bf8765197cbe892ac67b4b3aa9e.tar.gz
scala-93b4e617dbf30bf8765197cbe892ac67b4b3aa9e.tar.bz2
scala-93b4e617dbf30bf8765197cbe892ac67b4b3aa9e.zip
Fix for a jline paste bug. No review.
-rw-r--r--lib/jline.jar.desired.sha12
-rw-r--r--src/jline/src/main/java/jline/UnixTerminal.java2
-rw-r--r--src/jline/src/main/java/jline/WindowsTerminal.java2
-rw-r--r--src/jline/src/main/java/jline/console/ConsoleReader.java38
4 files changed, 20 insertions, 24 deletions
diff --git a/lib/jline.jar.desired.sha1 b/lib/jline.jar.desired.sha1
index 6857f5f24d..0bf735a895 100644
--- a/lib/jline.jar.desired.sha1
+++ b/lib/jline.jar.desired.sha1
@@ -1 +1 @@
-2a6d6dd4da89695f0c28ccc08cf388a4d84062b7 ?jline.jar
+e06409074cdbff3fd4d307fca52e93cfe2e509ee ?jline.jar
diff --git a/src/jline/src/main/java/jline/UnixTerminal.java b/src/jline/src/main/java/jline/UnixTerminal.java
index 37f18aea4e..755d899765 100644
--- a/src/jline/src/main/java/jline/UnixTerminal.java
+++ b/src/jline/src/main/java/jline/UnixTerminal.java
@@ -28,7 +28,7 @@ import static jline.console.Key.*;
* <em>/dev/tty</em> file to disable character echoing and enable
* character input. All known unix systems (including
* Linux and Macintosh OS X) support the <em>stty</em>), so this
- * implementation should work for an reasonable POSIX sys.
+ * implementation should work for an reasonable POSIX system.
*
* @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
* @author <a href="mailto:dwkemp@gmail.com">Dale Kemp</a>
diff --git a/src/jline/src/main/java/jline/WindowsTerminal.java b/src/jline/src/main/java/jline/WindowsTerminal.java
index 4304d6d473..dcaa3a9cde 100644
--- a/src/jline/src/main/java/jline/WindowsTerminal.java
+++ b/src/jline/src/main/java/jline/WindowsTerminal.java
@@ -302,7 +302,7 @@ public class WindowsTerminal
* control keys are processed by the system and are not returned in the
* ReadFile or ReadConsole buffer. If the ENABLE_LINE_INPUT mode is also
* enabled, backspace, carriage return, and linefeed characters are handled
- * by the sys.
+ * by the system.
*/
ENABLE_PROCESSED_INPUT(1),
diff --git a/src/jline/src/main/java/jline/console/ConsoleReader.java b/src/jline/src/main/java/jline/console/ConsoleReader.java
index b49966cf7e..660bb0cbc2 100644
--- a/src/jline/src/main/java/jline/console/ConsoleReader.java
+++ b/src/jline/src/main/java/jline/console/ConsoleReader.java
@@ -555,8 +555,20 @@ public class ConsoleReader
if (mask != null) {
Arrays.fill(chars, mask);
}
-
- print(chars);
+ if (terminal.hasWeirdWrap()) {
+ // need to determine if wrapping will occur:
+ int width = terminal.getWidth();
+ int pos = getCursorPosition();
+ for (int i = 0; i < chars.length; i++) {
+ print(chars[i]);
+ if ((pos + i + 1) % width == 0) {
+ print(32); // move cursor to next line by printing dummy space
+ print(13); // CR / not newline.
+ }
+ }
+ } else {
+ print(chars);
+ }
clearAhead(clear, chars.length);
if (terminal.isAnsiSupported()) {
if (chars.length > 0) {
@@ -571,7 +583,7 @@ public class ConsoleReader
// best guess on whether the cursor is in that weird location...
// Need to do this without calling ansi cursor location methods
// otherwise it breaks paste of wrapped lines in xterm.
- if (getCursorPosition() == width
+ if (getCursorPosition() > 0 && (getCursorPosition() % width == 0)
&& buf.cursor == buf.length() && clear == 0) {
// the following workaround is reverse-engineered from looking
// at what bash sent to the terminal in the same situation
@@ -603,20 +615,10 @@ public class ConsoleReader
}
if (terminal.isAnsiSupported()) {
- // it's possible the real cursor is in the last column of a terminal
- // with weird wrapping.
int width = terminal.getWidth();
int screenCursorCol = getCursorPosition() + delta;
- if (delta > 0 && terminal.hasWeirdWrap()
- && screenCursorCol % width == 0) {
- // need to clear out the line below - cursor has not wrapped
- printAnsiSequence("B");
- printAnsiSequence("2K");
- printAnsiSequence("A");
- } else {
- // clear current line
- printAnsiSequence("K");
- }
+ // clear current line
+ printAnsiSequence("K");
// if cursor+num wraps, then we need to clear the line(s) below too
int curCol = screenCursorCol % width;
int endCol = (screenCursorCol + num - 1) % width;
@@ -654,12 +656,6 @@ public class ConsoleReader
int width = getTerminal().getWidth();
int cursor = getCursorPosition();
int realCursor = cursor + num;
- // adjust cursor if it did not wrapped on its own
- if (terminal.hasWeirdWrap() && realCursor%width == 0) {
- if (getCurrentPosition() - 1 != realCursor%width) {
- realCursor--;
- }
- }
int realCol = realCursor % width;
int newCol = cursor % width;
int moveup = num / width;