[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Odd character sequence for text based program.



Bill,

I'm not familiar with Attachmate so I can't comment about its particular
needs. However, the escape sequence style you describe is commonly used
in terminal programs to implement non-printing characters and to achieve
special effects. I hope the following example will be of some help.

The area I'm most familiar with is shell scripting. I modify
my /etc/bashrc file to customize the bash prompt PS1 used in Xterm and
the GNOME Terminal:

[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="\n\\033[1;31m`cat /etc/redhat-release`\n\\033[1;34m`date +%A` - `date +%B` `date +%d`, `date +%Y`  \\033[0;32m\t `date +%Z`\n\\033[0;36m[\u@\h] \\033[1;33m\w\\033[0;37m\n\\$ "

The ASCII escape character is represented by the string \\033 where the
'033' part is the octal (base-8) representation of the decimal number 27
or hexadecimal 0x1b. When followed by a left square bracket '[', a pair
of numbers separated by a semicolon ';', and a trailing lower-case 'm',
the color of the text that follows changes to the value specified by the
number pair. In my custom PS1 prompt the color changes six times.

So, to implement your ESC-[-8 three-character string in a bash shell
script you would use '\\033[8'.

BTW, to use my prompt just cut & paste the long line above and replace
the PS1 line in /etc/bashrc after these two lines:

    # Turn on checkwinsize
    shopt -s checkwinsize

This works for both Fedora XX and RHEL4/5.

Hope this helps.

--Doc

On Thu, 2010-03-04 at 18:30 -0600, Bill Purcell wrote:
> Ok, I guess I wasn't hitting ESC-[-8 fast enough.  I spent sometime
> today trying to figure out if this was some kind of escape sequence
> but I guess I was thinking too far into it.  When I hit this sequence
> as fast as I could at the prompt, I was able to do what I needed to
> do.  
> 
> How would I go about setting, say, F8 to send "<ESC>[8" to the terminal?
> 
> At Thu, 04 Mar 2010 18:01:44 -0600,
> Bill Purcell wrote:
> > 
> > All,
> > 
> > I am using a text based program through a ssh session that is
> > installed on a RHEL server.  The program instructions require that you
> > use Attachmate's Reflection terminal emulator
> > (http://www.attachmate.com/). The only reason I can think of for this
> > is because Reflection allows you to map key sequences to a function
> > key.  In the set up of the program there are instructions to map F8 to
> > a series of three characters ESC-[-8.  I'm not sure if this is
> > supposed to be an escape sequence or if it is actually literally those
> > three characters.  At any rate, how do I do something similar in gnome
> > terminal, xterm, or another terminal emulator that I can install on my
> > Ubuntu 9.04 desktop? xmodmap?
> > 
> > I'm sure there was some misuse of terminology here but I hope I got my
> > point across. 
> > 
> > Thanks in advance,
> > 
> > Bill
> 
> -
> To unsubscribe, send email to majordomo@silug.org with
> "unsubscribe silug-discuss" in the body.
> 


-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.