-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #326 introducing new parameter to disable ansi colors on repl. …
…Backward compatible. Still no UI pref page to configure from the IDE
- Loading branch information
1 parent
5b3c9ac
commit f5b667f
Showing
4 changed files
with
57 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
....project.wollok.launch/src/org/uqbar/project/wollok/launch/repl/ReplOutputFormatter.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.uqbar.project.wollok.launch.repl | ||
|
||
import static org.fusesource.jansi.Ansi.* | ||
import static org.fusesource.jansi.Ansi.Color.* | ||
|
||
/** | ||
* An strategy to allow ANSI colors output | ||
* or regular output without special characters | ||
* | ||
* @author jfernandes | ||
*/ | ||
interface ReplOutputFormatter { | ||
def String errorStyle(CharSequence msg) | ||
def String importantMessageStyle(CharSequence msg) | ||
def String messageStyle(CharSequence msg) | ||
def String returnStyle(CharSequence msg) | ||
} | ||
|
||
class RegularReplOutputFormatter implements ReplOutputFormatter { | ||
override def errorStyle(CharSequence msg) { msg.toString } | ||
override def importantMessageStyle(CharSequence msg) { msg.toString } | ||
override def messageStyle(CharSequence msg) { msg.toString } | ||
override def returnStyle(CharSequence msg) { msg.toString } | ||
} | ||
|
||
|
||
class AnsiColoredReplOutputFormatter implements ReplOutputFormatter { | ||
static val COLOR_RETURN_VALUE = BLUE | ||
static val COLOR_ERROR = RED | ||
static val COLOR_REPL_MESSAGE = CYAN | ||
|
||
override def errorStyle(CharSequence msg) { ansi.fg(COLOR_ERROR).a(msg).reset.toString() } | ||
override def importantMessageStyle(CharSequence msg) { ansi.fg(COLOR_REPL_MESSAGE).bold.a(msg).reset.toString() } | ||
override def messageStyle(CharSequence msg) { ansi.fg(COLOR_REPL_MESSAGE).a(msg).reset.toString() } | ||
override def returnStyle(CharSequence msg) { ansi().fg(COLOR_RETURN_VALUE).a(msg).reset.toString() } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters