From: SVN by r. <sv...@ca...> - 2007-11-14 21:28:43
|
Author: roy Date: 2007-11-14 22:26:47 +0100 (Wed, 14 Nov 2007) New Revision: 200 Modified: src/main/java/nl/improved/sqlclient/SQLShell.java Log: some quit command changes.. made last executed command the last in the history list Modified: src/main/java/nl/improved/sqlclient/SQLShell.java =================================================================== --- src/main/java/nl/improved/sqlclient/SQLShell.java 2007-11-14 21:22:34 UTC (rev 199) +++ src/main/java/nl/improved/sqlclient/SQLShell.java 2007-11-14 21:26:47 UTC (rev 200) @@ -126,7 +126,9 @@ commands.register("HELP[\\s]*.*", new HelpCommand()); commands.register("HISTORY[\\s]*.*", new HistoryCommand()); commands.register("SPOOL[\\s]*.*", new SpoolCommand()); - commands.register("(QUIT|EXIT|\\\\Q)[\\s]*", new QuitCommand()); + commands.register("QUIT[\\s]*", new QuitCommand("quit")); + commands.register("EXIT[\\s]*", new QuitCommand("exit")); + //commands.register("\\\\Q[\\s]*", new QuitCommand("\\q")); commands.register("@.*", new ExecuteBatchCommand()); MAX_LINE_LENGTH = Toolkit.getScreenWidth()-(2+PROMPT.length()+2+1); // 2 spaces bouds.. prompt + "> " @@ -312,9 +314,16 @@ if (executeCommand(sqlCommand)) { // clear command history if (commandIndex != commandHistory.size()-1) { + SQLCommand tmpLines = commandLines; commandLines = commandHistory.get(commandHistory.size()-1); + if (commandLines.getCommandString().equals("")) { + commandHistory.add(commandHistory.size()-1, tmpLines); + } else { + commandHistory.add(tmpLines); + commandLines = tmpLines; + } } - if (commandLines.getLines().size() != 1 || commandLines.getLines().get(0).length() != 0) { + if (!commandLines.getCommandString().equals("")) { commandLines = new SQLCommand(); commandHistory.add(commandLines); newLine(); @@ -947,6 +956,11 @@ * Exit the client. */ private class QuitCommand implements Command { + private String cmd; + + public QuitCommand(String cmd) { + this.cmd = cmd; + } public CharSequence execute(SQLCommand command) { hide(); // quit return "Application terminated."; @@ -955,7 +969,7 @@ return "Quit(exit) the application."; } public CharSequence getCommandString() { - return "quit"; + return cmd; } /** * Returns some tab completion info for the specified command. |