"Fossies" - the Fresh Open Source Software Archive

Member "xtermcontrol-3.8/tests/xtermcontrol.test" (2 May 2021, 7923 Bytes) of package /linux/privat/xtermcontrol-3.8.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "xtermcontrol.test": 3.7_vs_3.8.

    1 
    2 if test ! -x $XTC
    3 then
    4    echo "$XTC: no such file or directory"
    5    exit 1
    6 fi
    7 
    8 Main() {
    9    ForeAndBackgroundColorTest
   10    ForeAndBackgroundRgbColorTest
   11    CursorAndMouseColorTest
   12    CursorAndMouseRgbColorTest
   13    ColorTest
   14    FontTest
   15    TitleTest
   16    RawTest
   17    WindowTest
   18    GeometryTest
   19    HelpAndVersionTest
   20    ResetTest
   21    :
   22 }
   23 
   24 SettingsSave() {
   25    printf "\n%s\n" "Saving Current XTerm Settings:"
   26 
   27    FOREGROUND=`$XTC --get-fg`
   28    printf "%18s: %s\n" "FOREGROUND" "$FOREGROUND"
   29 
   30    BACKGROUND=`$XTC --get-bg`
   31    printf "%18s: %s\n" "BACKGROUND" "$BACKGROUND"
   32 
   33    CURSOR=`$XTC --get-cursor`
   34    printf "%18s: %s\n" "CURSOR" "$CURSOR"
   35 
   36    MOUSE_FOREGROUND=`$XTC --get-mouse-fg`
   37    printf "%18s: %s\n" "MOUSE_FOREGROUND" "$MOUSE_FOREGROUND"
   38 
   39    MOUSE_BACKGROUND=`$XTC --get-mouse-bg`
   40    printf "%18s: %s\n" "MOUSE_BACKGROUND" "$MOUSE_BACKGROUND"
   41 
   42    FONT=`$XTC --get-font`
   43    printf "%18s: %s\n" "FONT" "$FONT"
   44 
   45    TITLE=`$XTC --get-title`
   46    printf "%18s: %s\n" "TITLE" "$TITLE"
   47 
   48    GEOMETRY=`$XTC --get-geometry`
   49    printf "%18s: %s\n" "GEOMETRY" "$GEOMETRY"
   50 
   51    HIGHLIGHT=`$XTC --get-highlight`
   52    printf "%18s: %s\n" "HIGHLIGHT" "$HIGHLIGHT"
   53 
   54    for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
   55    do
   56       COLOR=`$XTC --get-color$i`
   57       COLORS=$COLORS\ $COLOR
   58       printf "%18s: %s\n" "COLOR$i" "$COLOR"
   59    done
   60 }
   61 
   62 SettingsRestore() {
   63 
   64    test -n "$FOREGROUND"       && OPT="$OPT --fg=\"$FOREGROUND\""
   65    test -n "$BACKGROUND"       && OPT="$OPT --bg=\"$BACKGROUND\""
   66    test -n "$CURSOR"           && OPT="$OPT --cursor=\"$CURSOR\""
   67    test -n "$MOUSE_FOREGROUND" && OPT="$OPT --mouse-fg=\"$MOUSE_FOREGROUND\""
   68    test -n "$MOUSE_BACKGROUND" && OPT="$OPT --mouse-bg=\"$MOUSE_BACKGROUND\""
   69    test -n "$FONT"             && OPT="$OPT --font=\"$FONT\""
   70    test -n "$TITLE"            && OPT="$OPT --title=\"$TITLE\""
   71    test -n "$GEOMETRY"         && OPT="$OPT --geometry=\"$GEOMETRY\""
   72 
   73    if test -n "$COLORS"
   74    then
   75       i=0
   76       for COLOR in $COLORS
   77       do
   78          OPT="$OPT --color$i=\"$COLOR\""
   79          i=`expr $i + 1`
   80       done
   81    fi
   82 
   83    eval $XTC $OPT
   84 }
   85 
   86 ForeAndBackgroundColorTest() {
   87    printf "\n%s\n" "Foreground and Background Color Test:"
   88 
   89    for i in 0 1 2 3 4 5 6 7
   90    do
   91       if expr 7 - $i > /dev/null
   92       then
   93          j=`expr 7 - $i`
   94       else
   95          j=0
   96       fi
   97       eval FG=\$COLOR_$j
   98       eval BG=\$COLOR_$i
   99 
  100       printf "  %s %-14s %s\n" `basename $XTC` "--fg=\"$FG\"" "--bg=\"$BG\""
  101       $XTC --fg="$FG" --bg="$BG"
  102       sleep 1
  103    done
  104 
  105    ## reset to user prefs.
  106    $XTC --fg=$FOREGROUND --bg=$BACKGROUND
  107 }
  108 
  109 ForeAndBackgroundRgbColorTest() {
  110    printf "\n%s\n" "Foreground and Background RGB Color Test:"
  111 
  112    for i in 0 1 2 3 4 5 6 7
  113    do
  114       if expr 7 - $i > /dev/null
  115       then
  116          j=`expr 7 - $i`
  117       else
  118          j=0
  119       fi
  120       eval FG=\$COLOR_RGB_$j
  121       eval BG=\$COLOR_RGB_$i
  122 
  123       printf "  %s %-14s %s\n" `basename $XTC` "--fg=\"$FG\"" "--bg=\"$BG\""
  124       $XTC --fg="$FG" --bg="$BG"
  125       sleep 1
  126    done
  127 
  128    ## reset to user prefs.
  129    $XTC --fg=$FOREGROUND --bg=$BACKGROUND
  130 }
  131 
  132 CursorAndMouseColorTest() {
  133    printf "\n%s\n" "Cursor and Mouse Pointer Color Test:"
  134 
  135    for i in 0 1 2 3 4 5 6 7
  136    do
  137       if expr 7 - $i > /dev/null
  138       then
  139          j=`expr 7 - $i`
  140       else
  141          j=0
  142       fi
  143       eval FG=\$COLOR_$j
  144       eval BG=\$COLOR_$i
  145 
  146       printf "  %s %-20s %-20s %s\n" `basename $XTC` \
  147              "--mouse-fg=\"$FG\"" "--mouse-bg=\"$BG\"" "--cursor=\"$FG\""
  148       $XTC --mouse-fg="$FG" --mouse-bg="$BG" --cursor="$FG" 
  149       sleep 1
  150    done
  151 
  152    ## reset to user prefs.
  153    $XTC --mouse-fg=$MOUSE_FOREGROUND\
  154         --mouse-bg=$MOUSE_BACKGROUND\
  155         --cursor=$CURSOR 
  156 }
  157 
  158 CursorAndMouseRgbColorTest() {
  159    printf "\n%s\n" "Cursor and Mouse Pointer RGB Color Test:"
  160 
  161    for i in 0 1 2 3 4 5 6 7
  162    do
  163       if expr 7 - $i > /dev/null
  164       then
  165          j=`expr 7 - $i`
  166       else
  167          j=0
  168       fi
  169       eval FG=\$COLOR_RGB_$j
  170       eval BG=\$COLOR_RGB_$i
  171 
  172       printf "  %s %-20s %-20s %s\n" `basename $XTC` \
  173              "--mouse-fg=\"$FG\"" "--mouse-bg=\"$BG\"" "--cursor=\"$FG\""
  174       $XTC --mouse-fg="$FG" --mouse-bg="$BG" --cursor="$FG" 
  175       sleep 1
  176    done
  177 
  178    ## reset to user prefs.
  179    $XTC --mouse-fg=$MOUSE_FOREGROUND\
  180         --mouse-bg=$MOUSE_BACKGROUND\
  181         --cursor=$CURSOR 
  182 }
  183 
  184 ColorTest() {
  185    printf "\n%s\n" "Color Test..."
  186 
  187    for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  188    do
  189       if expr $i / 8 > /dev/null
  190       then
  191          bold=`expr $i / 8`
  192       else 
  193          bold=0
  194       fi
  195 
  196       if expr $i % 8 > /dev/null
  197       then
  198          color=`expr $i % 8`
  199       else
  200          color=0
  201       fi
  202 
  203       j=$i
  204       if test $j -lt 10
  205       then
  206          j="$j "
  207       fi
  208       $XTC --raw "\e[20G\e[$bold;3${color}m\e[40m  color$j  \e[0m\n"
  209    done
  210 
  211    sleep 1
  212    for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  213    do
  214       j=$i
  215       for COLOR in $COLORS
  216       do
  217          if expr \( $j + 1 \) % 16 > /dev/null
  218          then
  219             j=`expr \( $j + 1 \) % 16`
  220          else
  221             j=0
  222          fi
  223          $XTC --color$j="$COLOR"
  224       done
  225       printf "\r"
  226       sleep 1
  227    done
  228 }
  229 
  230 
  231 FontTest() {
  232    printf "\n%s\n" "Font Test..."
  233 
  234    printf "  %s %s\n" `basename $XTC` "--font=\"8x13\""
  235    $XTC --font="8x13"
  236    sleep 2
  237 
  238    ## reset to user prefs.
  239    $XTC --font=$FONT
  240 }
  241 
  242 TitleTest() {
  243    printf "\n%s\n" "Xterm Window Title Test..."
  244 
  245    max=8; i=0
  246    while test $i -lt $max
  247    do
  248       printf "  %d\r" `expr $max - $i`
  249       $XTC --title="`date`"
  250       i=`expr $i + 1`
  251       sleep 1
  252    done
  253 
  254    ## reset to user prefs.
  255    $XTC --title=$TITLE
  256 }
  257 
  258 RawTest() {
  259    printf "\n%s\n" "Raw Test:"
  260 
  261 # To make up for the shortcomming of xtermcontrol not having an option for the
  262 # wierd control sequence your desprately need, the raw option lets you issue any
  263 # sequence from the ctlseq.ms
  264 
  265    PrintStatus() {
  266 
  267       STATUS="$1"
  268       xtc="$XTC --raw"
  269 
  270       COL=60
  271       GOTO_COL="\e[${COL}G"
  272       GREEN="\e[1;32m"
  273       RED="\e[1;31m"
  274       NORM="\e[0m"
  275 
  276       if test "$STATUS" = "OK"
  277       then
  278          $xtc "${GOTO_COL}[  ${GREEN}${STATUS}${NORM}  ]\n"
  279       elif test "$STATUS" = "FAILED"
  280       then
  281          $xtc "${GOTO_COL}[${RED}${STATUS}${NORM}]\n"
  282       else
  283          $xtc "\nUsage: $FUNCNAME 'OK'|'FAILED'\n"
  284       fi
  285    }
  286 
  287    $XTC --raw "  Starting Service mydaemond:"
  288    PrintStatus "OK"
  289 
  290    $XTC --raw "  Starting Service mydaemond:"
  291    PrintStatus "FAILED"
  292 
  293    sleep 1
  294 }
  295 
  296 WindowTest() {
  297    printf "\n%s\n" "Window Test:"
  298    
  299    for i in maximize restore iconify de-iconify lower raise
  300    do
  301       printf "  %s %s\n" `basename $XTC` "--$i"
  302       $XTC --$i
  303       sleep 1
  304    done
  305 }
  306 
  307 GeometryTest() {
  308    printf "\n%s\n" "Geometry Test:"
  309 
  310    $XTC --geometry="50x200+100+0"
  311    sleep 1
  312    $XTC --geometry="200x19+0+100"
  313    sleep 1
  314    $XTC --geometry="50x19+100+100"
  315    sleep 1
  316    $XTC --geometry="50x19+500+100"
  317    sleep 1
  318    $XTC --geometry="50x19+500+400"
  319    sleep 1
  320    $XTC --geometry="50x19+100+400"
  321    sleep 1
  322    $XTC --geometry="50x19+100+100"
  323    sleep 1
  324    $XTC --geometry="20x5+0+0"
  325    sleep 1
  326 
  327    ## reset to user prefs.
  328    $XTC --geometry=$GEOMETRY
  329    clear
  330 }
  331 
  332 HelpAndVersionTest() {
  333    printf "\n%s\n" "Help and Version Message Test:"
  334 
  335    sleep 1
  336    echo "--- Begin Version Message --------------------------------------------"
  337    $XTC --version
  338    sleep 1
  339    printf "\n"
  340    echo "--- Begin Help Message -----------------------------------------------"
  341    $XTC --help
  342 }
  343 
  344 ResetTest() {
  345    printf "\n%s\n" "Reset Test (in 3 seconds):"
  346    sleep 3
  347    $XTC --reset
  348 }
  349 
  350 COLOR_0="black"
  351 COLOR_1="red"
  352 COLOR_2="green"
  353 COLOR_3="yellow"
  354 COLOR_4="blue"
  355 COLOR_5="magenta"
  356 COLOR_6="cyan"
  357 COLOR_7="white"
  358 
  359 COLOR_RGB_0="rgb:0/0/0"
  360 COLOR_RGB_1="rgb:c2/36/21"
  361 COLOR_RGB_2="rgb:25/bc/24"
  362 COLOR_RGB_3="rgb:ad/ad/27"
  363 COLOR_RGB_4="rgb:49/2e/e1"
  364 COLOR_RGB_5="rgb:d3/38/d3"
  365 COLOR_RGB_6="rgb:33/bb/c8"
  366 COLOR_RGB_7="rgb:cb/cc/cd"
  367 
  368 trap 'SettingsRestore; exit' 0 1 2 5 15
  369 SettingsSave
  370 Main