annotate src/sunfns.c @ 1942:b403b27bc31c

* make-dist: Only copy gmalloc.c if we couldn't link it. Don't try to copy man/{README,Makefile} unless they actually exist.
author Jim Blandy <jimb@redhat.com>
date Tue, 23 Feb 1993 14:13:27 +0000
parents 36ef55ecb265
children 507f64624555
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
1 /* Functions for Sun Windows menus and selection buffer.
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
2 Copyright (C) 1987 Free Software Foundation, Inc.
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
3
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
4 This file is part of GNU Emacs.
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
5
38
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 19
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 19
diff changeset
7 it under the terms of the GNU General Public License as published by
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 19
diff changeset
8 the Free Software Foundation; either version 1, or (at your option)
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 19
diff changeset
9 any later version.
19
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
10
38
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 19
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 19
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 19
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 19
diff changeset
14 GNU General Public License for more details.
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 19
diff changeset
15
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 19
diff changeset
16 You should have received a copy of the GNU General Public License
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 19
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
056b931d312b *** empty log message ***
Joseph Arceneaux <jla@gnu.org>
parents: 19
diff changeset
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
19
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
20 Author: Jeff Peck, Sun Microsystems, Inc. <peck@sun.com>
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
21 Original ideas by David Kastan and Eric Negaard, SRI International
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
22 Major help from: Steve Greenbaum, Reasoning Systems, Inc.
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
23 <froud@kestrel.arpa>
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
24 who first discovered the Menu_Base_Kludge.
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
25 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
26
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
27 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
28 * Emacs Lisp-Callable functions for sunwindows
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
29 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
30 #include "config.h"
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
31
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
32 #include <stdio.h>
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
33 #include <errno.h>
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
34 #include <signal.h>
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
35 #include <sunwindow/window_hs.h>
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
36 #include <suntool/selection.h>
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
37 #include <suntool/menu.h>
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
38 #include <suntool/walkmenu.h>
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
39 #include <suntool/frame.h>
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
40 #include <suntool/window.h>
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
41
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
42 #include <fcntl.h>
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
43 #undef NULL /* We don't need sunview's idea of NULL */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
44 #include "lisp.h"
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
45 #include "window.h"
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
46 #include "buffer.h"
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
47 #include "termhooks.h"
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
48
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
49 /* conversion to/from character & frame coordinates */
19
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
50 /* From Gosling Emacs SunWindow driver by Chris Torek */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
51
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
52 /* Chars to frame coords. Note that we speak in zero origin. */
19
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
53 #define CtoSX(cx) ((cx) * Sun_Font_Xsize)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
54 #define CtoSY(cy) ((cy) * Sun_Font_Ysize)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
55
766
b9e81bfc7ad9 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 485
diff changeset
56 /* Frame coords to chars */
19
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
57 #define StoCX(sx) ((sx) / Sun_Font_Xsize)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
58 #define StoCY(sy) ((sy) / Sun_Font_Ysize)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
59
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
60 #define CHECK_GFX(x) if((win_fd<0)&&(Fsun_window_init(),(win_fd<0)))return(x)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
61 int win_fd = -1;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
62 struct pixfont *Sun_Font; /* The font */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
63 int Sun_Font_Xsize; /* Width of font */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
64 int Sun_Font_Ysize; /* Height of font */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
65
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
66 #define Menu_Base_Kludge /* until menu_show_using_fd gets fixed */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
67 #ifdef Menu_Base_Kludge
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
68 static Frame Menu_Base_Frame;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
69 static int Menu_Base_fd;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
70 static Lisp_Object sm_kludge_string;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
71 #endif
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
72 struct cursor CurrentCursor; /* The current cursor */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
73
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
74 static short CursorData[16]; /* Build cursor here */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
75 static mpr_static(CursorMpr, 16, 16, 1, CursorData);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
76 static struct cursor NewCursor = {0, 0, PIX_SRC ^ PIX_DST, &CursorMpr};
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
77
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
78 #define RIGHT_ARROW_CURSOR /* if you want the right arrow */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
79 #ifdef RIGHT_ARROW_CURSOR
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
80 /* The default right-arrow cursor, with XOR drawing. */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
81 static short ArrowCursorData[16] = {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
82 0x0001,0x0003,0x0007,0x000F,0x001F,0x003F,0x007F,0x000F,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
83 0x001B,0x0019,0x0030,0x0030,0x0060,0x0060,0x00C0,0x00C0};
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
84 static mpr_static(ArrowCursorMpr, 16, 16, 1, ArrowCursorData);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
85 struct cursor DefaultCursor = {15, 0, PIX_SRC ^ PIX_DST, &ArrowCursorMpr};
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
86
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
87 #else
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
88 /* The default left-arror cursor, with XOR drawing. */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
89 static short ArrowCursorData[16] = {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
90 0x8000,0xC000,0xE000,0xF000,0xF800,0xFC00,0xFE00,0xF000,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
91 0xD800,0x9800,0x0C00,0x0C00,0x0600,0x0600,0x0300,0x0300};
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
92 static mpr_static(ArrowCursorMpr, 16, 16, 1, ArrowCursorData);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
93 struct cursor DefaultCursor = {0, 0, PIX_SRC ^ PIX_DST, &ArrowCursorMpr};
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
94 #endif
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
95
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
96 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
97 * Initialize window
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
98 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
99 DEFUN ("sun-window-init", Fsun_window_init, Ssun_window_init, 0, 1, 0,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
100 "One time setup for using Sun Windows with mouse.\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
101 Unless optional argument FORCE is non-nil, is a noop after its first call.\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
102 Returns a number representing the file descriptor of the open Sun Window,\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
103 or -1 if can not open it.")
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
104 (force)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
105 Lisp_Object force;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
106 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
107 char *cp;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
108 static int already_initialized = 0;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
109
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 116
diff changeset
110 if ((! already_initialized) || (!NILP(force))) {
19
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
111 cp = getenv("WINDOW_GFX");
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
112 if (cp != 0) win_fd = open(cp, 2);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
113 if (win_fd > 0)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
114 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
115 Sun_Font = pf_default();
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
116 Sun_Font_Xsize = Sun_Font->pf_defaultsize.x;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
117 Sun_Font_Ysize = Sun_Font->pf_defaultsize.y;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
118 Fsun_change_cursor_icon (Qnil); /* set up the default cursor */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
119 already_initialized = 1;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
120 #ifdef Menu_Base_Kludge
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
121
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
122 /* Make a frame to use for putting the menu on, and get its fd. */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
123 Menu_Base_Frame = window_create(0, FRAME,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
124 WIN_X, 0, WIN_Y, 0,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
125 WIN_ROWS, 1, WIN_COLUMNS, 1,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
126 WIN_SHOW, FALSE,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
127 FRAME_NO_CONFIRM, 1,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
128 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
129 Menu_Base_fd = (int) window_get(Menu_Base_Frame, WIN_FD);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
130 #endif
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
131 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
132 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
133 return(make_number(win_fd));
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
134 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
135
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
136 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
137 * Mouse sit-for (allows a shorter interval than the regular sit-for
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
138 * and can be interrupted by the mouse)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
139 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
140 DEFUN ("sit-for-millisecs", Fsit_for_millisecs, Ssit_for_millisecs, 1, 1, 0,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
141 "Like sit-for, but ARG is milliseconds. \n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
142 Perform redisplay, then wait for ARG milliseconds or until\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
143 input is available. Returns t if wait completed with no input.\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
144 Redisplay does not happen if input is available before it starts.")
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
145 (n)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
146 Lisp_Object n;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
147 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
148 struct timeval Timeout;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
149 int waitmask = 1;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
150
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
151 CHECK_NUMBER (n, 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
152 Timeout.tv_sec = XINT(n) / 1000;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
153 Timeout.tv_usec = (XINT(n) - (Timeout.tv_sec * 1000)) * 1000;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
154
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
155 if (detect_input_pending()) return(Qnil);
116
6b517878550a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 60
diff changeset
156 redisplay_preserve_echo_area ();
19
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
157 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
158 * Check for queued keyboard input/mouse hits again
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
159 * (A bit screen update can take some time!)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
160 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
161 if (detect_input_pending()) return(Qnil);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
162 select(1,&waitmask,0,0,&Timeout);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
163 if (detect_input_pending()) return(Qnil);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
164 return(Qt);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
165 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
166
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
167 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
168 * Sun sleep-for (allows a shorter interval than the regular sleep-for)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
169 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
170 DEFUN ("sleep-for-millisecs",
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
171 Fsleep_for_millisecs,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
172 Ssleep_for_millisecs, 1, 1, 0,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
173 "Pause, without updating display, for ARG milliseconds.")
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
174 (n)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
175 Lisp_Object n;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
176 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
177 unsigned useconds;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
178
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
179 CHECK_NUMBER (n, 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
180 useconds = XINT(n) * 1000;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
181 usleep(useconds);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
182 return(Qt);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
183 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
184
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
185 DEFUN ("update-display", Fupdate_display, Supdate_display, 0, 0, 0,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
186 "Perform redisplay.")
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
187 ()
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
188 {
116
6b517878550a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 60
diff changeset
189 redisplay_preserve_echo_area ();
19
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
190 return(Qt);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
191 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
192
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
193
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
194 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
195 * Change the Sun mouse icon
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
196 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
197 DEFUN ("sun-change-cursor-icon",
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
198 Fsun_change_cursor_icon,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
199 Ssun_change_cursor_icon, 1, 1, 0,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
200 "Change the Sun mouse cursor icon. ICON is a lisp vector whose 1st element\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
201 is the X offset of the cursor hot-point, whose 2nd element is the Y offset\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
202 of the cursor hot-point and whose 3rd element is the cursor pixel data\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
203 expressed as a string. If ICON is nil then the original arrow cursor is used")
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
204 (Icon)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
205 Lisp_Object Icon;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
206 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
207 register unsigned char *cp;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
208 register short *p;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
209 register int i;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
210 Lisp_Object X_Hot, Y_Hot, Data;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
211
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
212 CHECK_GFX (Qnil);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
213 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
214 * If the icon is null, we just restore the DefaultCursor
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
215 */
485
8c615e453683 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 116
diff changeset
216 if (NILP(Icon))
19
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
217 CurrentCursor = DefaultCursor;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
218 else {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
219 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
220 * extract the data from the vector
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
221 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
222 CHECK_VECTOR (Icon, 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
223 if (XVECTOR(Icon)->size < 3) return(Qnil);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
224 X_Hot = XVECTOR(Icon)->contents[0];
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
225 Y_Hot = XVECTOR(Icon)->contents[1];
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
226 Data = XVECTOR(Icon)->contents[2];
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
227
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
228 CHECK_NUMBER (X_Hot, 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
229 CHECK_NUMBER (Y_Hot, 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
230 CHECK_STRING (Data, 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
231 if (XSTRING(Data)->size != 32) return(Qnil);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
232 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
233 * Setup the new cursor
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
234 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
235 NewCursor.cur_xhot = X_Hot;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
236 NewCursor.cur_yhot = Y_Hot;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
237 cp = XSTRING(Data)->data;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
238 p = CursorData;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
239 i = 16;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
240 while(--i >= 0)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
241 *p++ = (cp[0] << 8) | cp[1], cp += 2;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
242 CurrentCursor = NewCursor;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
243 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
244 win_setcursor(win_fd, &CurrentCursor);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
245 return(Qt);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
246 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
247
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
248 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
249 * Interface for sunwindows selection
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
250 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
251 static Lisp_Object Current_Selection;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
252
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
253 static
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
254 sel_write (sel, file)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
255 struct selection *sel;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
256 FILE *file;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
257 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
258 fwrite (XSTRING (Current_Selection)->data, sizeof (char),
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
259 sel->sel_items, file);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
260 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
261
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
262 static
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
263 sel_clear (sel, windowfd)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
264 struct selection *sel;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
265 int windowfd;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
266 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
267 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
268
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
269 static
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
270 sel_read (sel, file)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
271 struct selection *sel;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
272 FILE *file;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
273 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
274 register int i, n;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
275 register char *cp;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
276
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
277 Current_Selection = make_string ("", 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
278 if (sel->sel_items <= 0)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
279 return (0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
280 cp = (char *) malloc(sel->sel_items);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
281 if (cp == (char *)0) {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
282 error("malloc failed in sel_read");
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
283 return(-1);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
284 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
285 n = fread(cp, sizeof(char), sel->sel_items, file);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
286 if (n > sel->sel_items) {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
287 error("fread botch in sel_read");
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
288 return(-1);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
289 } else if (n < 0) {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
290 error("Error reading selection.");
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
291 return(-1);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
292 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
293 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
294 * The shelltool select saves newlines as carrige returns,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
295 * but emacs wants newlines.
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
296 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
297 for (i = 0; i < n; i++)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
298 if (cp[i] == '\r') cp[i] = '\n';
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
299
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
300 Current_Selection = make_string (cp, n);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
301 free (cp);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
302 return (0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
303 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
304
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
305 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
306 * Set the window system "selection" to be the arg STRING
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
307 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
308 DEFUN ("sun-set-selection", Fsun_set_selection, Ssun_set_selection, 1, 1,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
309 "sSet selection to: ",
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
310 "Set the current sunwindow selection to STRING.")
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
311 (str)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
312 Lisp_Object str;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
313 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
314 struct selection selection;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
315
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
316 CHECK_STRING (str, 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
317 Current_Selection = str;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
318
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
319 CHECK_GFX (Qnil);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
320 selection.sel_type = SELTYPE_CHAR;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
321 selection.sel_items = XSTRING (str)->size;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
322 selection.sel_itembytes = 1;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
323 selection.sel_pubflags = 1;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
324 selection_set(&selection, sel_write, sel_clear, win_fd);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
325 return (Qt);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
326 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
327 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
328 * Stuff the current window system selection into the current buffer
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
329 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
330 DEFUN ("sun-get-selection", Fsun_get_selection, Ssun_get_selection, 0, 0, 0,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
331 "Return the current sunwindows selection as a string.")
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
332 ()
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
333 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
334 CHECK_GFX (Current_Selection);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
335 selection_get (sel_read, win_fd);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
336 return (Current_Selection);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
337 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
338
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
339 Menu sun_menu_create();
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
340
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
341 Menu_item
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
342 sun_item_create (Pair)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
343 Lisp_Object Pair;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
344 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
345 /* In here, we depend on Lisp supplying zero terminated strings in the data*/
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
346 /* so we can just pass the pointers, and not recopy anything */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
347
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
348 Menu_item menu_item;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
349 Menu submenu;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
350 Lisp_Object String;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
351 Lisp_Object Value;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
352
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
353 if (!CONSP(Pair)) wrong_type_argument(Qlistp, Pair);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
354 String = Fcar(Pair);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
355 CHECK_STRING(String, 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
356 Value = Fcdr(Pair);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
357 if(XTYPE(Value) == Lisp_Symbol)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
358 Value = XSYMBOL(Value)->value;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
359 if(XTYPE(Value) == Lisp_Vector) {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
360 submenu = sun_menu_create (Value);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
361 menu_item = menu_create_item
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
362 (MENU_RELEASE, MENU_PULLRIGHT_ITEM, XSTRING(String)->data, submenu, 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
363 } else {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
364 menu_item = menu_create_item
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
365 (MENU_RELEASE, MENU_STRING_ITEM, XSTRING(String)->data, Value, 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
366 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
367 return menu_item;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
368 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
369
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
370 Menu
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
371 sun_menu_create (Vector)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
372 Lisp_Object Vector;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
373 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
374 Menu menu;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
375 int i;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
376 CHECK_VECTOR(Vector,0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
377 menu=menu_create(0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
378 for(i = 0; i < XVECTOR(Vector)->size; i++) {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
379 menu_set (menu, MENU_APPEND_ITEM,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
380 sun_item_create(XVECTOR(Vector)->contents[i]), 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
381 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
382 return menu;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
383 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
384
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
385 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
386 * If the first item of the menu has nil as its value, then make the
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
387 * item look like a label by inverting it and making it unselectable.
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
388 * Returns 1 if the label was made, 0 otherwise.
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
389 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
390 int
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
391 make_menu_label (menu)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
392 Menu menu;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
393 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
394 int made_label_p = 0;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
395
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
396 if (( menu_get(menu, MENU_NITEMS) > 0 ) && /* At least one item */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
397 ((Lisp_Object) menu_get(menu_get(menu, MENU_NTH_ITEM, 1),
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
398 MENU_VALUE) == Qnil )) {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
399 menu_set(menu_get(menu, MENU_NTH_ITEM, 1),
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
400 MENU_INVERT, TRUE,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
401 MENU_FEEDBACK, FALSE,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
402 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
403 made_label_p = 1;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
404 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
405 return made_label_p;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
406 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
407
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
408 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
409 * Do a pop-up menu and return the selected value
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
410 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
411 DEFUN ("sun-menu-internal",
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
412 Fsun_menu_internal,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
413 Ssun_menu_internal, 5, 5, 0,
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
414 "Set up a SunView pop-up menu and return the user's choice.\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
415 Arguments WINDOW, X, Y, BUTTON, and MENU.\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
416 *** User code should generally use sun-menu-evaluate ***\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
417 \n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
418 Arguments WINDOW, X, Y, BUTTON, and MENU.\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
419 Put MENU up in WINDOW at position X, Y.\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
420 The BUTTON argument specifies the button to be released that selects an item:\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
421 1 = LEFT BUTTON\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
422 2 = MIDDLE BUTTON\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
423 4 = RIGHT BUTTON\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
424 The MENU argument is a vector containing (STRING . VALUE) pairs.\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
425 The VALUE of the selected item is returned.\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
426 If the VALUE of the first pair is nil, then the first STRING will be used\n\
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
427 as a menu label.")
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
428 (window, X_Position, Y_Position, Button, MEnu)
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
429 Lisp_Object window, X_Position, Y_Position, Button, MEnu;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
430 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
431 Menu menu;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
432 int button, xpos, ypos;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
433 Event event0;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
434 Event *event = &event0;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
435 Lisp_Object Value, Pair;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
436
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
437 CHECK_NUMBER(X_Position, 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
438 CHECK_NUMBER(Y_Position, 1);
1437
36ef55ecb265 * frame.c (make_frame_without_minibuffer, Fwindow_frame): Use
Jim Blandy <jimb@redhat.com>
parents: 766
diff changeset
439 CHECK_LIVE_WINDOW(window, 2);
19
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
440 CHECK_NUMBER(Button, 3);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
441 CHECK_VECTOR(MEnu, 4);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
442
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
443 CHECK_GFX (Qnil);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
444
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
445 xpos = CtoSX (XWINDOW(window)->left + XINT(X_Position));
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
446 ypos = CtoSY (XWINDOW(window)->top + XINT(Y_Position));
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
447 #ifdef Menu_Base_Kludge
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
448 {static Lisp_Object symbol[2];
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
449 symbol[0] = Fintern (sm_kludge_string, Qnil);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
450 Pair = Ffuncall (1, symbol);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
451 xpos += XINT (XCONS (Pair)->cdr);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
452 ypos += XINT (XCONS (Pair)->car);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
453 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
454 #endif
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
455
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
456 button = XINT(Button);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
457 if(button == 4) button = 3;
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
458 event_set_id (event, BUT(button));
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
459 event_set_down (event);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
460 event_set_x (event, xpos);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
461 event_set_y (event, ypos);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
462
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
463 menu = sun_menu_create(MEnu);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
464 make_menu_label(menu);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
465
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
466 #ifdef Menu_Base_Kludge
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
467 Value = (Lisp_Object) menu_show(menu, Menu_Base_Frame, event, 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
468 #else
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
469 /* This confuses the notifier or something: */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
470 Value = (Lisp_Object) menu_show_using_fd(menu, win_fd, event, 0);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
471 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
472 * Right button gets lost, and event sequencing or delivery gets mixed up
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
473 * So, until that gets fixed, we use this <Menu_Base_Frame> kludge:
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
474 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
475 #endif
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
476 menu_destroy (menu);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
477
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
478 return ((int)Value ? Value : Qnil);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
479 }
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
480
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
481
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
482 /*
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
483 * Define everything
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
484 */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
485 syms_of_sunfns()
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
486 {
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
487 #ifdef Menu_Base_Kludge
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
488 /* i'm just too lazy to re-write this into C code */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
489 /* so we will call this elisp function from C */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
490 sm_kludge_string = make_pure_string ("sm::menu-kludge", 15);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
491 #endif /* Menu_Base_Kludge */
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
492
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
493 defsubr(&Ssun_window_init);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
494 defsubr(&Ssit_for_millisecs);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
495 defsubr(&Ssleep_for_millisecs);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
496 defsubr(&Supdate_display);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
497 defsubr(&Ssun_change_cursor_icon);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
498 defsubr(&Ssun_set_selection);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
499 defsubr(&Ssun_get_selection);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
500 defsubr(&Ssun_menu_internal);
58b14548d982 Initial revision
Joseph Arceneaux <jla@gnu.org>
parents:
diff changeset
501 }