From: SVN by r. <sv...@ca...> - 2008-12-22 12:53:51
|
Author: roy Date: 2008-12-22 13:53:46 +0100 (Mon, 22 Dec 2008) New Revision: 331 Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java Log: fix cursor position when line is split up into multiple lines Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java =================================================================== --- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2008-12-17 13:47:37 UTC (rev 330) +++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2008-12-22 12:53:46 UTC (rev 331) @@ -18,10 +18,12 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.PrintStream; import java.io.PrintWriter; import java.io.StringWriter; import java.io.Writer; @@ -133,6 +135,14 @@ * Constructor. */ public AbstractSQLShellWindow() { + File errFile; + try { + errFile = File.createTempFile("sqlshell", ".err"); + errFile.deleteOnExit(); + System.setErr(new PrintStream(errFile)); + } catch (IOException ex) { + Logger.getLogger(AbstractSQLShellWindow.class.getName()).log(Level.SEVERE, null, ex); + } screen = new Screen(); char[] emptyLineChar = new char[getScreenWidth()]; Arrays.fill(emptyLineChar, ' '); @@ -443,6 +453,7 @@ repaint(); } }; + commandThread.setDaemon(true); commandThread.start(); } } @@ -516,9 +527,11 @@ } private synchronized void waitAndPaint() { + long oWait = wait; wait = System.currentTimeMillis(); - if (t == null || !t.isAlive()) { + if (t == null || !t.isAlive() || System.currentTimeMillis() - oWait > 4 ) { t = new RepaintThread(); + t.setDaemon(true); t.start(); } } @@ -738,12 +751,11 @@ currentLine.delete(lastSpace, currentLine.length()); if (lastChar == ' ') { nextLine.deleteCharAt(0); - cursorPosition.x--; } // check if the cursor postition > the new line length // calculate new x and go to nextline if (cursorPosition.x >= lastSpace) { - cursorPosition.x = cursorPosition.x - (lastSpace); + cursorPosition.x = (cursorPosition.x - (lastSpace))-1; cursorPosition.y++; } } |