|
From: SVN by r. <sv...@ca...> - 2008-10-14 19:30:44
|
Author: roy
Date: 2008-10-14 21:30:34 +0200 (Tue, 14 Oct 2008)
New Revision: 322
Modified:
src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java
Log:
improved caret position (again.. sigh)
Modified: src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2008-10-14 19:11:45 UTC (rev 321)
+++ src/main/java/nl/improved/sqlclient/charva/CharvaSQLShellWindow.java 2008-10-14 19:30:34 UTC (rev 322)
@@ -91,11 +91,11 @@
newText.append(seq.toString());
if (i < commandLines.size()-1) {
newText.append("\n");
- totalLineCount++;
}
+ totalLineCount++;
}
- if (totalLineCount > getScreenHeight()-commandLines.size()) {
- totalLineCount = getScreenHeight()-commandLines.size();
+ if (totalLineCount > getScreenHeight()-1) {
+ totalLineCount = getScreenHeight()-1;
}
String trimmed = trim(newText, screen.getPageUpCount());
if (trimmed.startsWith(textComponent.getText())) {
@@ -105,12 +105,11 @@
}
Point cursorPos = screen.getCursorPosition();
try {
- int start = textComponent.getLineStartOffset(totalLineCount - (commandLines.size() - cursorPos.y)+1);
+ int start = textComponent.getLineStartOffset(totalLineCount - (commandLines.size() - cursorPos.y));
textComponent.setCaretPosition(start + cursorPos.x + (Screen.PROMPT+" >").length());
} catch(Exception e) {
- debug("ERROR: failed to calculate line end: "+ totalLineCount +"-"+ cursorPos.y);
+ debug("ERROR: failed to calculate line end: "+ totalLineCount +"-"+ cursorPos.y +"/"+ getScreenHeight());
}
- // TODO fix caretposition
textComponent.draw();
}
|