* sending escape sequences to print in color
@ 2003-03-24 21:00 Eric Smith
2003-03-24 21:40 ` Dan Nelson
0 siblings, 1 reply; 9+ messages in thread
From: Eric Smith @ 2003-03-24 21:00 UTC (permalink / raw)
To: Zsh Users
How do I print (shell builtin) or scho or better still write (1)
to screen and produce color characters or inverse video.
Apologies if there is no zsh relevance to this question.
--
Eric Smith
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: sending escape sequences to print in color
2003-03-24 21:00 sending escape sequences to print in color Eric Smith
@ 2003-03-24 21:40 ` Dan Nelson
2003-03-24 21:52 ` Stephane CHAZELAS
2003-03-24 22:12 ` Phil Gregory
0 siblings, 2 replies; 9+ messages in thread
From: Dan Nelson @ 2003-03-24 21:40 UTC (permalink / raw)
To: Eric Smith; +Cc: Zsh Users
In the last episode (Mar 24), Eric Smith said:
> How do I print (shell builtin) or scho or better still write (1)
> to screen and produce color characters or inverse video.
echotc AF 6 ; echotc AB 4 ; echo "Cyan on Blue!"
--
Dan Nelson
dnelson@allantgroup.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: sending escape sequences to print in color
2003-03-24 21:40 ` Dan Nelson
@ 2003-03-24 21:52 ` Stephane CHAZELAS
2003-03-24 21:58 ` sending escape sequences to print in color - thanks Eric Smith
2003-03-25 0:03 ` sending escape sequences to print in color Thorsten Kampe
2003-03-24 22:12 ` Phil Gregory
1 sibling, 2 replies; 9+ messages in thread
From: Stephane CHAZELAS @ 2003-03-24 21:52 UTC (permalink / raw)
To: Dan Nelson; +Cc: Eric Smith, Zsh Users
On Mon, Mar 24, 2003 at 03:40:51PM -0600, Dan Nelson wrote:
> In the last episode (Mar 24), Eric Smith said:
> > How do I print (shell builtin) or scho or better still write (1)
> > to screen and produce color characters or inverse video.
>
> echotc AF 6 ; echotc AB 4 ; echo "Cyan on Blue!"
Or
autoload colors
colors
print "$bg[cyan]$fg[blue]Blue on Cyan!"
--
Stéphane
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: sending escape sequences to print in color - thanks
2003-03-24 21:52 ` Stephane CHAZELAS
@ 2003-03-24 21:58 ` Eric Smith
2003-03-24 22:32 ` Geoff Wing
2003-03-25 6:33 ` Stephane CHAZELAS
2003-03-25 0:03 ` sending escape sequences to print in color Thorsten Kampe
1 sibling, 2 replies; 9+ messages in thread
From: Eric Smith @ 2003-03-24 21:58 UTC (permalink / raw)
To: Zsh Users
Stephane CHAZELAS said:
> On Mon, Mar 24, 2003 at 03:40:51PM -0600, Dan Nelson wrote:
> > In the last episode (Mar 24), Eric Smith said:
> > > How do I print (shell builtin) or scho or better still write (1)
> > > to screen and produce color characters or inverse video.
> >
> > echotc AF 6 ; echotc AB 4 ; echo "Cyan on Blue!"
>
> Or
> autoload colors
> colors
>
> print "$bg[cyan]$fg[blue]Blue on Cyan!"
>
Thanks for both - nice to know and to use - great!
But one use I was looking for was to write(1) to another terminal viz.
echotc AF 6 ; echotc AB 4 ; echo "Cyan on Blue"|write eric /dev/pts/3
or
print "$bg[cyan]$fg[blue]Blue on Cyan"|write eric /dev/pts/3
but alas no colors on the destination terminal (of course this does not prove
it but trust me):
[eric@pear ~] 3 $
Message from eric@pear on pts/2 at 22:48 ...
Cyan on Blue
EOF
Message from eric@pear on pts/4 at 22:52 ...
^[[46m^[[34mBlue on Cyan
EOF
oops - this just came in (same issue):
print "\e[3${i}mFred $i here\e[0m"|write eric /dev/pts/3
Message from eric@pear on pts/4 at 22:56 ...
^[[3mFred here^[[0m
EOF
Perhaps I am being greedy - I learnt a great new trick today.
Thanks guys ...
--
Eric Smith
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: sending escape sequences to print in color
2003-03-24 21:40 ` Dan Nelson
2003-03-24 21:52 ` Stephane CHAZELAS
@ 2003-03-24 22:12 ` Phil Gregory
2003-03-25 5:24 ` Clint Adams
1 sibling, 1 reply; 9+ messages in thread
From: Phil Gregory @ 2003-03-24 22:12 UTC (permalink / raw)
To: Zsh Users
* Dan Nelson <dnelson@allantgroup.com> [2003-03-24 15:40 -0600]:
> echotc AF 6 ; echotc AB 4 ; echo "Cyan on Blue!"
I didn't know about the existence of echotc; cool. But I prefer
terminfo names (they're barely more mnemonic, at least). Why doesn't
echoti take arguments? (That's the only thing I'd use it for--simpler
to use the associative array for static strings.)
--
phil_g@pobox.com / phil! / DNRC / http://www.geeksimplex.org/phil/
PGP: ID: D8C75CF5 print: 0A7D B3AD 2D10 1099 7649 AB64 04C2 05A6
--- --
Statistics means never having to say you're certain.
---- --- --
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: sending escape sequences to print in color - thanks
2003-03-24 21:58 ` sending escape sequences to print in color - thanks Eric Smith
@ 2003-03-24 22:32 ` Geoff Wing
2003-03-25 6:33 ` Stephane CHAZELAS
1 sibling, 0 replies; 9+ messages in thread
From: Geoff Wing @ 2003-03-24 22:32 UTC (permalink / raw)
To: zsh-users
Eric Smith <es@fruitcom.com> typed:
: But one use I was looking for was to write(1) to another terminal viz.
: echotc AF 6 ; echotc AB 4 ; echo "Cyan on Blue"|write eric /dev/pts/3
: or
: print "$bg[cyan]$fg[blue]Blue on Cyan"|write eric /dev/pts/3
Generally you can't use write because most write programmes make control
characters visible, so escape will become the two characters ^ and [
However, on a local machine you may be able to do
% print "$bg[cyan]$fg[blue]Blue on Cyan" >> /dev/pts/3
Regards,
Geoff
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: sending escape sequences to print in color
2003-03-24 21:52 ` Stephane CHAZELAS
2003-03-24 21:58 ` sending escape sequences to print in color - thanks Eric Smith
@ 2003-03-25 0:03 ` Thorsten Kampe
1 sibling, 0 replies; 9+ messages in thread
From: Thorsten Kampe @ 2003-03-25 0:03 UTC (permalink / raw)
To: zsh-users
* Stephane CHAZELAS (03-03-24 22:52 +0100)
> On Mon, Mar 24, 2003 at 03:40:51PM -0600, Dan Nelson wrote:
>> In the last episode (Mar 24), Eric Smith said:
>>> How do I print (shell builtin) or scho or better still write (1)
>>> to screen and produce color characters or inverse video.
>>
>> echotc AF 6 ; echotc AB 4 ; echo "Cyan on Blue!"
I love the manual: "Output the termcap value corresponding to the
capability cap".
> Or
> autoload colors
> colors
I don't have to do this, perhaps because of "autoload -U promptinit ;
promptinit"? Any way to verify this?
> print "$bg[cyan]$fg[blue]Blue on Cyan!"
Time for me to unset the default "banghist" option.
Thorsten
--
Content-Type: text/explicit; charset=ISO-8859-666 (Parental Advisory)
Content-Transfer-Warning: message contains innuendos not suited for
children under the age of 18
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: sending escape sequences to print in color
2003-03-24 22:12 ` Phil Gregory
@ 2003-03-25 5:24 ` Clint Adams
0 siblings, 0 replies; 9+ messages in thread
From: Clint Adams @ 2003-03-25 5:24 UTC (permalink / raw)
To: Phil Gregory; +Cc: Zsh Users
> I didn't know about the existence of echotc; cool. But I prefer
> terminfo names (they're barely more mnemonic, at least). Why doesn't
> echoti take arguments? (That's the only thing I'd use it for--simpler
> to use the associative array for static strings.)
With the following patch, you'll be able to do
echoti setaf 4
or whatnot.
Index: Src/Modules/terminfo.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/terminfo.c,v
retrieving revision 1.19
diff -u -r1.19 terminfo.c
--- Src/Modules/terminfo.c 7 Oct 2002 11:48:08 -0000 1.19
+++ Src/Modules/terminfo.c 25 Mar 2003 05:21:51 -0000
@@ -59,8 +59,8 @@
static int
bin_echoti(char *name, char **argv, Options ops, int func)
{
- char *s, *t;
- int num;
+ char *s, *t, *u;
+ int num, argct;
s = *argv++;
/* This depends on the termcap stuff in init.c */
@@ -92,9 +92,28 @@
zwarnnam(name, "no such terminfo capability: %s", s, 0);
return 1;
}
-
- tputs(t, 1, putchar);
+ /* count the number of arguments required */
+ for (argct = 0, u = t; *u; u++)
+ if (*u == '%') {
+ if (u++, (*u == 'd' || *u == '2' || *u == '3' || *u == '.' ||
+ *u == '+'))
+ argct++;
+ }
+ /* check that the number of arguments provided is correct */
+ if (arrlen(argv) != argct) {
+ zwarnnam(name, (arrlen(argv) < argct) ? "not enough arguments" :
+ "too many arguments", NULL, 0);
+ return 1;
+ }
+ /* output string, through the proper termcap functions */
+ if (!argct)
+ tputs(t, 1, putraw);
+ else {
+ num = (argv[1]) ? atoi(argv[1]) : atoi(*argv);
+ tputs(tparm(t, atoi(*argv)), num, putraw);
+ }
return 0;
+
}
/**/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: sending escape sequences to print in color - thanks
2003-03-24 21:58 ` sending escape sequences to print in color - thanks Eric Smith
2003-03-24 22:32 ` Geoff Wing
@ 2003-03-25 6:33 ` Stephane CHAZELAS
1 sibling, 0 replies; 9+ messages in thread
From: Stephane CHAZELAS @ 2003-03-25 6:33 UTC (permalink / raw)
To: Zsh Users
On Mon, Mar 24, 2003 at 10:58:36PM +0100, Eric Smith wrote:
[...]
> But one use I was looking for was to write(1) to another terminal viz.
> echotc AF 6 ; echotc AB 4 ; echo "Cyan on Blue"|write eric /dev/pts/3
> or
> print "$bg[cyan]$fg[blue]Blue on Cyan"|write eric /dev/pts/3
>
> but alas no colors on the destination terminal (of course this does not prove
> it but trust me):
> [eric@pear ~] 3 $
> Message from eric@pear on pts/2 at 22:48 ...
> Cyan on Blue
> EOF
>
> Message from eric@pear on pts/4 at 22:52 ...
> ^[[46m^[[34mBlue on Cyan
> EOF
[...]
Be glad you can't. Some of such control sequences can serve to
put the remote terminal in an alternate charset or resize the
window to null, or iconify it or change the font to unreadable
or even in some versions of rxvt to run arbitrary commands!
--
Stéphane
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2003-03-25 7:10 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-24 21:00 sending escape sequences to print in color Eric Smith
2003-03-24 21:40 ` Dan Nelson
2003-03-24 21:52 ` Stephane CHAZELAS
2003-03-24 21:58 ` sending escape sequences to print in color - thanks Eric Smith
2003-03-24 22:32 ` Geoff Wing
2003-03-25 6:33 ` Stephane CHAZELAS
2003-03-25 0:03 ` sending escape sequences to print in color Thorsten Kampe
2003-03-24 22:12 ` Phil Gregory
2003-03-25 5:24 ` Clint Adams
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).