Permalink
Browse files

Make <Backspace> work when caret is at the beginning of the input line

  • Loading branch information...
ivan committed Apr 23, 2012
1 parent ff771ae commit f5d8cb28a6b70e860d663a7b11d4ea0178f2b824
Showing with 17 additions and 2 deletions.
  1. +17 −2 src/jvm/bsh/util/JConsole.java
@@ -224,17 +224,32 @@ private synchronized void type(KeyEvent e) {
break;
case (KeyEvent.VK_LEFT):
- case (KeyEvent.VK_BACK_SPACE):
if (text.getCaretPosition() <= cmdStart) {
- // See also default: case for backspace workaround
e.consume();
}
break;
+ case (KeyEvent.VK_BACK_SPACE):
+ if (text.getSelectedText() == null) {
+ if(text.getCaretPosition() <= cmdStart) {
+ e.consume();
+ }
+ } else {
+ if(text.getCaretPosition() < cmdStart) {
+ e.consume();
+ }
+ // TODO: prevent deletion when the caret is at
+ // the end of the user=> line
+ }
+ // See also default: case for backspace workaround
+ break;
+
case (KeyEvent.VK_DELETE):
if (text.getCaretPosition() < cmdStart) {
e.consume();
}
+ // TODO: prevent deletion when the caret is at
+ // the end of the user=> line
break;
case (KeyEvent.VK_RIGHT):

0 comments on commit f5d8cb2

Please sign in to comment.