|
From: SVN by r. <sv...@ca...> - 2008-03-02 13:48:55
|
Author: roy
Date: 2008-03-02 14:48:44 +0100 (Sun, 02 Mar 2008)
New Revision: 244
Modified:
src/main/java/nl/improved/sqlclient/SQLShell.java
Log:
made the order of the help for keymappings a little more readable (grouped)
Modified: src/main/java/nl/improved/sqlclient/SQLShell.java
===================================================================
--- src/main/java/nl/improved/sqlclient/SQLShell.java 2008-03-02 12:09:49 UTC (rev 243)
+++ src/main/java/nl/improved/sqlclient/SQLShell.java 2008-03-02 13:48:44 UTC (rev 244)
@@ -24,7 +24,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import jcurses.widgets.Window;
@@ -98,7 +98,7 @@
*/
private CommandManager commands = new CommandManager();
- private Map<String, KeyAction> actionKeys = new HashMap<String, KeyAction>();
+ private Map<String, KeyAction> actionKeys = new LinkedHashMap<String, KeyAction>();
/**
* Constructor.
@@ -184,6 +184,32 @@
return "Arrow Down:\tBrowse to next command in the history";
}
});
+ actionKeys.put(Integer.toString(InputChar.KEY_END),new KeyAction() {
+ public void execute() {
+ int curLineEnd = commandLines.getLines().get(cursorPosition.y).length();
+ if (cursorPosition.x == curLineEnd) {
+ cursorPosition.y = commandLines.getLines().size()-1;
+ CharSequence lineBuffer = commandLines.getLines().get(cursorPosition.y);
+ cursorPosition.x = lineBuffer.length();
+ } else {
+ cursorPosition.x = curLineEnd;
+ }
+ }
+ public CharSequence getHelp() {
+ return "End:\tMove the cursor to the end of the line, of if already there to the end of the command";
+ }
+ });
+ actionKeys.put(Integer.toString(InputChar.KEY_HOME), new KeyAction() {
+ public void execute() {
+ if (cursorPosition.x == 0) {
+ cursorPosition.y = 0;
+ }
+ cursorPosition.x = 0;
+ }
+ public CharSequence getHelp() {
+ return "Home:\tMove the cursor to the start of the line, of if already there to the start of the command";
+ }
+ });
actionKeys.put(Integer.toString(InputChar.KEY_BACKSPACE), new KeyAction() {
public void execute() {
if (cursorPosition.x == 0) {
@@ -218,54 +244,6 @@
return "Del:\tDelete the charactor at the current cursor position";
}
});
- actionKeys.put(Integer.toString(InputChar.KEY_PPAGE), new KeyAction() {
- public void execute() {
- if ((screenBuffer.size() + commandLines.getLines().size()
- - (Toolkit.getScreenHeight()/2) * pageUpCount) > 0) {
- pageUpCount++;
-
- }
- }
- public CharSequence getHelp() {
- return "PageUp:\tMove back in screen history";
- }
- });
- actionKeys.put(Integer.toString(InputChar.KEY_NPAGE), new KeyAction() {
- public void execute() {
- if (pageUpCount > 0) {
- pageUpCount--;
- }
- }
- public CharSequence getHelp() {
- return "PageDown:\tMove forward in screen history";
- }
- });
- actionKeys.put(Integer.toString(InputChar.KEY_END),new KeyAction() {
- public void execute() {
- int curLineEnd = commandLines.getLines().get(cursorPosition.y).length();
- if (cursorPosition.x == curLineEnd) {
- cursorPosition.y = commandLines.getLines().size()-1;
- CharSequence lineBuffer = commandLines.getLines().get(cursorPosition.y);
- cursorPosition.x = lineBuffer.length();
- } else {
- cursorPosition.x = curLineEnd;
- }
- }
- public CharSequence getHelp() {
- return "End:\tMove the cursor to the end of the line, of if already there at the end of the command";
- }
- });
- actionKeys.put(Integer.toString(InputChar.KEY_HOME), new KeyAction() {
- public void execute() {
- if (cursorPosition.x == 0) {
- cursorPosition.y = 0;
- }
- cursorPosition.x = 0;
- }
- public CharSequence getHelp() {
- return "End:\tMove the cursor to the start of the line, of if already there at the start of the command";
- }
- });
actionKeys.put("", new KeyAction() {
public void execute() {
StringBuilder lineBuffer = commandLines.getEditableLines().get(cursorPosition.y);
@@ -297,6 +275,28 @@
return "Control-U:\tRemove all characters before the cursor position";
}
});
+ actionKeys.put(Integer.toString(InputChar.KEY_PPAGE), new KeyAction() {
+ public void execute() {
+ if ((screenBuffer.size() + commandLines.getLines().size()
+ - (Toolkit.getScreenHeight()/2) * pageUpCount) > 0) {
+ pageUpCount++;
+
+ }
+ }
+ public CharSequence getHelp() {
+ return "PageUp:\tMove back in screen history";
+ }
+ });
+ actionKeys.put(Integer.toString(InputChar.KEY_NPAGE), new KeyAction() {
+ public void execute() {
+ if (pageUpCount > 0) {
+ pageUpCount--;
+ }
+ }
+ public CharSequence getHelp() {
+ return "PageDown:\tMove forward in screen history";
+ }
+ });
actionKeys.put("", new KeyAction() { //Ctrl+D
public void execute() {
if (commandLines.getCommandString().length() == 0) { //Quit on empty commandline, ignore otherwise
|