Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-350

Color shell support for Windows users

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 1.0.0.RC3
    • Component/s: @ ROO SHELL
    • Labels:
      None
    • Environment:
      Windows

      Description

      I've added support for colors in a Windows command prompt using a third party library called Jansi (http://jansi.fusesource.org). This library (APL-licensed) can wrap an OutputStream to parse ANSI escape codes and translates them to Windows native calls. It uses another library to make the native calls, called JNA (https://jna.dev.java.net) which is LGPL-licensed.

      I've attached a patch against trunk that uses Jansi on Windows if it's available: since it's trivial to use this without adding compile- nor runtime-time dependencies I've done so. Just by adding jansi-1.0.jar and jna.jar to your roo lib-dir you get coloring.

      I noticed that the colors are quite dark: this is not a problem with light backgrounds, but I found it a bit hard to read on black backgrounds. I've therefore also added support for using bright foreground colors to Roo: just add a system property currently called 'roo.bright' (feel free to rename it or change it to a proper cmd line param) and set it to 'true' to get brighter colors. This is not Windows-specific, it uses regular ANSI codes. See the patch for details. You could consider setting it to true by default in roo.bat for Windows users, although the bright green on my WinXP SP3 machine is almost white in cmd.exe (but not in command.com for some weird reason).

      Only slight downside is that colors on Windows are not restored after quitting the shell. Shouldn't even be noticeable for most users, but I have created a fix for this as well. Unfortunately that requires a small patch to the Jansi library: I'll see if I can get the author to publish a new version. It's done by closing the wrapped OutputStream, so the Roo code works the same with or without the fix present in the ansi jar.

      I'll leave it up to you to decide if you want to/can ship with the jansi and jna jars by default (esp. given the LGPL-license of jna), or if you just want to provide instructions on how to add these for users. Since the code compiles and runs without jansi, they just have to put the jars in the lib-dir.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jkuipers Joris Kuipers
                Reporter:
                jkuipers Joris Kuipers
              • Votes:
                1 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: