Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1727 Groovy shell and Groovy swing console improvements
  3. GROOVY-2059

Add syntax highlighting, printing, search, and undo/redo to Groovy Console

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.1-beta-3
    • 1.1-beta-3
    • None
    • None
    • Patch

    Description

      The attached code can be unzipped into the groovy.ui package and simply build groovy. It will add the following to the Groovy Console:

      1) simple syntax highlighting for input text area
      2) color printing for input text area (ctrl-p)
      3) find/find next/replace functionality (ctrl-f/F3/ctrl-h)
      4) undo/redo (ctrl-z/ctrl-y)

      This was done by taking some utility classes hacked out a few years back and creating a scrollpane/textpane combination with this functionality, and then simply replacing the current pair in the Console Groovy class. What this means is that when a better, more robust solution comes along, replacing this bit of extra functionality will be trivial.

      The code was originally written against JDK 1.4.x and should work that far back. It probably won't recognize enums (even though that keyword will be recognized) and certainly not annotations, either, even as the it was just a little Java parser was updated to instead recognize Groovy triple single/double quotes and a couple of extra Groovy keywords (in, as).

      This was run and tested briefly on a Windows Vista box, and run against JDK 1.6.2, compiling against a snapshot of Groovy 1.1-beta-3. Any help testing against a Linux or a Mac (or requests on how it can be made better against those platforms) would be appreciated.

      To use unzip the file into the groovy.ui package and recompile. This assumes that nothing has been done to Console.groovy (the only original groovy code touched; six lines or so) since this has been posted, so check first. Otherwise, create a ConsoleTextEditor and replace inputArea with consoleTextArea().getTextEditor().

      Please note that this code is not a robust, long term solution, but rather a stop gap until a better one can be created. It was low hanging fruit and looked moderately useful, so it's there if anyone wants it, there it is. Hopefully it's good enough for general use.

      Attachments

        1. highlightingConsole.zip
          28 kB
          Evan Slatis
        2. highlightingConsole.jpg
          99 kB
          Evan Slatis

        Activity

          People

            shemnon Daniel Ferrin
            hippyod Evan Slatis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: