Xterm Escape Sequences

SecureCRT


SecureCRT supports many standard escape sequences. The following is a list of the xterm sequences supported by SecureCRT.

Note: The mouse tracking information is provided for users developing applications for remote systems in order to support mouse tracking. Typically this implementation will be transparent to the user. SecureCRT supports X10 mouse tracking.

General Sequences

Action

ESC ] 2 ; title BEL

Set text parameters; change window title to title

 

 

Mouse Tracking Sequences

Action

ESC [ ? 9 h

Send mouse X and Y on button press

ESC [ ? 1000 h

Send mouse X and Y on button press and release

Example Script: Changing the Window Title

SecureCRT supports the xterm escape sequence for changing the session A session is a set of options that are assigned to a connection to a remote machine. These settings and options are saved under a session name and allow the user to have different preferences for different hosts. window title bar on the fly. The Perl script below shows how this can be done:

#! /usr/local/bin/perl

# title.pl - sends xterm escape sequence to

# change window title to @ARGV

 

$esc = "\x1b";

$bel = "\x7";

 

$txt = join(" ", @ARGV);

 

print $esc, "]2;", $txt, $bel;

This script can be placed in a shell alias to display the current working folder in the title bar of the session window:

alias cd 'cd \!\!* ; prompt ; ~/bin/title.pl $host\: `pwd` '

256-Color Extension Support

SecureCRT supports the 256-color extensions introduced for xterm versions that need to support more than 16 colors. For 256-color xterm escape sequences to work, you must have the ANSI Color option enabled in the Terminal/Emulation category of the Session Options dialog.

The general form of the 256-color escape sequences is as follows.

To set foreground color:

ESC [ 38 ; 5 ; <color> m

CSI 38 ; 5 ; <color> m

To set background color:

ESC [ 48 ; 5 ; <color> m

CSI 48 ; 5 ; <color> m

The following Perl script demonstrates using these sequences to lay out a "color cube" with a colored "X" in each color cell:

---

#!/usr/bin/perl

$ESC="\x1b";

$CSI="${ESC}\[";

for ($green=0;$green<6;$green++)

{

     for ($red=0;$red<6;$red++)

     {

         for ($blue=0;$blue<6;$blue++)

         {

             $bgcolor=16+($red*36)+($green*6)+$blue;

             $fgcolor=16-$red-$green-$blue;

             print "${CSI}48;5;${bgcolor}m";

             print "${CSI}38;5;${fgcolor}mX";

         }

         print "${CSI}0m";

         }

     print "\n";

}

---