|
From: SVN by r. <sv...@ca...> - 2010-03-08 21:00:40
|
Author: roy
Date: 2010-03-08 21:33:49 +0100 (Mon, 08 Mar 2010)
New Revision: 468
Modified:
src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
src/main/java/nl/improved/sqlclient/SQLProperties.java
Log:
allow for setting to make \n insert a line
Modified: src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java
===================================================================
--- src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2010-01-29 11:05:26 UTC (rev 467)
+++ src/main/java/nl/improved/sqlclient/AbstractSQLShellWindow.java 2010-03-08 20:33:49 UTC (rev 468)
@@ -325,7 +325,7 @@
}
StringBuffer lineBuffer = getEditableCommand().getEditableLines().get(cursorPosition.y);
int previousBreak = SQLUtil.getLastBreakIndex(lineBuffer.substring(0, cursorPosition.x-1));
- if (lineBuffer.charAt(previousBreak) == ' ' || lineBuffer.charAt(previousBreak) == '\t') {
+ if (SQLUtil.isBreakCharacter(lineBuffer.charAt(previousBreak))) {
previousBreak++;
}
lineBuffer.delete(previousBreak, cursorPosition.x);
@@ -645,9 +645,27 @@
if (ke != null) {
ke.execute();
} else {
- if (inp.getCharacter() == '\n') { // newline... see if the command can be executed
+ if (inp.getCharacter() == '\n') {
+ //Y : insert a new line when the current line is not the last line
+ SQLCommand sqlCommand = getCommand();
+ if ("Y".equals(SQLProperties.getProperty(SQLProperties.PropertyName.ENTER_AT_END))) {
+ Point cursorPosition = screen.getCursorPosition();
+ if (sqlCommand.getLines().size() -1 > cursorPosition.y) {
+ StringBuffer newLine = new StringBuffer();
+ StringBuffer currentLine = sqlCommand.getEditableLines().get(cursorPosition.y);
+ if (currentLine.length() > cursorPosition.x) {
+ newLine.append(currentLine.substring(cursorPosition.x));
+ currentLine.delete(cursorPosition.x, currentLine.length());
+ }
+ sqlCommand.getEditableLines().add(cursorPosition.y+1, newLine);
+ cursorPosition.x = 0;
+ cursorPosition.y++;
+ repaint();
+ return;
+ }
+ }
+ // newline... see if the command can be executed
// execute the command
- SQLCommand sqlCommand = getCommand();
String command = sqlCommand.getCommandString();
// search command...
if (command.length() > 0 && command.charAt(0) == '/') { // search in history
Modified: src/main/java/nl/improved/sqlclient/SQLProperties.java
===================================================================
--- src/main/java/nl/improved/sqlclient/SQLProperties.java 2010-01-29 11:05:26 UTC (rev 467)
+++ src/main/java/nl/improved/sqlclient/SQLProperties.java 2010-03-08 20:33:49 UTC (rev 468)
@@ -25,7 +25,7 @@
public class SQLProperties {
- public static enum PropertyName {VERSION, CONFIG_VERSION, MOUSE_HANDLING};
+ public static enum PropertyName {VERSION, CONFIG_VERSION, ENTER_AT_END};
private static SQLProperties instance;
|