/usr/share/jed/lib/mousex.sl is in jed-common 1:0.99.19-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | % mousex.sl -*- SLang -*-
%
% FIXME!!!
% This file does not work properly when the buffer contains folds.
%------------------------------------------------------------------
%
% Mouse routines for use inside an XTerm
% (and for Linux Console running selection/gpm?)
%
% Mouse actions:
% LEFT:
% If a region is marked, unmark it.
% Move the point to this new location.
%
% MIDDLE:
% If a region is marked, copy it to the pastebuffer.
% Otherwise, paste contents of the pastebuffer at the current point.
%
% RIGHT:
% Extend the region to this point.
%
% Ctrl-MIDDLE:
% If a region is marked, cut it to the pastebuffer.
%
% Status line actions:
% LEFT: switch window to a different buffer
% MIDDLE: split the window
% RIGHT: delete the window
%
% Cut/Paste Tips:
% 1. LEFT click at the beginning of the region, drag to the end of the
% region and release.
%
% 2. RIGHT click to extend the marked region.
%
% 3. MIDDLE click to COPY the marked region to the pastebuffer.
% or
% Ctrl-MIDDLE click to KILL the marked region to the pastebuffer.
%
% 4. MIDDLE click to paste the contents of the pastebuffer at the
% current point (use Step 1 to set the current point).
%
% Notes:
% Since XTerm normally uses Ctrl+MouseButton to activate popup menus,
% you can use ^C+MouseButton to simulate a Ctrl+MouseButton event
% -- i.e. press and release ^C before a mouse button event.
%
% To temporarily override XTerm mouse reporting -- and get the normal
% mouse selection behaviour -- hold down Shift or Mod1 (Meta, Alt) while
% performing the mouse action.
%
% Note that the mouse bindings use copy_region/kill_region/yank, while
% the key bindings typically use the yankpop equivalents so, in effect,
% the mouse gets its own kill buffer.
% mj olesen
% Someone tried to use this with Xjed. Stop that now.
if (is_defined ("X_LAST_KEYSYM"))
{
verror ("%s should not be loaded if using Xjed", "mousex.sl");
}
variable Mouse_Event_Type = 0, Mouse_X = 0, Mouse_Y = 0;
variable Mouse_Button = 3; % start with ButtonRelease event
setkey (".0 mouse_event", "\e[M"); % MouseButton
setkey_reserved (".'c'mouse_event", "\e[M");% simulate Ctrl+MouseButton
setkey (".'m'mouse_event", "\e\e[M"); % simulate Meta+MouseButton
setkey (".'s'mouse_event", "\e[\e[M"); % simulate Shift+MouseButton
% hooks to properly restore selection state (See $JED_ROOT/doc/mouse.txt)
% The XTerm mouse protocol sends a string encoded as:
% ESC [ M 'b' 'x' 'y'
% Here 'b' represents the key state and button information. It is a number
% equal to 32 + button-number + key-state. The left-button is button-number 0,
% the middle is 1, and the right is 2. A value of 3 appears to indicate
% a button release event. The key-state is:
% 4 = Shift
% 8 = Meta
% 16 = Ctrl
% 32 = double click (rxvt)
%
% x and y represent the 32 + column and 32 + row.
%
private define mousex_init_display_hook ()
{
variable esc_seq = "\e[?1000h";
if (strncmp (getenv ("TERM"), "xterm", 5))
esc_seq = "\e[?9h"; % (X10 compatibility) NOT xterm
tt_send (esc_seq);
}
private define mousex_reset_display_hook ()
{
variable esc_seq = "\e[?1000l";
if (strncmp (getenv ("TERM"), "xterm", 5))
esc_seq = "\e[?9l"; % NOT xterm
tt_send (esc_seq);
}
%hook_add_to_hook (&Reset_Display_Hook_List, &mousex_reset_display_hook);
%hook_add_to_hook (&Init_Display_Hook_List, &mousex_init_display_hook);
%hook_add_hook ("reset_display_hook", &mousex_reset_display_hook);
%hook_add_hook ("init_display_hook", &mousex_init_display_hook);
add_to_hook ("_jed_reset_display_hooks", &mousex_reset_display_hook);
add_to_hook ("_jed_init_display_hooks", &mousex_init_display_hook);
mousex_init_display_hook ();
% a hook into mouse-based menus (someday)
private define mousex_menu (x, y)
{
call ("select_menubar");
}
private define mousex_report (status)
{
sprintf ("Button <%d>: ", Mouse_Button);
if (status)
"Status line";
else
sprintf ("col,row = %d,%d Top,Rows = %d,%d",
Mouse_X, Mouse_Y, window_info('t'), window_info('r'));
flush (strcat ());
}
% missed release -- don't redefine
define mousex_3 (status) {}
% modifiers: 's' = Shift (4), 'm' = Meta (8), 'c' = Control (16)
define mouse_event (Mod)
{
variable n, status = 0;
variable meta = META_CHAR;
variable dec8 = DEC_8BIT_HACK;
META_CHAR = -1;
DEC_8BIT_HACK = 0;
n = _getkey () - 040; % button number + Modifiers
Mouse_X = _getkey () - 040; % Column
Mouse_Y = _getkey () - 040; % Row
META_CHAR = meta;
dec8 = DEC_8BIT_HACK;
% NB: xterm and rxvt use Shift and Meta to override mouse reporting
% and xterm use Ctrl for popup menus.
if ((n & 3) == 3) % release event
{
Mouse_Event_Type = 0; % use Mouse_Button from last ButtonPress
}
else
{
Mouse_Event_Type = 1;
Mouse_Button = (n & 3);
switch (Mod) % convert to logical masks
{ case 'c': 16;} % fake Ctrl+MouseButton
{ case 'm': 8;} % fake Meta+MouseButton
{ case 's': 4;} % fake Shift+MouseButton
{ 0;} % unadulterated
Mod = ();
Mouse_Button = Mouse_Button | Mod;
}
% error (sprintf ("Button <%d>: x,y: %d,%d", Mouse_Button, x, y));
n = nwindows ();
while (n)
{
variable top = window_info('t');
variable bot = window_info('r') + top;
if (Mouse_Y == bot)
{
status = 1;
break;
}
else if ((Mouse_Y >= top) and (Mouse_Y < bot))
{
Mouse_Y += 1 + what_line () - (top + window_line());
break;
}
otherwindow ();
n--;
}
!if (n)
{
if (Mouse_Y == 1) % Mouse on top status line
{
if (Mouse_Event_Type)
mousex_menu (Mouse_Event_Type, Mouse_X);
return;
}
Mouse_Button = 3;
!if (Mouse_Event_Type) error ("Mouse not in a window");
emacs_escape_x ();
return;
}
loop (n) otherwindow ();
Mouse_X += window_info('c') - 1;
n = nwindows () - n;
loop (n) otherwindow ();
if (not(Mouse_Event_Type) or status)
EXIT_BLOCK { Mouse_Button = 3; }
variable fn = sprintf ("mousex_%d", Mouse_Button);
!if (Mouse_Event_Type) {
if (n) return; % must be the same window
fn = strcat (fn, "U");
}
if (is_defined (fn) > 0)
{
status;
eval(strcat (".", fn)); % Use RPN--- no need to parse it
}
else
{
if (Mouse_Event_Type)
mousex_report (status); % Unbound ... just report
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% service functions
private define mouse_next_buffer ()
{
variable n, buf, cbuf = whatbuf ();
n = buffer_list (); % buffers on stack
loop (n)
{
buf = ();
n--;
if (buf[0] == ' ') continue;
if (buffer_visible (buf)) continue;
sw2buf (buf);
_pop_n (n);
return;
}
message ("All buffers are visible.");
}
% move to a new x, y location with/without extending the region
private define mouse_goto (moveto)
{
if (moveto)
pop_mark_0 ();
else !if (is_visible_mark ())
push_visible_mark ();
if (Mouse_Y == what_line ())
{
variable col = what_column (); % deal with going past end-of-line
if (col == goto_column_best_try (Mouse_X)) % didn't move
pop_mark (0);
}
else
{
goto_line (Mouse_Y);
() = goto_column_best_try (Mouse_X);
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% normal mouse event bindings, redefine as desired.
%
% mouse_?, mouse_?U (`U' means UP -- Button Release)
% `?' = 0-2 = None + l/m/r Button
% = 4-6 = Shift + l/m/r Button
% = 8-10 = Meta + l/m/r Button
% = 16-18 = Ctrl + l/m/r Button
% Left
define mousex_0 (status)
{
if (status)
mouse_next_buffer ();
else
mouse_goto (1);
}
% Left-Release
define mousex_0U (status)
{
!if (status) mouse_goto (0);
}
% Middle
define mousex_1 (status)
{
if (status)
splitwindow ();
else if (markp ())
{
call ("copy_region");
flush ("region copied");
}
else
call ("yank");
}
% Right
define mousex_2 (status)
{
if (status)
call ("delete_window");
else
mouse_goto (0);
}
% Ctrl-Middle
define mousex_17 (status)
{
if (status)
return;
else if (markp ())
{
call ("kill_region");
flush ("region killed");
}
}
% Other possible bindings
#iftrue
% Ctrl-Left
define mousex_16 (status)
{
if (status)
enable_top_status_line (1);
else
{
goto_line (Mouse_Y);
recenter (0);
}
}
% Ctrl-Right
define mousex_18 (status)
{
if (status)
enable_top_status_line (0);
else
mousex_report (status);
}
#endif
|