Terminal control/Coloured text: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) m syntax highlighting fixup automation |
|||
Line 1,008: | Line 1,008: | ||
smoutput(color BLACK),(clear 2),(move 8 22),J,(WHITE color BLACK),(downward 2) |
smoutput(color BLACK),(clear 2),(move 8 22),J,(WHITE color BLACK),(downward 2) |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
=={{header|jq}}== |
|||
''Adapted from [[#Wren|Wren]]'' |
|||
{{works with|jq}} |
|||
''Also works with gojq, the Go implmentation of jq'' |
|||
<syntaxhighlight lang="jq"> |
|||
# Pseudosleep for at least the given number of seconds, |
|||
# and emit the actual number of seconds that have elapsed. |
|||
def sleep($seconds): |
|||
now |
|||
| . as $now |
|||
| until( . - $now >= $seconds; now) |
|||
| . - $now ; |
|||
def esc: "\u001b"; |
|||
def colors: ["Black", "Red", "Green", "Yellow", "Blue", "Magenta", "Cyan", "White"]; |
|||
# display words using 'bright' colors |
|||
(range(1; 1 + (colors|length)) | "\(esc)[\(30+.);1m\(colors[.])"), # red to white |
|||
sleep(3), # wait for 3 seconds |
|||
"\(esc)[47m", # set background color to white |
|||
"\(esc)[2J", # clear screen to background color |
|||
"\(esc)[H", # home the cursor |
|||
# display words again using 'blinking' colors |
|||
"\(esc)[5m", # blink on |
|||
(range(0;6) | "\(esc)[\(30+.);1m\(colors[.])"), # black to cyan |
|||
sleep(3), # wait for 3 more seconds |
|||
"\(esc)[0m", # reset all attributes |
|||
"\(esc)[2J", # clear screen to background color |
|||
"\(esc)[H" # home the cursor |
|||
</syntaxhighlight> |
|||
''Invocation'' |
|||
Using jq: jq -nrf coloured_text.jq |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |