From 431271228215fb9adf6dc0c8017d4e559766d065 Mon Sep 17 00:00:00 2001 From: mattirn Date: Mon, 20 Dec 2021 08:33:34 +0100 Subject: [PATCH] REPL demo: add light.nanorctheme and rename default theme to dark --- demo/src/main/java/org/jline/demo/Repl.java | 2 +- demo/src/main/scripts/command.nanorc | 2 +- .../{default.nanorctheme => dark.nanorctheme} | 20 ++++---- demo/src/main/scripts/init.jline | 8 ++- demo/src/main/scripts/light.nanorctheme | 51 +++++++++++++++++++ 5 files changed, 68 insertions(+), 15 deletions(-) rename demo/src/main/scripts/{default.nanorctheme => dark.nanorctheme} (90%) create mode 100644 demo/src/main/scripts/light.nanorctheme diff --git a/demo/src/main/java/org/jline/demo/Repl.java b/demo/src/main/java/org/jline/demo/Repl.java index cebc1a397..7c1ef47b8 100644 --- a/demo/src/main/java/org/jline/demo/Repl.java +++ b/demo/src/main/java/org/jline/demo/Repl.java @@ -265,7 +265,7 @@ public static void main(String[] args) { File jnanorcFile = Paths.get(root, DEFAULT_NANORC_FILE).toFile(); if (!jnanorcFile.exists()) { try (FileWriter fw = new FileWriter(jnanorcFile)) { - fw.write("theme " + root + "nanorc/*.nanorctheme\n"); + fw.write("theme " + root + "nanorc/dark.nanorctheme\n"); fw.write("include " + root + "nanorc/*.nanorc\n"); } } diff --git a/demo/src/main/scripts/command.nanorc b/demo/src/main/scripts/command.nanorc index af8f46e88..616d94042 100644 --- a/demo/src/main/scripts/command.nanorc +++ b/demo/src/main/scripts/command.nanorc @@ -1,6 +1,6 @@ syntax "COMMAND" -FUNCTION: "[a-zA-Z]+[a-zA-Z0-9]*" +COMMAND: "[a-zA-Z]+[a-zA-Z0-9]*" VARIABLE: ".*=" PLAIN: "(\"|'|\.|=|:|\[|,|\])" COMMENT: "(^|\\s+)#.*$" diff --git a/demo/src/main/scripts/default.nanorctheme b/demo/src/main/scripts/dark.nanorctheme similarity index 90% rename from demo/src/main/scripts/default.nanorctheme rename to demo/src/main/scripts/dark.nanorctheme index 02bcdce3e..657abbaff 100644 --- a/demo/src/main/scripts/default.nanorctheme +++ b/demo/src/main/scripts/dark.nanorctheme @@ -1,5 +1,5 @@ # -# This file describes a default scheme for nanorc syntax highlighting. +# This file describes a default scheme for nanorc syntax highlighting for terminals with dark background # # Lines that start with a # character are comments. # Comments are ignored. Empty lines are ignored too. Leading/trailing white @@ -34,33 +34,31 @@ BOOLEAN brightwhite NULL cyan NUMBER blue VARIABLE brightyellow -PACKAGE green,,faint +PACKAGE green,faint CLASS green CONSTANT yellow OPERATOR yellow +COMMAND brightgreen OPTION yellow KEYWORD brightwhite -MACRO brightmagenta -DELIMITER brightred JUMP brightcyan SECTION brightgreen -TAG brightwhite ATTRIBUTE green -CHARREF brightred PATH brightblue -URL brightblue -EMAIL brightblue +EXECUTABLE green +LINK cyan +TITLE brightblue ESCAPE black,cyan -REGEXP blue,cyan +DEBUG brightmagenta +ERROR red TODO brightwhite,cyan WARNING ,red WHITESPACE ,green HEADER bold,!blue,~grey7,underline ROW_NUMBER bold,!blue,~grey7 ROW_STYLE ,~grey15 -DEBUG brightmagenta LIST_BACKGROUND ,~grey42 -LIST_GROUP ~greenyellow +LIST_GROUP yellow # # mixin # diff --git a/demo/src/main/scripts/init.jline b/demo/src/main/scripts/init.jline index a10f3f987..47b83101c 100644 --- a/demo/src/main/scripts/init.jline +++ b/demo/src/main/scripts/init.jline @@ -18,7 +18,9 @@ CONSOLE_OPTIONS['docs'].put('java.*',['https://docs.oracle.com/javase/8/docs/api 'http://docs.groovy-lang.org/latest/html/groovy-jdk/']) CONSOLE_OPTIONS['docs'].put('.*/java.*','https://docs.oracle.com/javase/8/docs/api/') CONSOLE_OPTIONS['docs'].put('org/jline/.*','https://www.javadoc.io/doc/org.jline/jline/latest/') -CONSOLE_OPTIONS.PRNT_COLORS = 'th=HEADER:rn=ROW_NUMBER:rs=ROW_STYLE:mk=ATTRIBUTE:em=WARNING:vs=DEBUG' +CONSOLE_OPTIONS.PRNT_COLORS = 'th=HEADER:rn=ROW_NUMBER:rs=ROW_STYLE:mk=ATTRIBUTE:em=ERROR:vs=DEBUG' +CONSOLE_OPTIONS.LS_COLORS = 'di=PATH:ex=EXECUTABLE:ln=LINK:fi=' +CONSOLE_OPTIONS.HELP_COLORS = "ti=TITLE:co=1:ar=3:op=OPTION" CONSOLE_OPTIONS.READER_COLORS = [:] CONSOLE_OPTIONS['READER_COLORS'].put('COMPLETION_STYLE_LIST_BACKGROUND', 'LIST_BACKGROUND') CONSOLE_OPTIONS['READER_COLORS'].put('COMPLETION_STYLE_LIST_GROUP', 'LIST_GROUP') @@ -91,7 +93,9 @@ GROOVY_OPTIONS.metaMethodsCompletion = false GROOVY_OPTIONS.allClassesCompletion = false GROOVY_OPTIONS.allConstructorsCompletion = false GROOVY_OPTIONS.syntheticMethodsCompletion = false - +GROOVY_OPTIONS.GROOVY_COLORS = 'ti=TITLE:me=ERROR' +GROOVY_OPTIONS.nanorcSyntax = 'Java' +GROOVY_OPTIONS.nanorcValue = 'GRON' # # custom Groovy pipes # diff --git a/demo/src/main/scripts/light.nanorctheme b/demo/src/main/scripts/light.nanorctheme new file mode 100644 index 000000000..dc617d3b1 --- /dev/null +++ b/demo/src/main/scripts/light.nanorctheme @@ -0,0 +1,51 @@ +# +# This file describes a default scheme for nanorc syntax highlighting for terminals with light background. +# + +PLAIN black +FUNCTION green +STRING cyan +COMMENT brightcyan +DOC_COMMENT cyan +TYPE brightblue +BOOLEAN brightblack +NULL cyan +NUMBER blue +VARIABLE brightyellow +PACKAGE green,faint +CLASS green +CONSTANT yellow +OPERATOR yellow +COMMAND green +OPTION yellow +KEYWORD brightblack +JUMP cyan +SECTION green +ATTRIBUTE green +PATH brightblue +EXECUTABLE green +LINK cyan +TITLE brightblue +ESCAPE black,cyan +DEBUG brightmagenta +ERROR red +TODO brightwhite,cyan +WARNING ,lightred +WHITESPACE ,lightgreen +HEADER bold,!blue,~grey70,underline +ROW_NUMBER bold,!blue,~grey70 +ROW_STYLE ,~grey82 +LIST_BACKGROUND ,~grey70 +LIST_GROUP yellow +# +# mixin +# ++FUNCTION FUNCTION: "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]" \n PLAIN: "[(]" ++LINT WHITESPACE: "[[:space:]]+$" \n WARNING: "\t*" ++LONG_LINE_WARNING WARNING: "^.{81,}$" +# +# parser +# +$LINE_COMMENT COMMENT \n TODO: "FIXME|TODO|XXX" +$BLOCK_COMMENT COMMENT \n DOC_COMMENT: startWith=/** \n TODO: "FIXME|TODO|XXX" +$BALANCED_DELIMITERS STRING \n VARIABLE: continueAs=\s*: