[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
HOWTO: Mouse editing with readline in xterm
From: |
Ilya Zakharevich |
Subject: |
HOWTO: Mouse editing with readline in xterm |
Date: |
Tue, 1 Oct 2002 22:43:49 +0000 (UTC) |
Here is how to enable mouse-edition of the command line in recent xterm's:
a) After running ./configure, add -DOPT_READLINE to the Makefile. [It
is a bug in configure that one cannot do this easier ;-]
b) This enables the following new [undocumented :-(] control codes for
DECSET etc:
#define SET_BUTTON1_MOVE_POINT 2001 /* click1 emit Esc seq to move point*/
#define SET_BUTTON2_MOVE_POINT 2002 /* press2 emit Esc seq to move point*/
#define SET_DBUTTON3_DELETE 2003 /* Double click-3 deletes */
#define SET_PASTE_IN_BRACKET 2004 /* Surround paste by escapes */
#define SET_PASTE_QUOTE 2005 /* Quote each char during paste */
#define SET_PASTE_LITERAL_NL 2006 /* Paste "\n" as C-j */
The reasonable sequence to enable this feature in ReadLine applications is:
0) Decide which features are good for a given ReadLine library;
E.g., for tcsh it is reasonable to use 2001;2002;2003.
For bare GNU readline it is reasonable to use 2001;2002;2003;2005;2006.
For applications which redefine many "usual keys" to do shortcuts
(e.g., redefine "(" to insert a matched pair of parens) one could
enable 2004, and bind F200 and F201 to switch off/on these
bindings. [2004 is an alternative to 2005.]
1) Before showing the prompt, emit CSI ? Pm s to save the settings,
then emit CSI ? Pm h to set new values. After the command line
editing is done, one should emit CSI ? Pm r to restore the old
values. Here Pm is the string discussed in (0), e.g.,
"2001;2002;2003" (without quotes).
2) If one has no such fine-grain control over the readline
application, the poor man solution is to emit these sequences
before and after running the application (instead of before and
after editing a line). However, in such cases xterm might
emulate presses of Left and Right in "wrong moments".
Here is the example for tcsh:
if ( $?SSH_CLIENT ) then
set user_in_prompt = '%n@'
else
set user_in_prompt = ''
endif
setenv MOUSE_READLINE_ON
'[?2001;2002;2003;2004;2005;2006s^[[?2001;2002;2003h'
setenv MOUSE_READLINE_OFF '[?2001;2002;2003;2004;2005;2006r'
set prompt = "%{^[]0;$user_in_prompt%m:
%~/^G%}%U%m%u%B:%b%U%~%u%B%{$MOUSE_READLINE_ON%}->%b"
alias post_cmd 'history -h 1 | perl -we '"'"'$_ = <STDIN>; chop;
s/[;\x07\n][^\n]*/.../; s~^~\e]0;$ARGV[1]:$ARGV[0]/> ~; s/$/\x07/;
s/\Q$ENV{HOME}/~/g; print $ENV{MOUSE_READLINE_OFF} if exists
$ENV{MOUSE_READLINE_OFF}; print'"'"' $cwd $LOGNAME$__hostname'
sched +0:00 alias postcmd post_cmd
set __hostname=`hostname`
Enjoy,
Ilya
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- HOWTO: Mouse editing with readline in xterm,
Ilya Zakharevich <=