-
-
Save j4james/eca9bd29189f2abe851f206f1cbda0cd to your computer and use it in GitHub Desktop.
Script for testing DECAC reports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CSI=$'\e[' # Control Sequence Introducer | |
DCS=$'\eP' # Device Control String | |
ST=$'\e\\' # String Terminator | |
assign_colors() { | |
local parms=${1} | |
printf ${CSI}${parms}',|' | |
sleep 1 # pause for a second so we can see the color change | |
} | |
query_colors() { | |
local parms=${1} | |
local prefix=${2} | |
local eol=${3} | |
if read -t 2 -s -p ${DCS}${parms}'$q'${prefix}',|'${ST} -r -d '\' | |
then | |
printf '%q' ${REPLY} | |
printf '%q' ${REPLY} >> decac.log | |
else | |
printf '<no reply>' | |
printf '<no reply>' >> decac.log | |
fi | |
printf "${eol}" | |
printf "${eol}" >> decac.log | |
} | |
query_default_colors() { | |
printf 'Report default colors: ' | |
query_colors '' '' '\n' | |
} | |
query_text_colors() { | |
printf 'Report text colors: ' | |
query_colors '1' '' ' ' | |
query_colors '' '1' '\n' | |
} | |
query_frame_colors() { | |
printf 'Report frame colors: ' | |
query_colors '2' '' ' ' | |
query_colors '' '2' '\n' | |
} | |
query_unknown_colors() { | |
printf 'Report unknown colors: ' | |
query_colors '3' '' ' ' | |
query_colors '' '3' '\n' | |
} | |
# Make sure the terminal generates 7-bit reports | |
printf '\e F' | |
# Initial user-preference colors | |
printf 'Startup colors\n' | |
query_text_colors | |
query_frame_colors | |
# Basic text color test | |
printf 'Text yellow on blue\n' | |
assign_colors '1;3;4' | |
query_text_colors | |
# Basic frame color test | |
printf 'Frame red on green\n' | |
assign_colors '2;1;2' | |
query_frame_colors | |
# Omitted or invalid P1 prefix | |
printf 'Colors as above\n' | |
query_default_colors | |
query_unknown_colors | |
# Testing omitted color parameters | |
printf 'Text default on red\n' | |
assign_colors '1;;1' | |
query_text_colors | |
printf 'Text green on default\n' | |
assign_colors '1;2' | |
query_text_colors | |
# Testing omitted item parameter | |
printf 'Unknown blue on yellow\n' | |
assign_colors ';4;3' | |
query_text_colors | |
query_frame_colors | |
# Does DECSTR have any effect? | |
printf 'Soft reset\n' | |
printf ${CSI}'!p' | |
sleep 1 | |
query_text_colors | |
query_frame_colors | |
# Resetting the colors explicitly | |
printf 'Text white on black\n' | |
assign_colors '1;7;0' | |
printf 'Frame white on black\n' | |
assign_colors '2;7;0' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment