ConsoleAdapter updateInputPrompt()

Hari Krishna Dara <[email protected]> Mon, 22 Nov 2004 19:28:00 -0800
Newsgroups gmane.comp.java.jswat.devel
Message-ID <[email protected]>
To plug ConsoleAdapter into other applications, I would like to
disable the prompt string completely, but currently it always prints
an ">" after the prompt. Is it not more appropriate to use this value
as part of the default prompt string and let user set whatever he
wants? Something like this:

    public void updateInputPrompt(String prompt) {
        if (prompt == null) {
            prompt = "> ";
        }
        inputPrompt = prompt;
    } // updateInputPrompt

And change the following line in run():

                    outputStream.printPrompt(inputPrompt + "> ");

to simply:

                    outputStream.printPrompt(inputPrompt);

Isn't this how most of the shell PS variables work anyway?

Nathan, if you agree, could you please apply the below patch? I doubt
if this is going to break any existing code (JEdit plugin doesn't use
this class).

Thanks,
Hari

*** ./classes/com/bluemarsh/jswat/ui/console/ConsoleAdapter.java.bak	Mon
Nov 22 19:26:14 2004
--- ./classes/com/bluemarsh/jswat/ui/console/ConsoleAdapter.java	Mon
Nov 22 19:26:16 2004
***************
*** 402,408 ****
       */
      public void updateInputPrompt(String prompt) {
          if (prompt == null) {
!             prompt = "";
          }
          inputPrompt = prompt;
      } // updateInputPrompt
--- 402,408 ----
       */
      public void updateInputPrompt(String prompt) {
          if (prompt == null) {
!             prompt = "> ";
          }
          inputPrompt = prompt;
      } // updateInputPrompt
***************
*** 464,470 ****
                      } catch (InterruptedException ie) {
                          // Ignore it.
                      }
!                     outputStream.printPrompt(inputPrompt + "> ");
                      String str = inputReader.readLine();
                      // User hitting enter resets this flag.
                      outputStream.needPrompt();
--- 464,470 ----
                      } catch (InterruptedException ie) {
                          // Ignore it.
                      }
!                     outputStream.printPrompt(inputPrompt);
                      String str = inputReader.readLine();
                      // User hitting enter resets this flag.
                      outputStream.needPrompt();