mapping escape sequences to control characters in KSH

mapping escape sequences to control characters in KSH

Post by Dean W. Annes » Sat, 11 Sep 1993 22:44:47



My customers run the Korn shell with emacs editing.  They have
asked me if there is any way to map (they love their arrow keys):

   up arrow    -- recall previous command (like C-p)
   down arrow  -- recall next command (like C-n)
   left arrow  -- move cursor left in command line (like C-b)
   right arrow -- move cursor right in command line (like C-f)

For xterm connections, I have been able to remap up/down/left/right
arrow keysyms to C-p/C-n/C-b/C-f via the following in their
.Xdefaults file:

! these keysym substututions generate the following strings
! for xterm sessions
!   Up       C-p
!   Down     C-n
!   Left     C-b
!   Right    C-f
xterm*vt100*Translations: #override\
  <Key>Up: string(0x10)\n\
  <Key>Down: string(0xe)\n\
  <Key>Left: string(0x2)\n\
  <Key>Right: string(0x6)

However, I would like to provide the same functionality for dumb terminal
connections.  What I'm looking for is somehow to be able to map the
escape sequences generated by the arrow keys to a control character from
within the Korn shell -- something like this:

  alias '\E[A'='\020'   # when you see this escape sequence for up
                        # arrow, return a C-p (control p) instead

Any suggestions would be very much appreciated.  Thank you.

Dean W. Anneser                  Pratt & Whitney Aircraft    
Computer System Specialist       m.s. 161-05                       \__ -\  
(203)565-9372 (desk) 5016 (fax)  400 Main St.               Ooo.. (_)-V/( )
Uucp:     uunet!pwa-b!anneser    East Hartford, CT  06108    Live to Ride

"One test result is worth one thousand expert opinions" -- Wernher Von Braun
--
Dean W. Anneser                  Pratt & Whitney Aircraft    
Computer System Specialist       m.s. 161-05                       \__ -\  
(203)565-9372 (desk) 5016 (fax)  400 Main St.               Ooo.. (_)-V/( )
Uucp:     uunet!pwa-b!anneser    East Hartford, CT  06108    Live to Ride

 
 
 

mapping escape sequences to control characters in KSH

Post by R. Stewart Ell » Sun, 12 Sep 1993 23:48:20



Quote:>My customers run the Korn shell with emacs editing.  They have
>asked me if there is any way to map (they love their arrow keys):

[delete]

Quote:>! these keysym substututions generate the following strings
>! for xterm sessions
>!   Up       C-p
>!   Down     C-n
>!   Left     C-b
>!   Right    C-f
>xterm*vt100*Translations: #override\
>  <Key>Up: string(0x10)\n\
>  <Key>Down: string(0xe)\n\
>  <Key>Left: string(0x2)\n\
>  <Key>Right: string(0x6)

What about when they run apps that look at the terminfo or termcap entry to
get the arrow key sequences and do not understand emacs?
If you would substitute bash, it looks for and uses the arrow key sequences
for whatever terminal it thinks the user is on.

Quote:>However, I would like to provide the same functionality for dumb terminal
>connections.  What I'm looking for is somehow to be able to map the
>escape sequences generated by the arrow keys to a control character from
>within the Korn shell -- something like this:
>  alias '\E[A'='\020'       # when you see this escape sequence for up
>                        # arrow, return a C-p (control p) instead
>Any suggestions would be very much appreciated.  Thank you.

IF the dumb terms are vt100-or-higher compatible, then you can give ksh
users on terms and xterms the following aliases:

alias __A=^P
alias __D=^B
alias __B=^N
alias __C=^F

You can also evidently bind other 'ESC[x' commands this way, but not the
longer ones.

--
  R.Stewart(Stew) Ellis, Assoc.Prof., (Off)313-762-9765   ___________________
  Humanities & Social Science,  GMI Eng.& Mgmt. Inst.    /   _____  ______

  Gopher,News and sendmail maintainer, all around hack /________/ /  /  / /

 
 
 

1. add control characters using sed with escape sequences?

Ok, I've managed to pull out most of the hair on my head over this
one...

I want to do the opposite to what most people seem to be asking.  I
have an ascii text file on my unix server and I wish to add Ctrl-M
(^M) characters to the end of each line in the file.  There are no ^M
characters in the file presently.

I can do this rather easily using the following sed command,

  sed -e 's/$/^M/' infile > outfile

where ^M is entered as a control character using Ctrl-V + Ctrl-M.

However, what I need to do is create a script that does not contain
the control character ^M in the sed command.  I would like to use an
escape sequence for the ^M character so that my script does not
contain any control characters.

Is that possible using sed?  I have seen many posts that mention it is
hard to use escape sequences in sed.

An option might be to use the translate command "tr" however I have
had no luck using this command.

Help!?

Regards
Paul

2. Strange Effect with Yamaha OPL3-SA3

3. Escape sequences for color selection in character mode.

4. CDE background texture

5. Escape sequence to flush characters

6. Linux Frequently Asked Questions with Answers (Part 5 of 6)

7. Can gnome terminal expand to 132 characters with xterm escape sequence ?

8. Creating text files in UNIX

9. escape sequence characters

10. How do I control a LG06 printer with escape sequences??

11. Escape sequences for display control??

12. escape characters in functions..in ksh

13. printing escape characters literally, ksh script