Skip to content

Commit

Permalink
[SQLLINE-417] Update jline to 3.18.0, add geshi color scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
snuyanzin committed Dec 20, 2020
1 parent edc3aab commit 86bfb12
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 19 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
<top.dir>${project.basedir}</top.dir>

<!-- The following list is sorted. -->
<checkstyle.version>8.36.2</checkstyle.version>
<checkstyle.version>8.37</checkstyle.version>
<docbkx-maven-plugin.version>2.0.17</docbkx-maven-plugin.version>
<forbiddenapis.version>3.1</forbiddenapis.version>
<h2.version>1.4.200</h2.version>
<hamcrest.version>2.2</hamcrest.version>
<hsqldb.version>2.5.0</hsqldb.version>
<jline.version>3.16.0</jline.version>
<jline.version>3.18.0</jline.version>
<jmockit.version>1.49</jmockit.version>
<junit.version>5.7.0</junit.version>
<maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
Expand Down
6 changes: 3 additions & 3 deletions src/docbkx/manual.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3245,9 +3245,9 @@ java.sql.SQLException: ORA-00942: table or view does not exist
<title>colorscheme</title>
<para>
If <literal>chester</literal>/<literal>dark</literal>
/<literal>dracula</literal>/<literal>light</literal>
/<literal>obsidian</literal>/<literal>solarized</literal>
/<literal>vs2010</literal>,
/<literal>dracula</literal>/<literal>geshi</literal>
/<literal>light</literal>/<literal>obsidian</literal>
/<literal>solarized</literal>/<literal>vs2010</literal>,
then this scheme will be used for command/sql syntax highlighting.
If <literal>default</literal> then there is no syntax highlighting.
</para>
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/sqlline/BuiltInHighlightStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
* <a href="https://github.com/ozmoroz/ozbsidian-sqldeveloper">
* ozmoroz's OzBsidian colour scheme for Oracle SQL Developer</a>.
*
* <p>Similarly, the {@link #GESHI} style is inspired by
* <a href="https://github.com/GeSHi/geshi-1.0/blob/master/src/geshi/sql.php">
* GeSHi - Generic Syntax Highlighter for sql</a>
*
* @see HighlightStyle
*/
enum BuiltInHighlightStyle {
Expand All @@ -42,7 +46,14 @@ enum BuiltInHighlightStyle {
DRACULA(BOLD_MAGENTA, BOLD_WHITE, GREEN, RED, ITALIC_CYAN, YELLOW, WHITE),
SOLARIZED(BOLD_YELLOW, BOLD_BLUE, GREEN, RED, ITALIC_BRIGHT, CYAN, BLUE),
VS2010(BOLD_BLUE, BOLD_WHITE, RED, MAGENTA, ITALIC_GREEN, BRIGHT, WHITE),
OBSIDIAN(BOLD_GREEN, BOLD_WHITE, RED, MAGENTA, ITALIC_BRIGHT, YELLOW, WHITE);
OBSIDIAN(BOLD_GREEN, BOLD_WHITE, RED, MAGENTA, ITALIC_BRIGHT, YELLOW, WHITE),
GESHI(AttributedStyle.BOLD.foreground(99, 33, 33),
BOLD_WHITE,
AttributedStyle.DEFAULT.foreground(0x66, 0xCC, 0x66),
AttributedStyle.DEFAULT.foreground(0x0, 0x0, 0x99),
AttributedStyle.DEFAULT.italic().foreground(0x80, 0x80, 0x80),
AttributedStyle.DEFAULT.foreground(0xCC, 0x66, 0xCC),
WHITE);

final HighlightStyle style;

Expand Down
1 change: 1 addition & 0 deletions src/main/java/sqlline/SqlLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ public LineReader getConsoleReader(InputStream inputStream,
.variable(LineReader.LINE_OFFSET, 1) // start line numbers with 1
.option(LineReader.Option.AUTO_LIST, false)
.option(LineReader.Option.AUTO_MENU, true)
.option(LineReader.Option.GROUP_PERSIST, true)
.option(LineReader.Option.DISABLE_EVENT_EXPANSION, true);
final LineReader lineReader;
if (inputStream == null) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/sqlline/SqlLine.properties
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ variables:\
\n max height/width based on terminal size\
\nautoSave true/false Automatically save preferences\
\ncolor true/false Control whether color is used for display\
\ncolorScheme chester/dark/dracula/light/obsidian/solarized/vs2010\
\ncolorScheme chester/dark/dracula/geshi/light/obsidian/solarized/vs2010\
\n Syntax highlight schema\
\nconfirm true/false Whether to prompt for confirmation before running\
\n commands specified in confirmPattern (default:\
Expand Down Expand Up @@ -325,7 +325,7 @@ cmd-usage: Usage: java sqlline.SqlLine \n \
\ -ac <class name> application configuration class name\n \
\ -ph <class name> prompt handler class name\n \
\ --color=[true/false] control whether color is used for display\n \
\ --colorScheme=[chester/dark/dracula/light/obsidian/solarized/vs2010]\
\ --colorScheme=[chester/dark/dracula/geshi/light/obsidian/solarized/vs2010]\
\ syntax highlight schema\n \
\ --confirm=[true/false] confirm before executing commands specified in confirmPattern\n \
\ --confirmPattern=[pattern] pattern of commands to prompt confirmation\n \
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/sqlline/manual.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ Variable Value Description
autoCommit true/false Enable/disable automatic transaction commit
autoSave true/false Automatically save preferences
color true/false Control whether color is used for display
colorScheme chester/dark/dracula/light/obsidian/solarized/vs2010
colorScheme chester/dark/dracula/geshi/light/obsidian/solarized/vs2010
Syntax highlight schema
confirm true/false Prompts for confirmation before running
commands specified in confirmPattern
Expand Down Expand Up @@ -2295,7 +2295,7 @@ If true, then output to the terminal will use color for a more pleasing visual e

colorScheme

If chester/dark/dracula/light/obsidian/solarized/vs2010, then this scheme will be used for command/sql syntax highlighting. If default then there is no syntax highlighting.
If chester/dark/dracula/geshi/light/obsidian/solarized/vs2010, then this scheme will be used for command/sql syntax highlighting. If default then there is no syntax highlighting.

confirm

Expand Down
18 changes: 9 additions & 9 deletions src/test/java/sqlline/SqlLineHighlighterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -773,13 +773,13 @@ private void checkHighlightedLine(
final AttributedString attributedString =
highlighter.highlight(sqlLine.getLineReader(), line);
final HighlightStyle highlightStyle = sqlLine.getHighlightStyle();
int commandStyle = highlightStyle.getCommandStyle().getStyle();
int keywordStyle = highlightStyle.getKeywordStyle().getStyle();
int singleQuoteStyle = highlightStyle.getQuotedStyle().getStyle();
int identifierStyle = highlightStyle.getIdentifierStyle().getStyle();
int commentStyle = highlightStyle.getCommentStyle().getStyle();
int numberStyle = highlightStyle.getNumberStyle().getStyle();
int defaultStyle = highlightStyle.getDefaultStyle().getStyle();
long commandStyle = highlightStyle.getCommandStyle().getStyle();
long keywordStyle = highlightStyle.getKeywordStyle().getStyle();
long singleQuoteStyle = highlightStyle.getQuotedStyle().getStyle();
long identifierStyle = highlightStyle.getIdentifierStyle().getStyle();
long commentStyle = highlightStyle.getCommentStyle().getStyle();
long numberStyle = highlightStyle.getNumberStyle().getStyle();
long defaultStyle = highlightStyle.getDefaultStyle().getStyle();

for (int i = 0; i < line.length(); i++) {
checkSymbolStyle(line, i, expectedHighlightStyle.commands,
Expand Down Expand Up @@ -811,7 +811,7 @@ private void checkDefaultLine(
SqlLineHighlighter defaultHighlighter) {
final AttributedString attributedString =
defaultHighlighter.highlight(sqlLine.getLineReader(), line);
int defaultStyle = AttributedStyle.DEFAULT.getStyle();
long defaultStyle = AttributedStyle.DEFAULT.getStyle();

for (int i = 0; i < line.length(); i++) {
if (Character.isWhitespace(line.charAt(i))) {
Expand Down Expand Up @@ -850,7 +850,7 @@ private void checkSymbolStyle(
int i,
BitSet styleBitSet,
AttributedString highlightedLine,
int style,
long style,
String styleName) {
if (styleBitSet.get(i)) {
assertEquals(i == 0 ? style + 32 : style,
Expand Down

0 comments on commit 86bfb12

Please sign in to comment.