Terminal control/Inverse video: Difference between revisions
Line 11: | Line 11: | ||
=={{header|BASIC}}== |
=={{header|BASIC}}== |
||
==={{header|Locomotive Basic}}=== |
|||
The firmware routine at &bb9c (TXT INVERSE) swaps the current Locomotive BASIC PEN and PAPER colors: |
|||
<lang locobasic>10 CALL &bb9c:PRINT "inverse"; |
|||
20 CALL &bb9c:PRINT "normal"</lang> |
|||
=== {{header|ZX Spectrum Basic}} === |
=== {{header|ZX Spectrum Basic}} === |
||
Revision as of 21:37, 2 August 2011
You are encouraged to solve this task according to the task description, using any language you may know.
The task is to display a word in inverse video followed by a word in normal video.
AWK
<lang awk>BEGIN { system ("tput rev") print "foo" system ("tput sgr0") print "bar" }</lang>
BASIC
Locomotive Basic
The firmware routine at &bb9c (TXT INVERSE) swaps the current Locomotive BASIC PEN and PAPER colors:
<lang locobasic>10 CALL &bb9c:PRINT "inverse"; 20 CALL &bb9c:PRINT "normal"</lang>
ZX Spectrum Basic
<lang basic>10 INVERSE 1 20 PRINT "FOO"; 30 INVERSE 0 40 PRINT "BAR"</lang>
C
<lang C>#include <stdio.h>
int main() { printf("\033[7mReversed\033[m Normal\n");
return 0; }</lang>
PicoLisp
<lang PicoLisp>(prin "abc") (call "tput" "rev") (prin "def") # These three chars are displayed in reverse video (call "tput" "sgr0") (prinl "ghi")</lang>
PureBasic
<lang PureBasic>If OpenConsole()
ConsoleColor(0, 15) ;use the colors black (background) and white (forground) PrintN("Inverse Video") ConsoleColor(15, 0) ;use the colors white (background) and black (forground) PrintN("Normal Video") Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input() CloseConsole()
EndIf</lang>
Tcl
This only works on Unix terminals. <lang tcl># Get how the terminal wants to do things... set videoSeq(reverse) [exec tput rev] set videoSeq(normal) [exec tput rmso] proc reverseVideo str {
global videoSeq return "$videoSeq(reverse)${str}$videoSeq(normal)"
}
- The things to print
set inReverse "foo" set inNormal "bar"
- Print those words
puts "[reverseVideo $inReverse] $inNormal"</lang>
UNIX Shell
<lang sh>#!/bin/sh tput rev # foo is reversed echo 'foo' tput sgr0 # bar is normal video echo 'bar'</lang>