ZhiqiangGao / beanshell2

Automatically exported from code.google.com/p/beanshell2
0 stars 0 forks source link

JConsole improvement ideas + patch #107

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
>> What are the issues and expected behaviour?
Issue #1: (BUG)
  Patch to handle Unicode characters, submitted by Daniel Leuck,
  replaces all characters by \uXXXX, so the following operation blocks:
      new BufferedReader(console.getIn()).readLine();
  because it looks for \n and does not seem to understand \u000a char sequence
Expected:
  JConsole has a constructor accepting a charset name for the inReader and
  outPipeWriter. One can then supply e.g. "UTF-8" and have Unicode supported
  => The patch introduces inReader, outPipeWriter and the constructor
  The alternative fix would be to test for '\n' and '\r' and append them to
  buf in original form, and only replace other characters with \uXXXX

Issue #2: (BUG)
  If user selects all console content (Ctrl+A) and then types some text, the
  complete content is overwritten. When user confirms the input by pressing
  Enter, BadLocationException is reported in private enter() method
Expected:
  In forceCaretMoveToEnd(), make sure the selection does not extend before cmdStart:
    text.setSelectionStart(Math.max(cmdStart, text.getSelectionStart()));
    text.setSelectionEnd(Math.max(cmdStart, text.getSelectionEnd()));
  => The patch implements this fix

Issue #3: (BUG?)
  The "special hack for empty return" in private enter() method, replacing
  empty user input with a semi-collon ";" does not belong to JConsole.
  If special handling of empty user input is needed, it belongs to the Interpreter.
  E.g., for my use case in implementing Octave interpreter, it is perfectly fine
  for user to press Enter and submit a blank line
Expected:
  Do not interpret/adapt user input in JConsole, do it in the Interpreter.
  => The patch removes the semi-colon
  => BeanShell Interpreter should be corrected to properly handle empty user input
     (i.e. replace it with ";" if that's what's appropriate)

Issue #4: (BUG?)
  The private invokeAndWait() calls SwingUtilities.invokeAndWait which may
  throw InterruptedException when the thread is interrupted, i.e. requested
  to stop.
Expected:
  If InterruptedException is caught, printing stack trace should be skipped
  and the thread should gracefully terminate
  => The patch implements this fix

Issue #5: (FEATURE)
  Escape key has no action assigned
Expected:
  Similar to windows cmd, escape could clear the line as Ctrl+U does.
  => The patch implements this
  Even better solution would probably be to implement bash-like behaviour
  where Esc followed by Backspace deletes the last token

Issue #6: (FEATURE)
  When Interpreter depends on an external process, the process may be terminated
  but there's no way to prevent further user input in JConsole
Expected:
  GUIConsoleInterface extended with
    void setEditable(boolean editable);
  JConsole implements it by delegating to text.setEditable(editable);
  => The patch implements this

Issue #7: (FEATURE)
  Some interpreters support commands for clearing the console. For example,
  lunux bash supports 'clear', windows cmd supports 'cls' and Octave 'clc'
Expected:
  GUIConsoleInterface extended with
    void clear();
  JConsole implements it clearing the text: text.setText("");
  => The patch implements this

>> What version of the product are you using? On what operating system?
v2.1.8, running on Win7, more precisely, on 18.01.2015, I've done a svn 
checkout:
  svn checkout http://beanshell2.googlecode.com/svn/trunk/ beanshell2-read-only

>> Please provide any additional information below.
To clarify my view point, please note that I do not use BeanShell interpreter.
I am using only JConsole and GUIConsoleInterface for creating my own interpreter
for executing GNU Octave commands. Therefore, I look at GUIConsoleInterface ane
JConsole as general purpose tools, unrelated to their use in BeanShell

Original issue reported on code.google.com by obradovi...@gmail.com on 18 Jan 2015 at 3:37

Attachments: