Code: Select all
echo "\033[0;31mI Am Red?"
Code: Select all
:put "\033[0;31mI Am Red?"
echo "\033[0;31mI Am Red?"
:put "\033[0;31mI Am Red?"
{ [/terminal style error]; :put "error text"; }
{ :put "\n"; [ /terminal style error ]; :put "error text"; [ /terminal style escaped ]; :put "escaped text"; :put "\n"; }
{ :put "\n"; [ /terminal style error ]; :put "hello "; [ /terminal style syntax-meta ]; [ /terminal cuu ]; :put "\tworld"; [ /terminal style syntax-old ]; [ /terminal cuu ]; :put "\t\t!!!"; :put "\n"; }
Didn't try it with input ... I occasionally use the colorization for output only, like a quick monitor script. The inkey stuff is super cleaver, but I just want some colorized text in the CLI for some stuff.I did not use tab but wrote the line again, again and again on each letter entered, till it was confirmed with an enter, NEXT line. I had even the option to correct earlier entries with the cursor keys.
:global RED do={/terminal style error}
:global BLUE do={/terminal style ambiguous}
:global WHITE do={/terminal style "syntax-old"}
:global blue do={/terminal style escaped}
:global cyan do={/terminal style "varname-local"}
:global red do={/terminal style varname}
:global plain do={/terminal style "syntax-val" }
:global yellow do={/terminal style "syntax-meta"}
:global strong do={/terminal style "syntax-noterm"}
:global nostyle do={/terminal style "none"}
{ $red; :put "red"; $RED; :put "reversed red" }
:put ("\1B[91mhello \1B[93mworld \1B[96m!!!")
Nice catch.But you can use escape sequences as well.
That seems true./terminal style does work in all terminal.
admin@MIkroTik > {/terminal style error; :put "red reversed test"; /terminal style none}
This may be a more complete example... What I didn't understand was:Ah, did not know this exists...
But you can use escape sequences as well.
/terminal/cuu
do {
:local RED do={/terminal style error}
:local BLUE do={/terminal style ambiguous}
:local WHITE do={/terminal style "syntax-old"}
:local blue do={/terminal style escaped}
:local cyan do={/terminal style "varname-local"}
:local red do={/terminal style varname}
:local plain do={/terminal style "syntax-val" }
:local yellow do={/terminal style "syntax-meta"}
:local strong do={/terminal style "syntax-noterm"}
:local nostyle do={/terminal style "none"}
:local rndhex do={ :return [:rndstr length=6 from=abcdef0123456789] }
{ :put {" Press "};
$nostyle; /terminal/cuu; :put "\t key to exit (or use Ctrl-C)";
$RED; /terminal/cuu; :put "\tany";
}
:local keypress 65535;
while (keypress=65535) do={
:local Nrows (9);
for i from=1 to=$Nrows do={:put ""}
for i from=1 to=$Nrows do={/terminal cuu}
for i from=1 to=$Nrows do={$RED; :put " A$i "}
for i from=1 to=$Nrows do={/terminal cuu}
for i from=1 to=$Nrows do={$cyan; :put "\t $([$rndhex])"}
for i from=1 to=$Nrows do={/terminal cuu}
for i from=1 to=$Nrows do={$blue; :put "\t\t $([$rndhex])"}
for i from=1 to=$Nrows do={/terminal cuu}
for i from=1 to=$Nrows do={$yellow; :put "\t\t\t $([$rndhex])"}
for i from=1 to=$Nrows do={/terminal cuu}
for i from=1 to=$Nrows do={$WHITE; :put "\t\t\t\t E$i "}
for i from=1 to=$Nrows do={/terminal cuu}
:set keypress [/terminal inkey timeout=1s]
}
}
Don't know if this helps anyone, but just learned a new trick to mimic the UNIX "clear" command.But you can use escape sequences as well.Code: Select all:put ("\1B[91mhello \1B[93mworld \1B[96m!!!")
:put "\1Bc"
Uuuuuuuuuuu..... nice catch!But there is an ANSI escape code for that, e.g. ANSI escape ("\1B") and letter "c", as a routeros "byte string":Prompt stay at bottom, and winbox/etc clears the terminal.Code: Select all:put "\1Bc"
Nice catch.Ah, did not know this exists...
But you can use escape sequences as well.
Code: Select all:put ("\1B[91mhello \1B[93mworld \1B[96m!!!")
This only works in telnet/ssh. Not in Winbox termial.
/terminal style does work in all terminal.
:put ("\1B[41mhello \1B[43mworld \1B[46m!!!\1B[0m")
:put ("\1B[1;37m\1B[41mhello \1B[1;33m\1B[40mworld \1B[0;30m\1B[42m!!!\1B[0m")
A more reasonable start be adding ANSI colors to https://en.wikipedia.org/wiki/Colossal_Cave_Adventure ... see viewtopic.php?t=199250Excelent. Now we got coloring in the terminal. How long until someone ports the DOOM into ROS CLI?