diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2006-11-26 11:11:55 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2006-11-26 11:11:55 +0000 |
commit | 145a665014b2aa230b81b582689c8ec17ef9968e (patch) | |
tree | 5ea1019527fe16cc21b9702371c72cc7f8c8090c /app/xterm/vttests | |
parent | 95c2d1cbda23a41cdf6e63520c7f0b825e63dd5b (diff) |
Importing xterm 216
Diffstat (limited to 'app/xterm/vttests')
-rw-r--r-- | app/xterm/vttests/16colors.sh | 90 | ||||
-rw-r--r-- | app/xterm/vttests/256colors.pl | 12 | ||||
-rw-r--r-- | app/xterm/vttests/256colors2.pl | 63 | ||||
-rw-r--r-- | app/xterm/vttests/88colors.pl | 13 | ||||
-rw-r--r-- | app/xterm/vttests/88colors2.pl | 66 | ||||
-rw-r--r-- | app/xterm/vttests/8colors.sh | 78 | ||||
-rw-r--r-- | app/xterm/vttests/acolors.sh | 64 | ||||
-rw-r--r-- | app/xterm/vttests/doublechars.sh | 87 | ||||
-rw-r--r-- | app/xterm/vttests/dynamic.sh | 60 | ||||
-rw-r--r-- | app/xterm/vttests/fonts.sh | 59 | ||||
-rw-r--r-- | app/xterm/vttests/paste64.pl | 143 | ||||
-rw-r--r-- | app/xterm/vttests/resize.pl | 100 | ||||
-rw-r--r-- | app/xterm/vttests/resize.sh | 82 | ||||
-rw-r--r-- | app/xterm/vttests/tcapquery.pl | 185 | ||||
-rw-r--r-- | app/xterm/vttests/title.sh | 55 |
15 files changed, 1157 insertions, 0 deletions
diff --git a/app/xterm/vttests/16colors.sh b/app/xterm/vttests/16colors.sh new file mode 100644 index 000000000..f47337577 --- /dev/null +++ b/app/xterm/vttests/16colors.sh @@ -0,0 +1,90 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/16colors.sh,v 1.5 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# Show a simple 16-color test pattern. It is a little more confusing than +# 8colors.sh, since everything is abbreviated to fit on an 80-column line. +# The high (8-15) combinations for foreground or background are marked with +# a '+' sign. + +ESC="" +CMD='echo' +OPT='-n' +SUF='' +TMP=/tmp/xterm$$ +eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null +( test ! -f $TMP || test -s $TMP ) && +for verb in printf print ; do + rm -f $TMP + eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null + if test -f $TMP ; then + if test ! -s $TMP ; then + CMD="$verb" + OPT= + SUF='\c' + break + fi + fi +done +rm -f $TMP + +if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null +then + trap '$CMD "[0m"; exit' EXIT HUP INT TRAP TERM +else + trap '$CMD "[0m"; exit' 0 1 2 5 15 +fi + +echo "[0m" +while true +do + for AT in 0 1 4 7 + do + case $AT in + 0) attr=" ";; + 1) attr="BO ";; + 4) attr="UN ";; + 7) attr="RV ";; + esac + for FG in 0 1 2 3 4 5 6 7 + do + case $FG in + 0) fcolor="BLK ";; + 1) fcolor="RED ";; + 2) fcolor="GRN ";; + 3) fcolor="YEL ";; + 4) fcolor="BLU ";; + 5) fcolor="MAG ";; + 6) fcolor="CYN ";; + 7) fcolor="WHT ";; + esac + for HI in 3 9 + do + if test $HI = 3 ; then + color=" $fcolor" + else + color="+$fcolor" + fi + $CMD $OPT "[0;${AT}m$attr$SUF" + $CMD $OPT "[${HI}${FG}m$color$SUF" + for BG in 1 2 3 4 5 6 7 + do + case $BG in + 0) bcolor="BLK ";; + 1) bcolor="RED ";; + 2) bcolor="GRN ";; + 3) bcolor="YEL ";; + 4) bcolor="BLU ";; + 5) bcolor="MAG ";; + 6) bcolor="CYN ";; + 7) bcolor="WHT ";; + esac + $CMD $OPT "[4${BG}m$bcolor$SUF" + $CMD $OPT "[10${BG}m+$bcolor$SUF" + done + echo "[0m" + done + done + sleep 1 + done +done diff --git a/app/xterm/vttests/256colors.pl b/app/xterm/vttests/256colors.pl new file mode 100644 index 000000000..b053b94fc --- /dev/null +++ b/app/xterm/vttests/256colors.pl @@ -0,0 +1,12 @@ +#!/usr/bin/perl +# $XFree86: xc/programs/xterm/vttests/256colors.pl,v 1.1 1999/07/11 08:49:54 dawes Exp $ + +for ($bg = 0; $bg < 256; $bg++) { + print "\x1b[9;1H\x1b[2J"; + for ($fg = 0; $fg < 256; $fg++) { + print "\x1b[48;5;${bg}m\x1b[38;5;${fg}m"; + printf "%03.3d/%03.3d ", $fg, $bg; + } + sleep 1; + print "\n"; +} diff --git a/app/xterm/vttests/256colors2.pl b/app/xterm/vttests/256colors2.pl new file mode 100644 index 000000000..c97c2be9d --- /dev/null +++ b/app/xterm/vttests/256colors2.pl @@ -0,0 +1,63 @@ +#!/usr/bin/perl +# Author: Todd Larason <jtl@molehill.org> +# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $ + +# use the resources for colors 0-15 - usually more-or-less a +# reproduction of the standard ANSI colors, but possibly more +# pleasing shades + +# colors 16-231 are a 6x6x6 color cube +for ($red = 0; $red < 6; $red++) { + for ($green = 0; $green < 6; $green++) { + for ($blue = 0; $blue < 6; $blue++) { + printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", + 16 + ($red * 36) + ($green * 6) + $blue, + ($red ? ($red * 40 + 55) : 0), + ($green ? ($green * 40 + 55) : 0), + ($blue ? ($blue * 40 + 55) : 0)); + } + } +} + +# colors 232-255 are a grayscale ramp, intentionally leaving out +# black and white +for ($gray = 0; $gray < 24; $gray++) { + $level = ($gray * 10) + 8; + printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", + 232 + $gray, $level, $level, $level); +} + + +# display the colors + +# first the system ones: +print "System colors:\n"; +for ($color = 0; $color < 8; $color++) { + print "\x1b[48;5;${color}m "; +} +print "\x1b[0m\n"; +for ($color = 8; $color < 16; $color++) { + print "\x1b[48;5;${color}m "; +} +print "\x1b[0m\n\n"; + +# now the color cube +print "Color cube, 6x6x6:\n"; +for ($green = 0; $green < 6; $green++) { + for ($red = 0; $red < 6; $red++) { + for ($blue = 0; $blue < 6; $blue++) { + $color = 16 + ($red * 36) + ($green * 6) + $blue; + print "\x1b[48;5;${color}m "; + } + print "\x1b[0m "; + } + print "\n"; +} + + +# now the grayscale ramp +print "Grayscale ramp:\n"; +for ($color = 232; $color < 256; $color++) { + print "\x1b[48;5;${color}m "; +} +print "\x1b[0m\n"; diff --git a/app/xterm/vttests/88colors.pl b/app/xterm/vttests/88colors.pl new file mode 100644 index 000000000..a645fc3d4 --- /dev/null +++ b/app/xterm/vttests/88colors.pl @@ -0,0 +1,13 @@ +#!/usr/bin/perl +# $XFree86: xc/programs/xterm/vttests/88colors.pl,v 1.1 1999/09/25 14:38:51 dawes Exp $ +# Made from 256colors.pl + +for ($bg = 0; $bg < 88; $bg++) { + print "\x1b[9;1H\x1b[48;5;${bg}m\x1b[2J"; + for ($fg = 0; $fg < 88; $fg++) { + print "\x1b[38;5;${fg}m"; + printf "%03.3d/%03.3d ", $fg, $bg; + } + sleep 1; + print "\n"; +} diff --git a/app/xterm/vttests/88colors2.pl b/app/xterm/vttests/88colors2.pl new file mode 100644 index 000000000..0e4c8f529 --- /dev/null +++ b/app/xterm/vttests/88colors2.pl @@ -0,0 +1,66 @@ +#!/usr/bin/perl +# Author: Steve Wall <swall@redcom.com> +# $XFree86: xc/programs/xterm/vttests/88colors2.pl,v 1.1 1999/09/25 14:38:51 dawes Exp $ +# Made from 256colors2.pl + +# use the resources for colors 0-15 - usually more-or-less a +# reproduction of the standard ANSI colors, but possibly more +# pleasing shades + +# colors 16-79 are a 4x4x4 color cube +@steps=(0,139,205,255); +for ($red = 0; $red < 4; $red++) { + for ($green = 0; $green < 4; $green++) { + for ($blue = 0; $blue < 4; $blue++) { + printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", + 16 + ($red * 16) + ($green * 4) + $blue, + int (@steps[$red]), + int (@steps[$green]), + int (@steps[$blue])); + } + } +} + +# colors 80-87 are a grayscale ramp, intentionally leaving out +# black and white +for ($gray = 0; $gray < 8; $gray++) { + $level = ($gray * 23.18181818) + 46.36363636; + if( $gray > 0 ) { $level += 23.18181818; } + printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", + 80 + $gray, int($level), int($level), int($level)); +} + + +# display the colors + +# first the system ones: +print "System colors:\n"; +for ($color = 0; $color < 8; $color++) { + print "\x1b[48;5;${color}m "; +} +print "\x1b[0m\n"; +for ($color = 8; $color < 16; $color++) { + print "\x1b[48;5;${color}m "; +} +print "\x1b[0m\n\n"; + +# now the color cube +print "Color cube, 4x4x4:\n"; +for ($green = 0; $green < 4; $green++) { + for ($red = 0; $red < 4; $red++) { + for ($blue = 0; $blue < 4; $blue++) { + $color = 16 + ($red * 16) + ($green * 4) + $blue; + print "\x1b[48;5;${color}m "; + } + print "\x1b[0m "; + } + print "\n"; +} + + +# now the grayscale ramp +print "Grayscale ramp:\n"; +for ($color = 80; $color < 88; $color++) { + print "\x1b[48;5;${color}m "; +} +print "\x1b[0m\n"; diff --git a/app/xterm/vttests/8colors.sh b/app/xterm/vttests/8colors.sh new file mode 100644 index 000000000..10865f730 --- /dev/null +++ b/app/xterm/vttests/8colors.sh @@ -0,0 +1,78 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/8colors.sh,v 1.5 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# Show a simple 8-color test pattern + +ESC="" +CMD='echo' +OPT='-n' +SUF='' +TMP=/tmp/xterm$$ +eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null +( test ! -f $TMP || test -s $TMP ) && +for verb in printf print ; do + rm -f $TMP + eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null + if test -f $TMP ; then + if test ! -s $TMP ; then + CMD="$verb" + OPT= + SUF='\c' + break + fi + fi +done +rm -f $TMP + +if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null +then + trap '$CMD $OPT "[0m"; exit' EXIT HUP INT TRAP TERM +else + trap '$CMD $OPT "[0m"; exit' 0 1 2 5 15 +fi + +echo "[0m" +while true +do + for AT in 0 1 4 7 + do + case $AT in + 0) attr="normal ";; + 1) attr="bold ";; + 4) attr="under ";; + 7) attr="reverse ";; + esac + for FG in 0 1 2 3 4 5 6 7 + do + case $FG in + 0) fcolor="black ";; + 1) fcolor="red ";; + 2) fcolor="green ";; + 3) fcolor="yellow ";; + 4) fcolor="blue ";; + 5) fcolor="magenta ";; + 6) fcolor="cyan ";; + 7) fcolor="white ";; + esac + $CMD $OPT "[0;${AT}m$attr" + $CMD $OPT "[3${FG}m$fcolor" + for BG in 1 2 3 4 5 6 7 + do + case $BG in + 0) bcolor="black ";; + 1) bcolor="red ";; + 2) bcolor="green ";; + 3) bcolor="yellow ";; + 4) bcolor="blue ";; + 5) bcolor="magenta ";; + 6) bcolor="cyan ";; + 7) bcolor="white ";; + esac + $CMD $OPT "[4${BG}m$bcolor" + done + echo "[0m" + done + sleep 1 + done +done diff --git a/app/xterm/vttests/acolors.sh b/app/xterm/vttests/acolors.sh new file mode 100644 index 000000000..ea19a38f4 --- /dev/null +++ b/app/xterm/vttests/acolors.sh @@ -0,0 +1,64 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/acolors.sh,v 1.2 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# Demonstrate the use of the control sequence for changing ANSI colors. + +ESC="" +CMD='echo' +OPT='-n' +SUF='' +TMP=/tmp/xterm$$ +eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null +( test ! -f $TMP || test -s $TMP ) && +for verb in printf print ; do + rm -f $TMP + eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null + if test -f $TMP ; then + if test ! -s $TMP ; then + CMD="$verb" + OPT= + SUF='\c' + break + fi + fi +done +rm -f $TMP + +LIST="00 30 80 d0 ff" + +exec </dev/tty +old=`stty -g` +stty raw -echo min 0 time 5 + +$CMD $OPT "${ESC}]4;4;?${SUF}" > /dev/tty +read original +stty $old +original=${original}${SUF} + +if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null +then + trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM +else + trap '$CMD $OPT "$original" >/dev/tty; exit' 0 1 2 5 15 +fi + +$CMD "${ESC}[0;1;34mThis message is BLUE" +$CMD "${ESC}[0;1;31mThis message is RED ${ESC}[0;31m(sometimes)" +$CMD "${ESC}[0;1;32mThis message is GREEN${ESC}[0m" +while true +do + for R in $LIST + do + for G in $LIST + do + for B in $LIST + do + # color "9" is bold-red + test $R != 00 && test $G = 00 && test $B = 00 && $CMD $OPT "" >/dev/tty + $CMD $OPT "${ESC}]4;9;rgb:$R/$G/$B${SUF}" >/dev/tty + sleep 1 + done + done + done +done diff --git a/app/xterm/vttests/doublechars.sh b/app/xterm/vttests/doublechars.sh new file mode 100644 index 000000000..dd032ae46 --- /dev/null +++ b/app/xterm/vttests/doublechars.sh @@ -0,0 +1,87 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/doublechars.sh,v 1.5 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/7/7) +# Illustrate the use of double-size characters by drawing successive lines in +# the commonly used video attributes. +# +# Use the -w option to force the output to wrap. It will look ugly, because +# the double-high lines will be split. + +ESC="" +CMD='echo' +OPT='-n' +SUF='' +TMP=/tmp/xterm$$ +eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null +( test ! -f $TMP || test -s $TMP ) && +for verb in printf print ; do + rm -f $TMP + eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null + if test -f $TMP ; then + if test ! -s $TMP ; then + CMD="$verb" + OPT= + SUF='\c' + break + fi + fi +done +rm -f $TMP + +SAVE=yes +WRAP=no +if test $# != 0 ; then + while test $# != 0 + do + case $1 in + -n) SAVE=no ;; + -w) WRAP=yes ;; + esac + shift + done +fi + +if test $SAVE = yes ; then + exec </dev/tty + old=`stty -g` + stty raw -echo min 0 time 5 + + $CMD $OPT "${ESC}[18t${SUF}" > /dev/tty + IFS=';' read junk high wide + + stty $old + + wide=`echo $wide|sed -e 's/t.*//'` + original=${ESC}[8\;${high}\;${wide}t${SUF} + + if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null + then + trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM + else + trap '$CMD $OPT "$original" >/dev/tty; exit' 0 1 2 5 15 + fi + +fi + +if test $WRAP = yes ; then + # turn on wrapping and force the screen to 80 columns + $CMD $OPT "${ESC}[?7h" >/dev/tty + $CMD $OPT "${ESC}[?40l" >/dev/tty +else + # force the screen to 132 columns + $CMD $OPT "${ESC}[?40h" >/dev/tty + $CMD $OPT "${ESC}[?3h" >/dev/tty +fi + +for SGR in 0 1 4 5 7 +do + $CMD $OPT "${ESC}[0;${SGR}m" >/dev/tty + for DBL in 5 3 4 6 5 + do + $CMD $OPT "${ESC}#${DBL}" >/dev/tty + echo "The quick brown fox jumps over the lazy dog" >/dev/tty + done + echo +done +$CMD $OPT "${ESC}[0m" >/dev/tty diff --git a/app/xterm/vttests/dynamic.sh b/app/xterm/vttests/dynamic.sh new file mode 100644 index 000000000..e68ebbc6c --- /dev/null +++ b/app/xterm/vttests/dynamic.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/dynamic.sh,v 1.5 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# Demonstrate the use of dynamic colors by setting the background successively +# to different values. + +ESC="" +CMD='echo' +OPT='-n' +SUF='' +TMP=/tmp/xterm$$ +eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null +( test ! -f $TMP || test -s $TMP ) && +for verb in printf print ; do + rm -f $TMP + eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null + if test -f $TMP ; then + if test ! -s $TMP ; then + CMD="$verb" + OPT= + SUF='\c' + break + fi + fi +done +rm -f $TMP + +LIST="00 30 80 d0 ff" + +exec </dev/tty +old=`stty -g` +stty raw -echo min 0 time 5 + +$CMD $OPT "${ESC}]11;?${SUF}" > /dev/tty +read original +stty $old +original=${original}${SUF} + +if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null +then + trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM +else + trap '$CMD $OPT "$original" >/dev/tty; exit' 0 1 2 5 15 +fi + +while true +do + for R in $LIST + do + for G in $LIST + do + for B in $LIST + do + $CMD $OPT "${ESC}]11;rgb:$R/$G/$B${SUF}" >/dev/tty + sleep 1 + done + done + done +done diff --git a/app/xterm/vttests/fonts.sh b/app/xterm/vttests/fonts.sh new file mode 100644 index 000000000..5dd9e29f0 --- /dev/null +++ b/app/xterm/vttests/fonts.sh @@ -0,0 +1,59 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/fonts.sh,v 1.4 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# Demonstrate the use of dynamic colors by setting the background successively +# to different values. + +ESC="" +CMD='echo' +OPT='-n' +SUF='' +TMP=/tmp/xterm$$ +eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null +( test ! -f $TMP || test -s $TMP ) && +for verb in printf print ; do + rm -f $TMP + eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null + if test -f $TMP ; then + if test ! -s $TMP ; then + CMD="$verb" + OPT= + SUF='\c' + break + fi + fi +done +rm -f $TMP + +exec </dev/tty +old=`stty -g` +stty raw -echo min 0 time 5 + +$CMD $OPT "${ESC}]50;?${SUF}" > /dev/tty +read original + +stty $old +original="${original}${SUF}" + +if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null +then + trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM +else + trap '$CMD $OPT "$original" >/dev/tty; exit' 0 1 2 5 15 +fi + +F=1 +D=1 +T=6 +while true +do + $CMD $OPT "${ESC}]50;#$F${SUF}" >/dev/tty + #sleep 1 + if test .$D = .1 ; then + test $F = $T && D=-1 + else + test $F = 1 && D=1 + fi + F=`expr $F + $D` +done diff --git a/app/xterm/vttests/paste64.pl b/app/xterm/vttests/paste64.pl new file mode 100644 index 000000000..301c31b17 --- /dev/null +++ b/app/xterm/vttests/paste64.pl @@ -0,0 +1,143 @@ +#!/usr/bin/perl -w +# $XTermId: paste64.pl,v 1.9 2006/03/13 01:28:02 tom Exp $ +# $XFree86: xc/programs/xterm/vttests/paste64.pl,v 1.1 2006/03/13 01:28:02 dickey Exp $ +# +# -- Thomas Dickey (2006/3/7) +# Test the paste64 option of xterm. + +use strict; + +use Term::ReadKey; +use IO::Handle; +use MIME::Base64; + +our $target = ""; + +sub to_hex($) { + my $value = $_[0]; + my $result = ""; + my $n; + + for ( $n = 0; $n < length($value); ++$n) { + $result .= sprintf("%02X", ord substr($value,$n,1)); + } + return $result; +} + +sub show_string($) { + my $value = $_[0]; + my $n; + + my $result = ""; + for ( $n = 0; $n < length($value); $n += 1) { + my $c = ord substr($value,$n,1); + if ( $c == ord '\\' ) { + $result .= "\\\\"; + } elsif ( $c == 0x1b ) { + $result .= "\\E"; + } elsif ( $c == 0x7f ) { + $result .= "^?"; + } elsif ( $c == 32 ) { + $result .= "\\s"; + } elsif ( $c < 32 ) { + $result .= sprintf("^%c", $c + 64); + } elsif ( $c > 128 ) { + $result .= sprintf("\\%03o", $c); + } else { + $result .= chr($c); + } + } + + printf "%s\r\n", $result; +} + +sub get_reply($) { + my $command = $_[0]; + my $reply = ""; + + printf "send: "; + show_string($command); + + print STDOUT $command; + autoflush STDOUT 1; + while (1) { + my $test=ReadKey 1; + last if not defined $test; + #printf "%d:%s\r\n", length($reply), to_hex($test); + $reply .= $test; + } + return $reply; +} + +sub get_paste() { + my $reply = get_reply("\x1b]52;" . $target . ";?\x1b\\"); + + printf "read: "; + show_string($reply); + + my $data = $reply; + $data =~ s/^\x1b]52;[[:alnum:]]*;//; + $data =~ s/\x1b\\$//; + printf "chop: "; + show_string($data); + + $data = decode_base64($data); + printf "data: "; + show_string($data); +} + +sub put_paste() { + ReadMode 1; + + printf "data: "; + my $data = ReadLine 0; + chomp $data; + ReadMode 5; + + $data = encode_base64($data); + chomp $data; + printf "data: "; + show_string($data); + + my $send = "\x1b]52;" . $target . ";" . $data . "\x1b\\"; + + printf "send: "; + show_string($send); +} + +sub set_target() { + ReadMode 1; + + printf "target: "; + $target = ReadLine 0; + $target =~ s/[^[:alnum:]]//g; + ReadMode 5; + printf "result: %s\r\n", $target; +} + +ReadMode 5, 'STDIN'; # allow single-character inputs +while (1) { + my $cmd; + + printf "\r\nCommand (? for help):"; + $cmd = ReadKey 0; + if ( $cmd eq "?" ) { + printf "\r\np=put selection, g=get selection, q=quit, r=reset target, s=set target\r\n"; + } elsif ($cmd eq "p") { + printf " ...put selection\r\n"; + put_paste(); + } elsif ($cmd eq "g") { + printf " ...get selection\r\n"; + get_paste(); + } elsif ($cmd eq "q") { + printf " ...quit\r\n"; + last; + } elsif ($cmd eq "r") { + printf " ...reset\r\n"; + $target = ""; + } elsif ($cmd eq "s") { + printf " ...set target\r\n"; + set_target(); + } +} +ReadMode 0, 'STDIN'; # Reset tty mode before exiting diff --git a/app/xterm/vttests/resize.pl b/app/xterm/vttests/resize.pl new file mode 100644 index 000000000..21a18beea --- /dev/null +++ b/app/xterm/vttests/resize.pl @@ -0,0 +1,100 @@ +#!/usr/bin/perl +# $XFree86: xc/programs/xterm/vttests/resize.pl,v 1.1 2004/03/04 02:21:58 dickey Exp $ +# +# -- Thomas Dickey (2004/3/3) +# resize.sh rewritten into Perl for comparison. +# See also Term::ReadKey. + +use IO::Handle; + +sub write_tty { + open TTY, "+</dev/tty" or die("Cannot open /dev/tty\n"); + autoflush TTY 1; + print TTY @_; + close TTY; +} + +sub get_reply { + open TTY, "+</dev/tty" or die("Cannot open /dev/tty\n"); + autoflush TTY 1; + $old=`stty -g`; + system "stty raw -echo min 0 time 5"; + + print TTY @_; + my $reply=<TTY>; + close TTY; + system "stty $old"; + return $reply; +} + +sub csi_field { + my $first = @_[0]; + my $second = @_[1]; + $first =~ s/^[^0-9]+//; + while ( --$second > 0 ) { + $first =~ s/^[\d]+//; + $first =~ s/^[^\d]+//; + } + $first =~ s/[^\d]+.*$//; + return $first; +} + +$original=get_reply("\x1b[18t"); +if ( $original =~ /\x1b\[8;\d+;\d+t/ ) { + $high=csi_field($original,2); + $wide=csi_field($original,3); + printf "parsed terminal size $high,$wide\n"; +} else { + die "Cannot get terminal size via escape sequence\n"; +} +# +$maximize=get_reply("\x1b[19t"); +if ( $maximize =~ /\x1b\[9;\d+;\d+t/ ) { + $maxhigh=csi_field($maximize,2); + $maxwide=csi_field($maximize,3); + $maxhigh != 0 or $maxhigh = $high * 2; + $maxwide != 0 or $maxwide = $wide * 2; + printf "parsed terminal maxsize $maxhigh,$maxwide\n"; +} else { + die "Cannot get terminal size via escape sequence\n"; +} + +sub catch_zap { + $zapped++; +} +$SIG{INT} = \&catch_zap; +$SIG{QUIT} = \&catch_zap; +$SIG{KILL} = \&catch_zap; +$SIG{HUP} = \&catch_zap; +$SIG{TERM} = \&catch_zap; + +$w=$wide; +$h=$high; +$a=1; +$zapped=0; +while ( $zapped == 0 ) +{ +# sleep 1 + printf "resizing to $h by $w\n"; + write_tty("\x1b[8;$h;$w" . "t"); + if ( $a == 1 ) { + if ( $w == $maxwide ) { + $h += $a; + if ( $h = $maxhigh ) { + $a = -1; + } + } else { + $w += $a; + } + } else { + if ( $w == $wide ) { + $h += $a; + if ( $h = $high ) { + $a=1; + } + } else { + $w += $a; + } + } +} +write_tty($original); diff --git a/app/xterm/vttests/resize.sh b/app/xterm/vttests/resize.sh new file mode 100644 index 000000000..004574949 --- /dev/null +++ b/app/xterm/vttests/resize.sh @@ -0,0 +1,82 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/resize.sh,v 1.5 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# Obtain the current screen size, then resize the terminal to the nominal +# screen width/height, and restore the size. + +ESC="" +CMD='echo' +OPT='-n' +SUF='' +TMP=/tmp/xterm$$ +eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null +( test ! -f $TMP || test -s $TMP ) && +for verb in printf print ; do + rm -f $TMP + eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null + if test -f $TMP ; then + if test ! -s $TMP ; then + CMD="$verb" + OPT= + SUF='\c' + break + fi + fi +done +rm -f $TMP + +exec </dev/tty +old=`stty -g` +stty raw -echo min 0 time 5 + +$CMD $OPT "${ESC}[18t${SUF}" > /dev/tty +IFS=';' read junk high wide + +$CMD $OPT "${ESC}[19t${SUF}" > /dev/tty +IFS=';' read junk maxhigh maxwide + +stty $old + +wide=`echo $wide|sed -e 's/t.*//'` +maxwide=`echo $maxwide|sed -e 's/t.*//'` +original=${ESC}[8\;${high}\;${wide}t${SUF} + +test $maxwide = 0 && maxwide=`expr $wide \* 2` +test $maxhigh = 0 && maxhigh=`expr $high \* 2` + +if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null +then + trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM +else + trap '$CMD $OPT "$original" >/dev/tty; exit' 0 1 2 5 15 +fi + +w=$wide +h=$high +a=1 +while true +do +# sleep 1 + echo resizing to $h by $w + $CMD $OPT "${ESC}[8;${h};${w}t" >/dev/tty + if test $a = 1 ; then + if test $w = $maxwide ; then + h=`expr $h + $a` + if test $h = $maxhigh ; then + a=-1 + fi + else + w=`expr $w + $a` + fi + else + if test $w = $wide ; then + h=`expr $h + $a` + if test $h = $high ; then + a=1 + fi + else + w=`expr $w + $a` + fi + fi +done diff --git a/app/xterm/vttests/tcapquery.pl b/app/xterm/vttests/tcapquery.pl new file mode 100644 index 000000000..a96a74ca1 --- /dev/null +++ b/app/xterm/vttests/tcapquery.pl @@ -0,0 +1,185 @@ +#!/usr/bin/perl -w +# $XTermId: tcapquery.pl,v 1.10 2006/07/20 00:37:00 tom Exp $ +# $XFree86: xc/programs/xterm/vttests/tcapquery.pl,v 1.3 2006/03/13 01:28:02 dickey Exp $ +# +# -- Thomas Dickey (2004/3/3) +# Test the tcap-query option of xterm. + +use strict; + +use IO::Handle; + +sub get_reply($) { + open TTY, "+</dev/tty" or die("Cannot open /dev/tty\n"); + autoflush TTY 1; + my $old=`stty -g`; + system "stty raw -echo min 0 time 5"; + + print TTY @_; + my $reply=<TTY>; + close TTY; + system "stty $old"; + return $reply; +} + +sub hexified($) { + my $value = $_[0]; + my $result = ""; + my $n; + + for ( $n = 0; $n < length($value); ++$n) { + $result .= sprintf("%02X", ord substr($value,$n,1)); + } + return $result; +} + +sub query_tcap($$) { + my $tcap = $_[0]; + my $tinfo = $_[1]; + my $param1 = hexified($tcap); + my $param2 = hexified($tinfo); + + # uncomment one of the following lines + my $reply=get_reply("\x1bP+q" . $param1 . ";" . $param2 . "\x1b\\"); + #my $reply=get_reply("\x1bP+q" . $param2 . "\x1b\\"); + + return unless defined $reply; + if ( $reply =~ /\x1bP1\+r[[:xdigit:]]+=[[:xdigit:]]*.*/ ) { + my $value = $reply; + my $n; + + $value =~ s/^\x1bP1\+r//; + $value =~ s/\x1b\\//; + + my $result = ""; + for ( $n = 0; $n < length($value); ) { + my $c = substr($value,$n,1); + # handle semicolon and equals + if ( $c =~ /[[:punct:]]/ ) { + $n += 1; + $result .= $c; + } else { + # handle hex-data + my $k = hex substr($value,$n,2); + if ( $k == 0x1b ) { + $result .= "\\E"; + } elsif ( $k == 0x7f ) { + $result .= "^?"; + } elsif ( $k == 32 ) { + $result .= "\\s"; + } elsif ( $k < 32 ) { + $result .= sprintf("^%c", $k + 64); + } elsif ( $k > 128 ) { + $result .= sprintf("\\%03o", $k); + } else { + $result .= chr($k); + } + $n += 2; + } + } + + printf "%s\n", $result; + } +} + +# See xtermcapKeycode() +query_tcap( "#2", "kHOM"); +query_tcap( "*7", "kEND"); +query_tcap( "#4", "kLFT"); +query_tcap( "%c", "kNXT"); +query_tcap( "%e", "kPRV"); +query_tcap( "%i", "kRIT"); + +query_tcap( "kh", "khome"); +query_tcap( "\@7", "kend"); +query_tcap( "kl", "kcub1"); +query_tcap( "kd", "kcud1"); +query_tcap( "ku", "kcuu1"); +query_tcap( "kr", "kcuf1"); + +query_tcap( "%1", "khlp"); +query_tcap( "#1", "kHLP"); +query_tcap( "*6", "kslt"); +query_tcap( "#6", "kSLT"); +query_tcap( "\@0", "kfnd"); +query_tcap( "*0", "kFND"); + +query_tcap( "k1", "kf1"); +query_tcap( "k2", "kf2"); +query_tcap( "k3", "kf3"); +query_tcap( "k4", "kf4"); +query_tcap( "k5", "kf5"); +query_tcap( "k6", "kf6"); +query_tcap( "k7", "kf7"); +query_tcap( "k8", "kf8"); +query_tcap( "k9", "kf9"); +query_tcap( "k;", "kf10"); +query_tcap( "F1", "kf11"); +query_tcap( "F2", "kf12"); +query_tcap( "F3", "kf13"); +query_tcap( "F4", "kf14"); +query_tcap( "F5", "kf15"); +query_tcap( "F6", "kf16"); +query_tcap( "F7", "kf17"); +query_tcap( "F8", "kf18"); +query_tcap( "F9", "kf19"); +query_tcap( "FA", "kf20"); +query_tcap( "FB", "kf21"); +query_tcap( "FC", "kf22"); +query_tcap( "FD", "kf23"); +query_tcap( "FE", "kf24"); +query_tcap( "FF", "kf25"); +query_tcap( "FG", "kf26"); +query_tcap( "FH", "kf27"); +query_tcap( "FI", "kf28"); +query_tcap( "FJ", "kf29"); +query_tcap( "FK", "kf30"); +query_tcap( "FL", "kf31"); +query_tcap( "FM", "kf32"); +query_tcap( "FN", "kf33"); +query_tcap( "FO", "kf34"); +query_tcap( "FP", "kf35"); +query_tcap( "FQ", "kf36"); +query_tcap( "FR", "kf37"); +query_tcap( "FS", "kf38"); +query_tcap( "FT", "kf39"); +query_tcap( "FU", "kf40"); +query_tcap( "FV", "kf41"); +query_tcap( "FW", "kf42"); +query_tcap( "FX", "kf43"); +query_tcap( "FY", "kf44"); +query_tcap( "FZ", "kf45"); +query_tcap( "Fa", "kf46"); +query_tcap( "Fb", "kf47"); +query_tcap( "Fc", "kf48"); +query_tcap( "Fd", "kf49"); +query_tcap( "Fe", "kf50"); +query_tcap( "Ff", "kf51"); +query_tcap( "Fg", "kf52"); +query_tcap( "Fh", "kf53"); +query_tcap( "Fi", "kf54"); +query_tcap( "Fj", "kf55"); +query_tcap( "Fk", "kf56"); +query_tcap( "Fl", "kf57"); +query_tcap( "Fm", "kf58"); +query_tcap( "Fn", "kf59"); +query_tcap( "Fo", "kf60"); +query_tcap( "Fp", "kf61"); +query_tcap( "Fq", "kf62"); +query_tcap( "Fr", "kf63"); + +query_tcap( "K1", "ka1"); +query_tcap( "K4", "kc1"); + +query_tcap( "kB", "kcbt"); +query_tcap( "kC", "kclr"); + +query_tcap( "kD", "kdch1"); +query_tcap( "kI", "kich1"); + +query_tcap( "kN", "knp"); +query_tcap( "kP", "kpp"); + +query_tcap( "kb", "kbs"); + +query_tcap( "Co", "colors"); diff --git a/app/xterm/vttests/title.sh b/app/xterm/vttests/title.sh new file mode 100644 index 000000000..af3807783 --- /dev/null +++ b/app/xterm/vttests/title.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# $XFree86: xc/programs/xterm/vttests/title.sh,v 1.6 2003/05/19 00:52:30 dickey Exp $ +# +# -- Thomas Dickey (1999/3/27) +# Obtain the current title of the window, set up a simple clock which runs +# until this script is interrupted, then restore the title. + +ESC="" +CMD='echo' +OPT='-n' +SUF='' +TMP=/tmp/xterm$$ +eval '$CMD $OPT >$TMP || echo fail >$TMP' 2>/dev/null +( test ! -f $TMP || test -s $TMP ) && +for verb in printf print ; do + rm -f $TMP + eval '$verb "\c" >$TMP || echo fail >$TMP' 2>/dev/null + if test -f $TMP ; then + if test ! -s $TMP ; then + CMD="$verb" + OPT= + SUF='\c' + break + fi + fi +done +rm -f $TMP + +exec </dev/tty +old=`stty -g` +stty raw -echo min 0 time 5 + +$CMD $OPT "${ESC}[21t${SUF}" > /dev/tty +read original + +stty $old + +# We actually get this terminated by an <esc>backslash, but the backslash +# is lost. We may lose doublequote characters when restoring the title, +# depending on the shell. +original=`echo "$original" |sed -e 's/^...//' -e 's/.$//'` +original=${ESC}]2\;"${original}"${SUF} + +if ( trap "echo exit" EXIT 2>/dev/null ) >/dev/null +then + trap '$CMD $OPT "$original" >/dev/tty; exit' EXIT HUP INT TRAP TERM +else + trap '$CMD $OPT "$original" >/dev/tty; exit' 0 1 2 5 15 +fi + +while true +do + sleep 1 + $CMD $OPT "${ESC}]2;`date`" >/dev/tty +done |