From ec0900e037212cd6d1fe359a925486dc0026b74f64c21a454b2b6857476d5a1d Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Tue, 23 Mar 2021 13:10:04 +0000 Subject: [PATCH] cursescheck enhenced OBS-URL: https://build.opensuse.org/package/show/Base:System/ncurses?expand=0&rev=539 --- cursescheck | 219 ++++++++++++++++++++++++++++++++++-------------- ncurses.changes | 5 ++ 2 files changed, 159 insertions(+), 65 deletions(-) diff --git a/cursescheck b/cursescheck index a2f7401..5d61267 100644 --- a/cursescheck +++ b/cursescheck @@ -1,6 +1,18 @@ #!/bin/bash -# Test ACS Line Graphics and REP capability of a terminal line +# +# cursescheck Test ACS/UTF-8 Line Graphics and REP capability +# of a terminal line described by variable TERM. +# +# Written in bash code to show and test capabilities of an terminal +# or terminal emulator without the `magic' of a binary program using +# libncurses(w) as many users do belive that ncurses defines the +# behaviour of a terminal. Here we show that the terminfo database +# given by the TERM variable simply describes the capabilities of +# a terminal. For this `infocmp(1)' and `tput(1)' is used as well +# the helpers `tty(1)', `grep(1), and `od(1)' are used herein. +# # Author: Werner Fink +# typeset -i rep=0 line=0 color=0 for s in 0 1 2 @@ -62,21 +74,23 @@ tput civis tput cup 0 0 if ((color > 0)) then - tput setab 4 - tput setaf 7 + tput -S <<-! + setab 4 + setaf 7 + ! fi tput ed echo Checking for Line Graphics on $tty with TERM=$TERM let line++ -smacs="$(tput enacs;tput smacs)" -rmacs="$(tput rmacs)" echo Found ${#acsc[@]} ACSC characters, check used Font and its Mapping let line++ tput cup $((line + 2)) 0 typeset -i row=$((line+2)) col=4 +typeset smacs=$(tput enacs; tput smacs) +typeset rmacs=$(tput rmacs) for sub in ${!acsc[@]} do tput cup $row $col @@ -107,8 +121,6 @@ let line=0 echo Checking for UTF-8 Line Graphics on $tty with TERM=$TERM let line++ -smacs="$(tput enacs;tput smacs)" -rmacs="$(tput rmacs)" echo Use U+2500 upto U+25FF glyps, check used Font and its Mapping let line++ @@ -148,6 +160,7 @@ let line=0 if ((${#acsc[@]} > 0)) then + typeset -i cx=20 echo Terminal TERM=$TERM has ASC Line Graphics let line++ echo Use them to draw a simple box @@ -159,28 +172,53 @@ then enacs smacs ! + if ((color > 0)) + then + tput -S <<-! + setab 7 + setaf 0 + ! + fi echo -ne ${acsn[0x6c]} - for ((c=0;c<20;c++)); do echo -ne ${acsn[0x71]}; done + for ((c=0;c 0)) && tput ech $cx + tput hpa $((col+cx+1)) + echo -ne ${acsn[0x78]} + done + tput cup $((row+c)) $col echo -ne ${acsn[0x6d]} - for ((c=0;c<20;c++)); do echo -ne ${acsn[0x71]}; done + for ((c=0;c 0)) + then + tput -S <<-! + setab 0 + setaf 0 + cup $((row+1)) $((col+cx+2)) + ech 2 + cup $((row+2)) $((col+cx+2)) + ech 2 + cup $((row+3)) $((col+cx+2)) + ech 2 + cup $((row+4)) $((col+cx+2)) + ech 2 + cup $((row+5)) $((col+2)) + ech $((cx+2)) + setab 4 + setaf 7 + ! + fi tput -S <<-! rmacs ! + tput cup $((row+2)) $((col+4)) + echo -n "" + tput cup $line 0 tput cvvis echo -n "OK> " @@ -193,7 +231,6 @@ else ed rmcup ! - exit 0 fi # @@ -209,6 +246,9 @@ let line=0 if ((1)) then + # + # UTF-8 wide character line glyphs + # ul=\\xe2\\x94\\x8c ur=\\xe2\\x94\\x90 hl=\\xe2\\x94\\x80 @@ -216,6 +256,7 @@ then dl=\\xe2\\x94\\x94 dr=\\xe2\\x94\\x98 + typeset -i cx=20 echo Terminal TERM=$TERM with UTF-8 Line Graphics let line++ echo Use them to draw a simple box @@ -223,27 +264,50 @@ then let row=height/2-4 let col=8 tput cup $row $col + if ((color > 0)) + then + tput -S <<-! + setab 7 + setaf 0 + ! + fi tput enacs - echo -ne ${ul} - for ((c=0;c<20;c++)); do echo -ne ${hl}; done + for ((c=0;c<$cx;c++)); do echo -ne ${hl}; done echo -ne ${ur} - tput cup $((row+1)) $col - echo -ne ${vl} - tput hpa $((col+21)) - echo -ne ${vl} - tput cup $((row+2)) $col - echo -ne ${vl} - tput hpa $((col+21)) - echo -ne ${vl} - tput cup $((row+3)) $col - echo -ne ${vl} - tput hpa $((col+21)) - echo -ne ${vl} - tput cup $((row+4)) $col + for ((c=1;c<4;c++)) + do + tput cup $((row+c)) $col + echo -ne ${vl} + ((color > 0)) && tput ech $cx + tput hpa $((col+cx+1)) + echo -ne ${vl} + done + tput cup $((row+c)) $col echo -ne ${dl} - for ((c=0;c<20;c++)); do echo -ne ${hl}; done + for ((c=0;c<$cx;c++)); do echo -ne ${hl}; done echo -ne ${dr} + if ((color > 0)) + then + tput -S <<-! + setab 0 + setaf 0 + cup $((row+1)) $((col+cx+2)) + ech 2 + cup $((row+2)) $((col+cx+2)) + ech 2 + cup $((row+3)) $((col+cx+2)) + ech 2 + cup $((row+4)) $((col+cx+2)) + ech 2 + cup $((row+5)) $((col+2)) + ech $((cx+2)) + setab 4 + setaf 7 + ! + fi + tput cup $((row+2)) $((col+4)) + echo -n "" tput cup $line 0 tput cvvis @@ -257,7 +321,6 @@ else ed rmcup ! - exit 0 fi # @@ -287,45 +350,71 @@ else ! exit 0 fi -if ((rep > 0)) + +if ((${#acsc[@]} > 0 && rep > 0)) then + typeset -i cx=20 echo Testing rep capability of TERM=$TERM let line++ let row=height/2-4 let col=8 + if ((color > 0)) + then + tput -S <<-! + setab 7 + setaf 0 + ! + fi tput -S <<-! - civis enacs smacs - bold cup $row $col - rep ${acsc[0x6c]} 0 - rep ${acsc[0x71]} 20 - rep ${acsc[0x6b]} 0 - cup $((row+1)) $col - rep ${acsc[0x78]} 0 - hpa $((col+21)) - rep ${acsc[0x78]} 0 - cup $((row+2)) $col - rep ${acsc[0x78]} 0 - hpa $((col+21)) - rep ${acsc[0x78]} 0 - cup $((row+3)) $col - rep ${acsc[0x78]} 0 - hpa $((col+21)) - rep ${acsc[0x78]} 0 - cup $((row+4)) $col - rep ${acsc[0x6d]} 0 - rep ${acsc[0x71]} 20 - rep ${acsc[0x6a]} 0 - sgr0 + ! + echo -ne ${acsn[0x6c]} + tput rep ${acsc[0x71]} $cx + echo -ne ${acsn[0x6b]} + for ((c=1;c<4;c++)) + do + tput cup $((row+c)) $col + echo -ne ${acsn[0x78]} + tput hpa $((col+cx+1)) + echo -ne ${acsn[0x78]} + done + tput cup $((row+c)) $col + echo -ne ${acsn[0x6d]} + tput rep ${acsc[0x71]} $cx + echo -ne ${acsn[0x6a]} + tput -S <<-! rmacs ! if ((color > 0)) then - tput setab 4 - tput setaf 7 + tput -S <<-! + cup $((row+1)) $((col+1)) + ech $cx + cup $((row+2)) $((col+1)) + ech $cx + cup $((row+3)) $((col+1)) + ech $cx + setab 0 + setaf 0 + cup $((row+1)) $((col+cx+2)) + ech 2 + cup $((row+2)) $((col+cx+2)) + ech 2 + cup $((row+3)) $((col+cx+2)) + ech 2 + cup $((row+4)) $((col+cx+2)) + ech 2 + cup $((row+5)) $((col+2)) + ech $((cx+2)) + setab 4 + setaf 7 + ! fi + tput cup $((row+2)) $((col+4)) + echo -n "" + tput cup $line 0 tput cvvis echo -n "OK> " diff --git a/ncurses.changes b/ncurses.changes index 0c710c7..957512e 100644 --- a/ncurses.changes +++ b/ncurses.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Mar 23 10:07:04 UTC 2021 - Dr. Werner Fink + +- Enhence cursescheck script + ------------------------------------------------------------------- Mon Mar 22 15:39:19 UTC 2021 - Dr. Werner Fink