X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/91264a4aa55481b7b3036b5367ed46e938b5fecf..95555145149ca1758e9b9e50d769685ece740134:/lib-src/emacstool.c diff --git a/lib-src/emacstool.c b/lib-src/emacstool.c index a25820750f..0843a3c508 100644 --- a/lib-src/emacstool.c +++ b/lib-src/emacstool.c @@ -1,22 +1,27 @@ /* - Copyright (C) 1986, 1988, 1990, 1991 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + Copyright (C) 1986, 1988, 1990, 1991, 2002, 2003, 2004, + 2005, 2006 Free Software Foundation, Inc. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +This file is part of GNU Emacs. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +GNU Emacs is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ /* * For Emacs in SunView/Sun-Windows: (supported by Sun Unix v3.2 or greater) - * Insert a notifier filter-function to convert all useful input + * Insert a notifier filter-function to convert all useful input * to "key" sequences that emacs can understand. See: Emacstool(1). * * Author: Jeff Peck, Sun Microsystems, Inc. @@ -107,7 +112,7 @@ FILE *console; /* for debugging: setenv DEBUGEMACSTOOL */ Icon frame_icon; /* make an icon_image for the default frame_icon */ -static short default_image[258] = +static short default_image[258] = { #include }; @@ -149,11 +154,11 @@ button_value (event) * Variables to store the time of the previous mouse event that was * sent to emacs. * - * The theory is that to time double clicks while ignoreing UP buttons, + * The theory is that to time double clicks while ignoring UP buttons, * we must keep track of the accumulated time. * * If someone writes a SUN-SET-INPUT-MASK for emacstool, - * That could be used to selectively disable UP events, + * That could be used to selectively disable UP events, * and then this cruft wouldn't be necessary. */ static long prev_event_sec = 0; @@ -169,13 +174,13 @@ time_delta (now_sec, now_usec, prev_sec, prev_usec) { long sec_delta = now_sec - prev_sec; long usec_delta = now_usec - prev_usec; - + if (usec_delta < 0) { /* "borrow" a second */ usec_delta += 1000000; --sec_delta; } - - if (sec_delta >= 10) + + if (sec_delta >= 10) return (9999); /* Infinity */ else return ((sec_delta * 1000) + (usec_delta / 1000)); @@ -185,7 +190,7 @@ time_delta (now_sec, now_usec, prev_sec, prev_usec) /* * Filter function to translate selected input events for emacs * Mouse button events become ^X^@(button x-col y-line time-delta) . - * Function keys: ESC-*{c}{lrt} l,r,t for Left, Right, Top; + * Function keys: ESC-*{c}{lrt} l,r,t for Left, Right, Top; * {c} encodes the keynumber as a character [a-o] */ static Notify_value @@ -211,18 +216,18 @@ input_event_filter_function (window, event, arg, type) /* UP L5 & L7 is Expose & Open, let them pass to sunview */ if (event_id(event) == KEY_LEFT(5) || event_id(event) == KEY_LEFT(7)) - if(event_is_up (event)) + if(event_is_up (event)) return notify_next_event_func (window, event, arg, type); else return NOTIFY_IGNORED; if (event_is_button (event)) { /* do Mouse Button events */ /* Commented out so that we send mouse up events too. - if (event_is_up (event)) + if (event_is_up (event)) return notify_next_event_func (window, event, arg, type); */ time_stamp = event_time (event); ttysw_input (tty_win, mouse_prefix, m_prefix_length); - sprintf (buffer, "(%d %d %d %d)\015", + sprintf (buffer, "(%d %d %d %d)\015", button_value (event), (event_x (event) - left_margin) / font_width, event_y (event) / font_height, @@ -234,14 +239,14 @@ input_event_filter_function (window, event, arg, type) prev_event_usec = time_stamp.tv_usec; return NOTIFY_IGNORED; } - + { /* Do the function key events */ int d; char c = (char) 0; if ((event_is_key_left (event)) ? - ((d = event_id(event) - KEY_LEFT(1) + 'a'), c='l') : + ((d = event_id(event) - KEY_LEFT(1) + 'a'), c='l') : ((event_is_key_right (event)) ? - ((d = event_id(event) - KEY_RIGHT(1) + 'a'), c='r') : + ((d = event_id(event) - KEY_RIGHT(1) + 'a'), c='r') : ((event_is_key_top (event)) ? ((d = event_id(event) - KEY_TOP(1) + 'a'), c='t') : 0))) { @@ -252,14 +257,14 @@ input_event_filter_function (window, event, arg, type) if (event_meta_is_down (event)) c = c + 128; #ifdef WANT_CAPS_LOCK /* set a toggle and relabel window so T1 can act like caps-lock */ - if (event_id(event) == KEY_TOP(1)) + if (event_id(event) == KEY_TOP(1)) { /* make a frame label with and without CAPS */ - strcpy (buffer, Caps); + strcpy (buffer, Caps); title = &buffer[CAPS_LEN]; strncpy (title, (char *)window_get (frame, FRAME_LABEL), BUFFER_SIZE - CAPS_LEN); - buffer[BUFFER_SIZE] = (char) 0; + buffer[BUFFER_SIZE] = (char) 0; if (strncmp (title, Caps, CAPS_LEN) == 0) title += CAPS_LEN; /* already Caps */ caps_lock = (caps_lock ? 0 : CAPS_LEN); @@ -274,7 +279,7 @@ input_event_filter_function (window, event, arg, type) return NOTIFY_IGNORED; } } - if ((event_is_ascii(event) || event_is_meta(event)) + if ((event_is_ascii(event) || event_is_meta(event)) && event_is_up(event)) return NOTIFY_IGNORED; #ifdef WANT_CAPS_LOCK /* shift alpha chars to upper case if toggle is set */ @@ -298,7 +303,7 @@ main (argc, argv) char **argv; { int error_code; /* Error codes */ - + #ifdef JLE setlocale(LC_ALL, ""); #endif JLE @@ -326,10 +331,10 @@ main (argc, argv) {fprintf (stderr, "%s: Could not clear TERMCAP\n", argv[0]) ;} ; } ; } ; - + /* find command to run as subprocess in window */ if (!(argv[0] = (char *)getenv("EMACSTOOL"))) /* Set emacs command name */ - argv[0] = emacs_name; + argv[0] = emacs_name; /* Emacstool recognizes two special args: -rc and -bold */ for (argc = 1; argv[argc]; argc++) /* Use last one on line */ { @@ -342,7 +347,7 @@ main (argc, argv) } } - if (!(strcmp ("-bold", argv[argc]))) + if (!(strcmp ("-bold", argv[argc]))) {int i = argc; argv[argc--]=0; /* kill the -bold argument */ if (argv[i+1]) { /* move to bold_name and squeeze the rest */ @@ -375,7 +380,7 @@ int interpose_on_window(argc,argv) char **argv; { #ifndef TTERM - int i, font_width_adjust = 1; /* hackery, and hueristics */ + int i, font_width_adjust = 1; /* hackery, and heuristics */ /* if -Wt is not supplied, then font comes out as lucida-14 (width=8) * rather than the screen.r.12 (width=7) typically used * this hack attempts to workaround it. @@ -403,9 +408,9 @@ int interpose_on_window(argc,argv) /* Create a tty with emacs in it */ tty_win = xv_create (frame, SWTYPE, WIN_IS_CLIENT_PANE, - TTY_QUIT_ON_CHILD_DEATH, TRUE, + TTY_QUIT_ON_CHILD_DEATH, TRUE, TTY_BOLDSTYLE, TTYSW_BOLD_INVERT, - TTY_ARGV, argv, + TTY_ARGV, argv, 0); if (bold_name) { @@ -431,15 +436,15 @@ int interpose_on_window(argc,argv) tty_view = (Xv_Window) xv_get (tty_win, OPENWIN_NTH_VIEW, 0); xv_set(tty_view, - WIN_CONSUME_EVENTS, + WIN_CONSUME_EVENTS, WIN_MOUSE_BUTTONS, WIN_UP_EVENTS, ACTION_ADJUST, ACTION_MENU, - WIN_ASCII_EVENTS, + WIN_ASCII_EVENTS, WIN_LEFT_KEYS, WIN_TOP_KEYS, WIN_RIGHT_KEYS, 0, 0); /* Interpose my event function */ - return (int) notify_interpose_event_func + return (int) notify_interpose_event_func (tty_view, input_event_filter_function, NOTIFY_SAFE); } #else @@ -460,10 +465,10 @@ int interpose_on_window (argc, argv) 0); /* Create a tty with emacs in it */ - tty_win = window_create (frame, TTY, - TTY_QUIT_ON_CHILD_DEATH, TRUE, + tty_win = window_create (frame, TTY, + TTY_QUIT_ON_CHILD_DEATH, TRUE, TTY_BOLDSTYLE, TTYSW_BOLD_INVERT, - TTY_ARGV, argv, + TTY_ARGV, argv, 0); if (bold_name) { @@ -477,20 +482,23 @@ int interpose_on_window (argc, argv) tty_view = tty_win; window_set(tty_view, - WIN_CONSUME_PICK_EVENTS, + WIN_CONSUME_PICK_EVENTS, WIN_STOP, WIN_MOUSE_BUTTONS, WIN_UP_EVENTS, /* LOC_WINENTER, LOC_WINEXIT, LOC_MOVE, */ 0, - WIN_CONSUME_KBD_EVENTS, + WIN_CONSUME_KBD_EVENTS, WIN_STOP, - WIN_ASCII_EVENTS, + WIN_ASCII_EVENTS, WIN_LEFT_KEYS, WIN_TOP_KEYS, WIN_RIGHT_KEYS, /* WIN_UP_ASCII_EVENTS, */ 0, 0); /* Interpose my event function */ - return (int) notify_interpose_event_func + return (int) notify_interpose_event_func (tty_view, input_event_filter_function, NOTIFY_SAFE); } #endif XVIEW + +/* arch-tag: 7a2e7105-c059-418a-b3d9-5b5de96abb4e + (do not change this comment) */