|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I think you all have heard about the game
named Rissian Diamonds. Yes, I want to implement this in bash. So, I need some commmands like curse library. Are there such commands? |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On 2006-12-10, Bo Yang wrote:
> I think you all have heard about the game > named Rissian Diamonds. I have never heard of it. What is it? > Yes, I want to implement this in bash. > So, I need some commmands like curse library. > Are there such commands? There is no shell interface to the curses library apart from the non-standardized tput. However, there is a standard for terminals which is close to universal. If you use ISO-6429, which is almost the same as the older ANSI x3.64, which is basically VT100. The number of terminals which do not support the standard is very small, and getting smaller. By encapsulating screen codes in functions, they can easily be replaced by those for a different terminal in the unlikely event that it should be necessary. These articles discuss using the mouse, cursor keys and function keys in shell scripts: <http://www.unixreview.com/documents/s=9920/ur0511a/ur0511a.html> <http://www.unixreview.com/documents/s=9525/ur0507a/ur0507a.html> -- Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Chris F.A. Johnson :
> On 2006-12-10, Bo Yang wrote: >> I think you all have heard about the game >> named Rissian Diamonds. > > I have never heard of it. What is it? Oh, I am sorry. I have taken it for granted that the game is very prevailing ! Sorry! > >> Yes, I want to implement this in bash. >> So, I need some commmands like curse library. >> Are there such commands? > > There is no shell interface to the curses library apart from the > non-standardized tput. However, there is a standard for terminals > which is close to universal. If you use ISO-6429, which is almost > the same as the older ANSI x3.64, which is basically VT100. The > number of terminals which do not support the standard is very > small, and getting smaller. Can you explain ISO-6429 and ANSI x3.64 for me? Are those standards for terminals? > > By encapsulating screen codes in functions, they can easily be > replaced by those for a different terminal in the unlikely event > that it should be necessary. > > These articles discuss using the mouse, cursor keys and function > keys in shell scripts: > <http://www.unixreview.com/documents/s=9920/ur0511a/ur0511a.html> > <http://www.unixreview.com/documents/s=9525/ur0507a/ur0507a.html> > I just want to draw some basic geometry graphics in the terminals, are there such commands? |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
2006-12-10, 18:10(-05), Chris F.A. Johnson:
> On 2006-12-10, Bo Yang wrote: >> I think you all have heard about the game >> named Rissian Diamonds. > > I have never heard of it. What is it? > >> Yes, I want to implement this in bash. >> So, I need some commmands like curse library. >> Are there such commands? > > There is no shell interface to the curses library apart from the > non-standardized tput. tcsh has a builtin interface to the termcap database (echotc) zsh has a builtin interface to both the termcap and terminfo databases (echoti, echotc, the $termcap and $terminfo associative arrays) in its zsh/term{cap,info} modules, and associative arrays for ANSI colors and attributes in the "colors" autoloadable function. -- Stéphane |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Stephane CHAZELAS :
> 2006-12-10, 18:10(-05), Chris F.A. Johnson: >> On 2006-12-10, Bo Yang wrote: >>> I think you all have heard about the game >>> named Rissian Diamonds. >> I have never heard of it. What is it? >> >>> Yes, I want to implement this in bash. >>> So, I need some commmands like curse library. >>> Are there such commands? >> There is no shell interface to the curses library apart from the >> non-standardized tput. > > tcsh has a builtin interface to the termcap database (echotc) > > zsh has a builtin interface to both the termcap and terminfo > databases (echoti, echotc, the $termcap and $terminfo > associative arrays) in its zsh/term{cap,info} modules, and > associative arrays for ANSI colors and attributes in the > "colors" autoloadable function. > I am sorry, I still didn't understand after look over your post. Can the echoti and echotc make a green rect in my terminal? Please give more and explaination, thank you! |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
2006-12-11, 21:19(+08), Bo Yang:
> Stephane CHAZELAS : >> 2006-12-10, 18:10(-05), Chris F.A. Johnson: >>> On 2006-12-10, Bo Yang wrote: >>>> I think you all have heard about the game >>>> named Rissian Diamonds. >>> I have never heard of it. What is it? >>> >>>> Yes, I want to implement this in bash. >>>> So, I need some commmands like curse library. >>>> Are there such commands? >>> There is no shell interface to the curses library apart from the >>> non-standardized tput. >> >> tcsh has a builtin interface to the termcap database (echotc) >> >> zsh has a builtin interface to both the termcap and terminfo >> databases (echoti, echotc, the $termcap and $terminfo >> associative arrays) in its zsh/term{cap,info} modules, and >> associative arrays for ANSI colors and attributes in the >> "colors" autoloadable function. >> > I am sorry, I still didn't understand after look over your post. > Can the echoti and echotc make a green rect in my terminal? [...] That's a low level interface. zmodload zsh/terminfo rectangle() { # x y w h color local i j local x=$1 y=$2 w=$3 h=$4 color=$5 echoti setab $color repeat $h { echoti cup $((y++)) $x repeat $w print -n ' ' } } -- Stéphane |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
Stephane CHAZELAS :
> 2006-12-11, 21:19(+08), Bo Yang: >> Stephane CHAZELAS : >>> 2006-12-10, 18:10(-05), Chris F.A. Johnson: >>>> On 2006-12-10, Bo Yang wrote: >>>>> I think you all have heard about the game >>>>> named Rissian Diamonds. >>>> I have never heard of it. What is it? >>>> >>>>> Yes, I want to implement this in bash. >>>>> So, I need some commmands like curse library. >>>>> Are there such commands? >>>> There is no shell interface to the curses library apart from the >>>> non-standardized tput. >>> tcsh has a builtin interface to the termcap database (echotc) >>> >>> zsh has a builtin interface to both the termcap and terminfo >>> databases (echoti, echotc, the $termcap and $terminfo >>> associative arrays) in its zsh/term{cap,info} modules, and >>> associative arrays for ANSI colors and attributes in the >>> "colors" autoloadable function. >>> >> I am sorry, I still didn't understand after look over your post. >> Can the echoti and echotc make a green rect in my terminal? > [...] > > That's a low level interface. > > zmodload zsh/terminfo > > rectangle() { # x y w h color > local i j > local x=$1 y=$2 w=$3 h=$4 color=$5 > echoti setab $color > repeat $h { > echoti cup $((y++)) $x > repeat $w print -n ' ' > } > } Understand! I think I can use tput to do this in the same way! Thank you Stephane! Thanks! |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
Stephane CHAZELAS :
> 2006-12-11, 21:19(+08), Bo Yang: >> Stephane CHAZELAS : >>> 2006-12-10, 18:10(-05), Chris F.A. Johnson: >>>> On 2006-12-10, Bo Yang wrote: >>>>> I think you all have heard about the game >>>>> named Rissian Diamonds. >>>> I have never heard of it. What is it? >>>> >>>>> Yes, I want to implement this in bash. >>>>> So, I need some commmands like curse library. >>>>> Are there such commands? >>>> There is no shell interface to the curses library apart from the >>>> non-standardized tput. >>> tcsh has a builtin interface to the termcap database (echotc) >>> >>> zsh has a builtin interface to both the termcap and terminfo >>> databases (echoti, echotc, the $termcap and $terminfo >>> associative arrays) in its zsh/term{cap,info} modules, and >>> associative arrays for ANSI colors and attributes in the >>> "colors" autoloadable function. >>> >> I am sorry, I still didn't understand after look over your post. >> Can the echoti and echotc make a green rect in my terminal? > [...] > > That's a low level interface. > > zmodload zsh/terminfo > > rectangle() { # x y w h color > local i j > local x=$1 y=$2 w=$3 h=$4 color=$5 > echoti setab $color > repeat $h { > echoti cup $((y++)) $x > repeat $w print -n ' ' > } > } > > Understand! I think I can draw a rectangle in bash with tput now! Thank you Stephane! Thanks! |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
Bo Yang wrote:
> > I think you all have heard about the game > named Rissian Diamonds. > > Yes, I want to implement this in bash. > So, I need some commmands like curse library. > Are there such commands? You can use "tput" or issue VT100 commands which are more or less understood by most terminals including "xterm", "dtterm", "kconsole" etc. ... however I am not sure how usefull bash is in this case since each rendering command will result in a |fork()| and that's very time-intensive and unpredictable from a timing point of view. BTW: http://svn.genunix.org/repos/on/bran...n/fun/gnaw.ksh is a PacMan-like game written in ksh93 which shows how to cache "tput" output for use in a game ("tput" and other time-intensive stuff is done before the game starts and during the game's main loop things like |fork()|'ed child processes are avoided and ksh93 builtin commands (which do not require a |fork()|) are used whereever possible). ---- Bye, Roland -- __ . . __ (o.\ \/ /.o) roland.mainz@nrubsig.org \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 7950090 (;O/ \/ \O ![]() |
|
|
|
#10 |
|
Messages: n/a
Hébergeur: |
On 2006-12-12, Roland Mainz wrote:
> Bo Yang wrote: >> >> I think you all have heard about the game >> named Rissian Diamonds. >> >> Yes, I want to implement this in bash. >> So, I need some commmands like curse library. >> Are there such commands? > > You can use "tput" or issue VT100 commands which are more or less > understood by most terminals including "xterm", "dtterm", "kconsole" > etc. ... however I am not sure how usefull bash is in this case since > each rendering command will result in a |fork()| and that's very > time-intensive and unpredictable from a timing point of view. Bash doesn't need to fork if you use the VT100/ISO-6429 codes with printf. > BTW: > http://svn.genunix.org/repos/on/bran...n/fun/gnaw.ksh > is a PacMan-like game written in ksh93 which shows how to cache "tput" > output for use in a game ("tput" and other time-intensive stuff is done > before the game starts and during the game's main loop things like >|fork()|'ed child processes are avoided and ksh93 builtin commands > (which do not require a |fork()|) are used whereever possible). Interesting, but it doesn't work in the version of ksh93 that I have (Version M 1993-12-28 n). The problem is 'read -t ....'. -- Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
|
|
#11 |
|
Messages: n/a
Hébergeur: |
"Chris F.A. Johnson" wrote:
> On 2006-12-12, Roland Mainz wrote: > > Bo Yang wrote: > >> > >> I think you all have heard about the game > >> named Rissian Diamonds. > >> > >> Yes, I want to implement this in bash. > >> So, I need some commmands like curse library. > >> Are there such commands? > > > > You can use "tput" or issue VT100 commands which are more or less > > understood by most terminals including "xterm", "dtterm", "kconsole" > > etc. ... however I am not sure how usefull bash is in this case since > > each rendering command will result in a |fork()| and that's very > > time-intensive and unpredictable from a timing point of view. > > Bash doesn't need to fork if you use the VT100/ISO-6429 codes with > printf. Uhm... is "printf" a bash builtin ? > > BTW: > > http://svn.genunix.org/repos/on/bran...n/fun/gnaw.ksh > > is a PacMan-like game written in ksh93 which shows how to cache "tput" > > output for use in a game ("tput" and other time-intensive stuff is done > > before the game starts and during the game's main loop things like > >|fork()|'ed child processes are avoided and ksh93 builtin commands > > (which do not require a |fork()|) are used whereever possible). > > Interesting, but it doesn't work in the version of ksh93 that I > have (Version M 1993-12-28 n). The problem is 'read -t ....'. Newer versions of "gnaw" need the following fix (more or less because "gnaw" was developed as some kind of technology demonstrator/demo for "ksh93 in Solaris" during ksh93s alpha): -- snip -- 06-11-16 The discipline functions have been modified to allow each subscript to act independently. Currently the discipline function will not be called when called from a discipline function of the same variable. -- snip -- This was fixed in ksh93s (=ksh93, vesion "s"; see https://mailman.research.att.com/pip...q4/001484.html for download urls for the current alpha version (which may disappear when the next alpha gets released)) ... ksh93n is very very old... ;-/ BTW: A screenshot of "gnaw" can be found at http://www.opensolaris.org/os/projec...n/screenshots/ (bottom of the page). ---- Bye, Roland -- __ . . __ (o.\ \/ /.o) roland.mainz@nrubsig.org \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 7950090 (;O/ \/ \O ![]() |
|
|
|
#12 |
|
Messages: n/a
Hébergeur: |
On 2006-12-12, Roland Mainz wrote:
>> >> Bash doesn't need to fork if you use the VT100/ISO-6429 codes with >> printf. > > Uhm... is "printf" a bash builtin ? Since bash-2.02-alpha1 which dates from 1997. -- Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
![]() |
| Outils de la discussion | |
|
|