annotate src/gui_riscos.c @ 811:d2c169a725c8

updated for version 7.0c01
author vimboss
date Mon, 27 Mar 2006 20:55:21 +0000
parents d0d15b184c56
children 1f929f3ca806
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 #include <string.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 * gui_riscos.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 * Thomas Leonard <tal197@ecs.soton.ac.uk>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 * Updated by Andy Wingate <andy@sparse.net>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 extern int time_of_last_poll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 int task_handle = 0; /* Zero means we are not yet a Wimp task */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 int child_handle = 0; /* Task handle of our child process (zero if none). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 int *wimp_menu = (int *) -1; /* Pointer to a Wimp menu structure (or -1) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 int save_window = -1; /* Save As window handle */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 int *redraw_block = NULL; /* NULL means not in a redraw loop. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 int ro_return_early = FALSE; /* Break out of gui_mch_wait_for_chars() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 int leaf_ref = 0; /* Wimp message number - send via Wimp$Scrap */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 char_u *leaf_name = NULL; /* Leaf name from DataSave */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 int default_columns = 120; /* These values are used if the --rows and --columns */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 int default_rows = 32; /* options aren't used on startup. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 #define DRAG_FALSE 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 #define DRAG_SELECTION 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 #define DRAG_RESIZE_WINDOW 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 int ro_dragging = DRAG_FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 int drag_button;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 int drag_modifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 int drag_x_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 int drag_y_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 int nested_wimp = FALSE; /* Bool - can we use the new wimp? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 int changed_mode = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 int x_eigen_factor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 int y_eigen_factor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 /* If ro_current_font is non-zero then use the outline font with that handle,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 * otherwise, if zap_redraw is TRUE then use ZapRedraw, otherwise use the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 * system font.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 * If zap_redraw is TRUE then zap_file[] contains valid Zap font file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 * pointers (or NULLs).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 int ro_current_font = 0; /* 0 is system font, or ZapRedraw */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 int font_x_offset = 0; /* Where to position each char in its box */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 int font_y_offset = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 int zap_redraw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 int double_height = FALSE; /* Plot each line twice? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 #define grgb(r,g,b) ((b<<16) + (g<<8) + (r))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 #define UNUSED_COLOUR (gui.back_pixel)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 #define RO_LOAD_CLIPBOARD -2 /* Internal handle for DataSave message. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 /* Changes by John Kortink, 22-23 July 1998
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 * Stuff to make redraw a lot faster. Almost all of it is right here below,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 * elsewhere changes are marked with 'JK230798'. Apart from a small change in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 * 'gui.c' all changes are limited to this file, 'gui_riscos.c'. The change in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 * 'gui.c' is to make Vim stop being 'smart' not redrawing characters that are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 * 'already there' (i.e. from the previous line, by coincidence). This caused a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 * lot more calls to the redraw code, which we want to avoid because a few nice
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 * big strings at a time is a lot faster than a truckload of small ones. ('Dear
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 * Bram ...').
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 /* The ZapRedraw structure */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 static struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 int r_flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 int r_minx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 int r_miny;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 int r_maxx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 int r_maxy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 int r_screen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 int r_bpl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 int r_bpp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 int r_charw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 int r_charh;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 char *r_caddr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 int r_cbpl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 int r_cbpc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 int r_linesp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 int r_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 int r_scrollx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 int r_scrolly;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 int *r_palette;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 int r_for;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 int r_bac;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 char *r_workarea;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 int r_magx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 int r_magy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 int r_xsize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 int r_ysize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 int r_mode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 zap_redraw_block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 /* Other globals */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 static int zap_redraw_initialised = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 static int zap_redraw_update_colours;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 static int zap_redraw_colours[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 static int zap_redraw_palette[16];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 /* Holds the current Zap font file(s).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 * The font is recreated from this block on a mode change.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 * When using zap, element ZAP_NORMAL is always valid, but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 * the others can be NULL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 #define ZAP_NORMAL 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 #define ZAP_BOLD 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 #define ZAP_ITALIC 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 #define ZAP_BITALIC 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 #define ZAP_STYLES 4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 /* Zap font file format data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 static char *zap_file[ZAP_STYLES] = {NULL, NULL, NULL, NULL};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 /* r_caddr format for current mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 static char *zap_caddr[ZAP_STYLES] = {NULL, NULL, NULL, NULL};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 static void ro_remove_menu(int *menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 * Initialise all the ZapRedraw stuff.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 * Call this when changing font and after each mode change.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 * zap_redraw_bitmap must contain a valid Zap font file (possibly
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 * created from the system font).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 * Return FAIL to revert to system font (if we can't use ZapRedraw).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 ro_zap_redraw_initialise()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 int bytes_per_bitmap_char;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 int first, last;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 /* Can't have initialisers for struct members :-(, ok, this way then ... */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 if (!zap_redraw_initialised)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 zap_redraw_block.r_workarea = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 zap_redraw_initialised = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 /* We redraw in DSA mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 zap_redraw_block.r_flags = 0x0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 /* Let ZapRedraw get the screen address for us */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168 zap_redraw_block.r_screen = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 /* Read the font width and height from the font file header.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 * Assume that all styles are the same size.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 * ZAP_NORMAL is always present.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 zap_redraw_block.r_charw = ((int *) zap_file[ZAP_NORMAL])[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 zap_redraw_block.r_charh = ((int *) zap_file[ZAP_NORMAL])[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 /* We have no linespacing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 zap_redraw_block.r_linesp = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 /* Fix foreground = colour 1 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 zap_redraw_block.r_for = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 /* Fix background = colour 0 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 zap_redraw_block.r_bac = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 /* Colour mask buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 zap_redraw_block.r_palette = zap_redraw_palette;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 /* Allocate local workspace (for the few calls following here) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 if (zap_redraw_block.r_workarea != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 free(zap_redraw_block.r_workarea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 zap_redraw_block.r_workarea = (char*) malloc(128);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 if (!zap_redraw_block.r_workarea)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 return FAIL; /* Out of memory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 /* Fill in VDU variables */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 if (xswi(ZapRedraw_ReadVduVars, 0, &zap_redraw_block) & v_flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 return FAIL; /* Can't find ZapRedraw module - use VDU instead */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 /* Determine cbpl and cbpc */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 swi(ZapRedraw_CachedCharSize, zap_redraw_block.r_bpp, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 zap_redraw_block.r_charw, zap_redraw_block.r_charh);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 zap_redraw_block.r_cbpl = r2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 zap_redraw_block.r_cbpc = r3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 /* Allocate general workspace (for the calls outside) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207 if (zap_redraw_block.r_workarea != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 free(zap_redraw_block.r_workarea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 zap_redraw_block.r_workarea = (char*) malloc(128 + zap_redraw_block.r_cbpl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 if (!zap_redraw_block.r_workarea)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 return FAIL; /* Out of memory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 /* Now convert the 1 bpp character data ready for the current mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
215 bytes_per_bitmap_char = (zap_redraw_block.r_charw * zap_redraw_block.r_charh + 7) / 8;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217 /* Convert the fonts from 1bpp to a format suitable for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
218 * current mode.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
219 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 for (i = 0; i < ZAP_STYLES; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 first = ((int *) zap_file[i])[4];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 last = ((int *) zap_file[i])[5];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
225 if (last > 255)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226 last = 255; /* Don't convert cursors (overwrites memory!) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
227
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228 /* Allocate the font cache */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
229 vim_free(zap_caddr[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 if (zap_file[i])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 zap_caddr[i] = (char*) malloc(zap_redraw_block.r_cbpc * 256);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 zap_caddr[i] = NULL; /* No file for this style */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 if (zap_caddr[i])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 zap_redraw_block.r_caddr = zap_caddr[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 swi(ZapRedraw_ConvertBitmap, 0, &zap_redraw_block,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240 first, last, /* Range of characters to convert */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 zap_file[i] + 0x20 /* Addr of first char provided by font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 - first * bytes_per_bitmap_char);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 if (!zap_caddr[ZAP_NORMAL])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 zap_redraw = FALSE; /* Out of memory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 /* Next time we need them, we have to update the colour masks */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 zap_redraw_update_colours = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 * Redraw a string at OS coordinates <x,y> (top-left, x inclusive, y exclusive).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 * Graphics clip window is window[0..3] as in R1+28..40 of Wimp_RedrawWindow.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 * Returns (possibly modified) flags.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 ro_zap_redraw_draw_string(x, y, string, length, flags, clip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 char *string;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 int length;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 int flags; /* DRAW_TRANSP, DRAW_BOLD, DRAW_UNDERL, DRAW_ITALIC */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 int *clip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 char redraw_data[1024];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 int clip_minx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 int clip_miny;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 int clip_maxx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 int clip_maxy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 int os_xshift = zap_redraw_block.r_magx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 int os_yshift = zap_redraw_block.r_magy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 if (flags & DRAW_TRANSP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 return flags; /* We don't do transparent plotting yet. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 if (flags & DRAW_BOLD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 if (flags & DRAW_ITALIC && zap_caddr[ZAP_BITALIC])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 zap_redraw_block.r_caddr = zap_caddr[ZAP_BITALIC];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 zap_redraw_block.r_caddr = zap_caddr[ZAP_BOLD];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 if (flags & DRAW_ITALIC)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 zap_redraw_block.r_caddr = zap_caddr[ZAP_ITALIC];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 zap_redraw_block.r_caddr = zap_caddr[ZAP_NORMAL];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 if (!zap_redraw_block.r_caddr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 zap_redraw_block.r_caddr = zap_caddr[ZAP_NORMAL];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 flags |= DRAW_UNDERL; /* Style missing - we can always underline */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 /* Set the vertical scaling flag */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 if (double_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 zap_redraw_block.r_flags = 1 << 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 zap_redraw_block.r_flags = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 /* Update the colour masks (if needed) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 if (zap_redraw_update_colours)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 swi(ZapRedraw_CreatePalette, 2,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 &zap_redraw_block,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 zap_redraw_colours,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 zap_redraw_block.r_palette, 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 zap_redraw_update_colours = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 /* Target rectangle in ZapRedraw rectangle coordinates (pixels, Y-min/max reversed !!!) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 zap_redraw_block.r_minx = x >> os_xshift; /* inclusive */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 zap_redraw_block.r_miny = zap_redraw_block.r_ysize - (y >> os_yshift); /* inclusive */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 zap_redraw_block.r_maxx = (x + length * gui.char_width) >> os_xshift; /* exclusive */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 zap_redraw_block.r_maxy = zap_redraw_block.r_ysize - ((y - gui.char_height) >> os_yshift);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 /* exclusive */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 /* Clip rectangle in ZapRedraw rectangle coordinates (pixels, Y-min/max reversed !!!) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 clip_minx = clip[0] >> os_xshift; /* inclusive */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 clip_miny = zap_redraw_block.r_ysize - (clip[3] >> os_yshift); /* inclusive */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 clip_maxx = clip[2] >> os_xshift; /* exclusive */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 clip_maxy = zap_redraw_block.r_ysize - (clip[1] >> os_yshift); /* exclusive */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 /* Clip target rectangle against the current graphics window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 if (zap_redraw_block.r_minx < clip_minx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 zap_redraw_block.r_scrollx = clip_minx - zap_redraw_block.r_minx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 zap_redraw_block.r_minx = clip_minx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 zap_redraw_block.r_scrollx = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 if (zap_redraw_block.r_miny < clip_miny)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 zap_redraw_block.r_scrolly = clip_miny - zap_redraw_block.r_miny;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 zap_redraw_block.r_miny = clip_miny;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 zap_redraw_block.r_scrolly = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 if (zap_redraw_block.r_maxx > clip_maxx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 zap_redraw_block.r_maxx = clip_maxx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 if (zap_redraw_block.r_maxy > clip_maxy)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 zap_redraw_block.r_maxy = clip_maxy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 /* Fill in the character data structure */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 if (length > (sizeof(redraw_data) - 2 * 4 - 2))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 length = sizeof(redraw_data) - 2 * 4 - 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355 ((int*) redraw_data)[0] = 2 * 4;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 ((int*) redraw_data)[1] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 strncpy(redraw_data + 2 * 4, string, length);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 redraw_data[2 * 4 + length + 0] = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 redraw_data[2 * 4 + length + 1] = '\x2';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 zap_redraw_block.r_data = (int) redraw_data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 /* Perform the draw */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 swi(ZapRedraw_RedrawArea, 0, &zap_redraw_block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365 return flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 * Okay that was it from me, back to Thomas ...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373 * Parse the GUI related command-line arguments. Any arguments used are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 * deleted from argv, and *argc is decremented accordingly. This is called
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 * when vim is started, whether or not the GUI has been started.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 gui_mch_prepare(int *argc, char **argv)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 int arg = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 while (arg < *argc - 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 if (strcmp(argv[arg], "--rows") == 0 || strcmp(argv[arg], "--columns") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 int value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 value = atoi(argv[arg + 1]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 if (argv[arg][2] == 'r')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 default_rows = value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393 default_columns = value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 /* Delete argument from argv[]. (hope this is read/write!) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 *argc -= 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 if (*argc > arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 mch_memmove(&argv[arg], &argv[arg + 2], (*argc - arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 * sizeof(char *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 arg++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 /* Fatal error on initialisation - report it and die. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 ro_die(error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 char_u *error; /* RISC OS error block */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 swi(Wimp_ReportError, error, 5, "GVim");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 exit(EXIT_FAILURE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 /* Find the sizes of the window tools:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 * Create a test window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 * Find inner and outer sizes.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 * Find the difference.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 * Delete window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 * While we're here, find the eigen values too.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 ro_measure_tools()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 int block[10];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 int vdu[] = { 4, 5, -1};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 int test_window[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 -100, -100, /* Visible area : min X,Y */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 -50, -50, /* max X,Y */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434 0, 0, /* Scroll offsets */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 -1, /* Window in front */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 0xd0800150, /* Window flags */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 0xff070207, /* Colours */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438 0x000c0103, /* More colours */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 0, -0x4000, /* Workarea extent */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 0x4000, 0, /* max X,Y */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 0x00000000, /* No title */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 0 << 12, /* No workarea button type */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 1, /* Wimp sprite area */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 0x00010001, /* Minimum width, height */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 0, 0, 0, /* Title data (none) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 0 /* No icons */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 int inner_max_x, inner_min_y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 swi(Wimp_CreateWindow, 0, test_window);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 block[0] = r0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 /* Open the window (and read state).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 * GetWindowOutline needs it too if the wimp isn't nested.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 swi(Wimp_OpenWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457 inner_max_x = block[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 inner_min_y = block[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 swi(Wimp_GetWindowOutline, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 gui.scrollbar_width = block[3] - inner_max_x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 gui.scrollbar_height = inner_min_y - block[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 swi(Wimp_DeleteWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 /* Read the size of one pixel. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 swi(OS_ReadVduVariables, vdu, vdu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 x_eigen_factor = vdu[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 y_eigen_factor = vdu[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 /* Load a template from the current templates file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 * Create the window and return its handle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 ro_load_template(str_name, title, title_size)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 char_u *str_name; /* Identifier of window in file (max 12 chars) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479 char_u **title; /* If not NULL then return pointer to title here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 int *title_size; /* If not NULL then return the title length here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 int *window;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 char *data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 int name[4];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 strcpy( (char *) name, str_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 /* Find how big we must make the buffers */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 if (xswi(Wimp_LoadTemplate, 0, 0, 0, 0, -1, name, 0) & v_flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 ro_die( (char *) r0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 window = malloc(r1); /* Don't print text messages from alloc() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 data = malloc(r2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 if (window == NULL || data == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 ro_die("\0\0\0\0Out of memory - Can't load templates");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 /* Load the template into the buffers */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 swi(Wimp_LoadTemplate, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 window, /* Temp block */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 data, /* Icon data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503 data + r2 + 1, /* End of icon data */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 -1, /* No fonts */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 name, 0); /* First match */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 if (r6 == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 ro_die("\0\0\0\0Can't find window in Templates file");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 /* Create the window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 if (xswi(Wimp_CreateWindow, 0, window) & v_flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 ro_die( (char *) r0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 if (title)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 *title = (char_u *) window[18];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516 if (title_size)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 *title_size = window[20];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 free(window); /* Free temp block */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 return r0; /* Return the window handle */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 * Check if the GUI can be started. Called before gvimrc is sourced.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 * Return OK or FAIL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 gui_mch_init_check()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
530 return OK; /* TODO: GUI can always be started? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
531 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
532
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 * Initialise the RISC OS GUI.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 * Create all the windows.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
536 * Returns OK for success, FAIL when the GUI can't be started.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
539 gui_mch_init()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 int messages[] = {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 1, 2, 3, 4, /* DataSave, DataSaveAck, DataLoad, DataLoadAck */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
543 8, /* PreQuit */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 0xf, /* ClaimEntity (for clipboard) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
545 0x10, /* DataRequest (for clipboard) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
546 0x400c1, /* Mode change */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 0x400c3, /* TaskCloseDown */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 0x400c9, /* MenusDeleted */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549 0x808c1, /* TW_Output */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
550 0x808c2, /* TW_Ego */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 0x808c3, /* TW_Morio */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 0x808c4, /* TW_Morite */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
553 0}; /* End-of-list. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
554
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
555
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 /* There may have been some errors reported in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
557 * command window before we get here. Wait if so.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
559 swi(Wimp_ReadSysInfo, 3);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 if (r0 == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 swi(Wimp_CommandWindow, 0); /* Window opened - close with prompt */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 if (xswi(Wimp_Initialise, 310, 0x4b534154, "GVim", messages) & v_flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
565 nested_wimp = r0 >= 397;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 task_handle = r1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
567
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 /* Load the templates. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 if (xswi(Wimp_OpenTemplate, 0, "Vim:Templates") & v_flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 ro_die( (char *) r0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
573 gui.window_handle = ro_load_template("editor",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 &gui.window_title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 &gui.window_title_size);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 save_window = ro_load_template("save", NULL, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 swi(Wimp_CloseTemplate);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 /* Set default foreground and background colours. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 gui.norm_pixel = gui.def_norm_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 gui.back_pixel = gui.def_back_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 /* Get the colours from the "Normal" and "Menu" group (set in syntax.c or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 * in a vimrc file) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 set_normal_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 * Check that none of the colors are the same as the background color
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 gui_check_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 /* Get the colours for the highlight groups (gui_check_colors() might have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 * changed them) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 highlight_gui_started(); /* re-init colours and fonts */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 /* Set geometry based on values read on initialisation. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 gui.num_cols = Columns = default_columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 gui.num_rows = Rows = default_rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 /* Get some information about our environment. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 ro_measure_tools();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 * Called when the foreground or background colour has been changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 gui_mch_new_colors()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 * Open the GUI window which was created by a call to gui_mch_init().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 gui_mch_open(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 int block[10];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 block[7] = -1; /* Open at the top of the stack */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 swi(Wimp_OpenWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 /* Give the new window the input focus */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 swi(Wimp_SetCaretPosition, gui.window_handle, -1, 0, 0, -1, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 if (gui_win_x != -1 && gui_win_y != -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 gui_mch_set_winpos(gui_win_x, gui_win_y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 gui_mch_exit(int rc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 int block[64];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 /* Close window. Stops us from getting troublesome events
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 * if we take a while to die.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 swi(Wimp_CloseWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 if (child_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 /* We still have a sub-task running - kill it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 block[0] = 20;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 block[3] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 block[4] = 0; /* Quit */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 if ((xswi(Wimp_SendMessage, 17, block, child_handle) & v_flag) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 /* Idle until child dies. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 while (child_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 process_event(wimp_poll(1, block), block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 exit(rc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 * Get the position of the top left corner of the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678 gui_mch_get_winpos(int *x, int *y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 * Set the position of the top left corner of the window to the given
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 * coordinates.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 gui_mch_set_winpos(int x, int y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
693
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 void
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 444
diff changeset
695 gui_mch_set_shellsize(width, height, min_width, min_height, base_width, base_height, direction)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 int width; /* In OS units */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 int height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698 int min_width; /* Smallest permissable window size (ignored) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 int min_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 int base_width; /* Space for scroll bars, etc */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 int base_height;
811
d2c169a725c8 updated for version 7.0c01
vimboss
parents: 444
diff changeset
702 int direction;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 int s_width, s_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 int block[] = {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 gui.window_handle,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 -height + 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 1};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 gui_mch_get_screen_dimensions(&s_width, &s_height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 s_width -= base_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 s_height -= base_height; /* Underestimate - ignores titlebar */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 block[3] = block[1] + width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 block[2] = block[4] - height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 if (block[3] > s_width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721 block[3] = s_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 block[1] = block[3] - width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 if (block[2] < gui.scrollbar_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726 block[2] = gui.scrollbar_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 block[4] = block[2] + height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 swi(Wimp_OpenWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 swi(Wimp_ForceRedraw, gui.window_handle, 0, -height, width, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 int block[] = {4, 5, 11, 12, -1};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 swi(OS_ReadVduVariables, block, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 *screen_w = (block[2] + 1) << block[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 *screen_h = (block[3] + 1) << block[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 /* Take a font name with options and return a font handle, or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 * zero for failure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 * Replace extension with 'Bold' or 'Italic' depending on modifiers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 ro_get_font(fullname, weight)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 char_u *fullname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 int weight; /* Initial weights:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 * BIT MEANING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 * 0 bold
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 * 1 italic
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 char_u *arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 char_u font[41];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 int width = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 int height = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 int name_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 char_u c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 for (i = 0; i < 39;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 c = fullname[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 if (c == ':' || c == NUL || c == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 font[i++] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772 /* find the first modifier, NULL if none */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 arg = strchr(fullname + i, ':');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 while (arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 switch (*++arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 case 'h':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 height = strtol(arg + 1, (char **) &arg, 10);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 case 'w':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 width = strtol(arg + 1, (char **) &arg, 10);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 case 'b':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 weight |= 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788 case 'i':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 weight |= 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 arg = strchr(arg, ':');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 if ((weight & 1) && i < 35)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 /* Bold goes instead of given suffix */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 strncpy(font + i, ".Bold", 5);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 i += 5;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 /* Copy rest of name unless we are using Bold */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806 while (i < 39)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 c = fullname[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 if (c == ':' || c == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 font[i++] = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
813 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 if ((weight & 2) && i < 32)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
815 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 strncpy(font + i, ".Oblique", 8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 i += 8;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 font[i] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 if (height < 1 && width < 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 height = width = 10; /* Default to 10pt */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 else if (height < 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 height = width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 else if (width < 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 width = height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
829 if (xswi(Font_FindFont, 0, font, width << 4, height << 4, 0, 0) & v_flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830 return NOFONT; /* Can't find font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 return r0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
835 /* Load a file into allocated memory and check it is valid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
836 * Return a pointer to the allocated block on success.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
838 char *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 zap_load_file(name, style)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 char_u *name; /* Name of directory containing styles */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 char_u *style; /* Name of style within directory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 char_u fname[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
844 char_u *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846 if (strlen(name) + strlen(style) > 254)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 return NULL; /* Names too long */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 sprintf(fname, "%s.%s", name, style);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
850
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 /* Load the named font in 1bpp format. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 if (xswi(OS_File, 13, fname, 0, 0, "VimFonts:") & v_flag || r0 != 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 return NULL; /* Error reading file info, or not a file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 /* Allocate enough memory to load the whole file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 file = (char *) alloc(r4);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 if (!file)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 return NULL; /* Out of memory */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 if (xswi(OS_File, 12, fname, file, 0, "VimFonts:") & v_flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 return NULL; /* Unable to load file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 if (strncmp(file, "ZapFont\015", 8) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 return file; /* Loaded OK! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 free(file);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867 return NULL; /* Not a valid font file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 /* Load and convert the named font.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 * If name is NULL or a null string then convert the system font.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 * Return OK on success; FAIL and we revert to using the VDU drivers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 * 'name' is the name of a directory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 * Tries to load 'name.0', 'name.B', 'name.I' and 'name.IB'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 zap_load_font(name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 /* Free the existing font files, if any */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 for (i = 0; i < ZAP_STYLES; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 vim_free(zap_file[i]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 zap_file[i] = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 if (name && *name == '!')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 name++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 double_height = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 double_height = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 if (name && *name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 zap_file[ZAP_NORMAL] = zap_load_file(name, "0");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 if (!zap_file[ZAP_NORMAL])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 return FAIL; /* Can't load the 'normal' style - error */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 zap_file[ZAP_BOLD] = zap_load_file(name, "B");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 zap_file[ZAP_ITALIC] = zap_load_file(name, "I");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 zap_file[ZAP_BITALIC] = zap_load_file(name, "IB");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 int *header;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 char workarea[16];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 char *old_wa;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 /* Allocate memory for system font (8 x 8 x 256 bits, plus header) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 header = (int *) alloc(0x20 + 8 * 256);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 if (header == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 zap_file[ZAP_NORMAL] = (char *) header;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 /* Store details about the system font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 header[2] = 8; /* Width */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 header[3] = 8; /* Height */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 header[4] = 0; /* First char */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924 header[5] = 255; /* Last char */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 header[6] = header[7] = 0; /* Reserved */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 /* Get system font bitmap */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 old_wa = zap_redraw_block.r_workarea;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 zap_redraw_block.r_workarea = workarea;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 swi(ZapRedraw_ReadSystemChars, zap_file[ZAP_NORMAL] + 0x20, &zap_redraw_block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 zap_redraw_block.r_workarea = old_wa;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 return ro_zap_redraw_initialise();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 * Initialise vim to use the font with the given name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 * Return FAIL if the font could not be loaded, OK otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942 gui_mch_init_font(char_u *font_name, int fontset)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 int new_handle = 0; /* Use the system font by default */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
945
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 if (font_name[0] == '!')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 /* Select a ZapRedraw font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 if (zap_load_font(font_name + 1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 zap_redraw = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 EMSG2(_("E610: Can't load Zap font '%s'"), font_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954 font_name = "System"; /* Error - use system font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 zap_redraw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 zap_redraw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 if (font_name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 /* Extract any extra details about the font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 new_handle = ro_get_font(font_name, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 if (!new_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
967 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
969 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 font_name = "System";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 /* Free the previous font, if any */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
974 gui_mch_free_font(gui.norm_font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 gui.norm_font = new_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976 gui.char_ascent = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 if (new_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 /* Read details about the chosen font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
981 swi(Font_ReadInfo, new_handle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 gui.char_width = r3 - r1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 gui.char_height = r4 - r2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
985
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 font_x_offset = -r1; /* Where to position each char in its box */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 font_y_offset = -r4;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
989 /* Try to load other fonts for bold, italic, and bold-italic */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
990 gui_mch_free_font(gui.bold_font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 gui.bold_font = ro_get_font(font_name, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 gui_mch_free_font(gui.ital_font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 gui.ital_font = ro_get_font(font_name, 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 gui_mch_free_font(gui.boldital_font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 gui.boldital_font = ro_get_font(font_name, 3);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999 /* Use the system font or ZapRedraw. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 if (zap_redraw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 gui.char_width = zap_redraw_block.r_charw << zap_redraw_block.r_magx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 gui.char_height = zap_redraw_block.r_charh << zap_redraw_block.r_magy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 if (double_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 gui.char_height <<= 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 gui.char_width = 16;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010 gui.char_height = 32;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 gui_mch_free_font(gui.bold_font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014 gui.bold_font = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 gui_mch_free_font(gui.ital_font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 gui.ital_font = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 gui_mch_free_font(gui.boldital_font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 gui.boldital_font = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 hl_set_font_name(font_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 must_redraw = CLEAR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025
444
d0d15b184c56 updated for version 7.0116
vimboss
parents: 273
diff changeset
1026 /*
d0d15b184c56 updated for version 7.0116
vimboss
parents: 273
diff changeset
1027 * Adjust gui.char_height (after 'linespace' was changed).
d0d15b184c56 updated for version 7.0116
vimboss
parents: 273
diff changeset
1028 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 int
444
d0d15b184c56 updated for version 7.0116
vimboss
parents: 273
diff changeset
1030 gui_mch_adjust_charheight()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 * Get a font structure for highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038 GuiFont
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 gui_mch_get_font(name, giveErrorIfMissing)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 int giveErrorIfMissing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1043 int handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1045 if (!name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 return NOFONT; /* System font if no name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 handle = ro_get_font(name, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 if (!handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 if (giveErrorIfMissing)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 EMSG2(_("E611: Can't use font %s"), name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053 return NOFONT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 return handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1057 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents: 37
diff changeset
1059 #if defined(FEAT_EVAL) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1060 /*
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1061 * Return the name of font "font" in allocated memory.
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1062 * Don't know how to get the actual name, thus use the provided name.
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1063 */
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1064 char_u *
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1065 gui_mch_get_fontname(font, name)
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1066 GuiFont font;
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1067 char_u *name;
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1068 {
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1069 if (name == NULL)
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1070 return NULL;
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1071 return vim_strsave(name);
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1072 }
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents: 37
diff changeset
1073 #endif
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1074
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
1075 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 * Set the current text font.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 gui_mch_set_font(GuiFont font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1080 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 ro_current_font = font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1082
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 if (font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 /* Not the system font or ZapRedraw font - select it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 swi(Font_SetFont, font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 * If a font is not going to be used, free its structure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 gui_mch_free_font(GuiFont font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1096 if (font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 swi(Font_LoseFont, font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 * Return the Pixel value (colour) for the given colour name.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 * Return INVALCOLOR for error.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 * NB: I've changed Green for now, since it looked really sick
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 guicolor_T
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 gui_mch_get_color(char_u *name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 struct colour
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112 guicolor_T value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 } colours[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 { "Red", grgb(255, 0, 0) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 { "LightRed", grgb(255, 0, 0) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 { "DarkRed", grgb(139, 0, 0) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119 { "Green", grgb(50, 200, 50) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 { "LightGreen", grgb(144, 238, 144) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 { "DarkGreen", grgb(0, 100, 0) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 { "SeaGreen", grgb(46, 139, 87) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 { "Blue", grgb(0, 0, 255) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125 { "LightBlue", grgb(173, 216, 230) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 { "DarkBlue", grgb(0, 0, 139) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 { "SlateBlue", grgb(160, 90, 205) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 { "Cyan", grgb(0, 255, 255) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 { "LightCyan", grgb(224, 255, 255) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 { "DarkCyan", grgb(0, 139, 139) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 { "Magenta", grgb(255, 0, 255) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 { "LightMagenta", grgb(255, 224, 255) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 { "DarkMagenta", grgb(139, 0, 139) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 { "Yellow", grgb(255, 255, 0) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138 { "LightYellow", grgb(255, 255, 224) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 { "DarkYellow", grgb(139, 139, 0) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 { "Brown", grgb(165, 42, 42) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142 { "Gray", grgb(190, 190, 190) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 { "Grey", grgb(190, 190, 190) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 { "LightGray", grgb(211, 211, 211) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 { "LightGrey", grgb(211, 211, 211) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 { "DarkGray", grgb(169, 169, 169) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 { "DarkGrey", grgb(169, 169, 169) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149 { "Black", grgb(0, 0, 0) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 { "White", grgb(255, 255, 255) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 { "Orange", grgb(255, 165, 0) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 { "Purple", grgb(160, 32, 240) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 { "Violet", grgb(238, 130, 238) },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 {NULL, 0}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 if (name[0] == '#')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 char *end;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 c = strtol(name + 1, &end, 16);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 return (guicolor_T) ((c >> 16) & 0xff) | (c & 0xff00) | ((c & 0xff) << 16);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 for (i = 0; colours[i].name != NULL; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 if (STRICMP(name, colours[i].name) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 return colours[i].value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 if (strnicmp(name, "grey", 4) == 0 || strnicmp(name, "gray", 4) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174 int level = (255 * atoi(name + 4)) / 100;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1175 return (guicolor_T) grgb(level, level, level);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 return INVALCOLOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 * Set the current text colours.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 * If we are using fonts then set the antialiasing colours too.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 gui_mch_set_colors(guicolor_T fg, guicolor_T bg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 zap_redraw_colours[0] = bg << 8; /* JK230798, register new background colour */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 zap_redraw_colours[1] = fg << 8; /* JK230798, register new foreground colour */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 zap_redraw_update_colours = TRUE; /* JK230798, need update of colour masks */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 swi(ColourTrans_ReturnGCOL, fg << 8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 gui.fg_colour = r0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 swi(ColourTrans_ReturnGCOL, bg << 8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 gui.bg_colour = r0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 if (ro_current_font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1197 swi(ColourTrans_SetFontColours, 0, bg << 8, fg << 8, 14);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 ro_draw_string(x, y, s, len, flags, clip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 int x; /* Top-left coord to plot at (x incl, y excl) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 int y; /* (screen coords) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204 char_u *s; /* String to plot */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1205 int len; /* Length of string */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 int flags; /* DRAW_TRANSP, DRAW_BOLD, DRAW_UNDERL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 int* clip; /* JK230798, added clip window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209 if (ro_current_font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 int fx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 int flen = len; /* Preserve for underline */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 /* Use the Font manager to paint the string.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 * Must do one char at a time to get monospacing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 if (flags & DRAW_ITALIC && !gui.ital_font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219 flags |= DRAW_UNDERL; /* No italic - underline instead */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 if ((flags & DRAW_TRANSP) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223 swi(ColourTrans_SetColour, gui.bg_colour, 0, 0, 0, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 swi(OS_Plot, 4, x, y - gui.char_height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 swi(OS_Plot, 96 + 5, x + len * gui.char_width - 1, y - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1226 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228 fx = x + font_x_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 while (flen--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 swi(Font_Paint, 0, s++, 0x90, fx, y + font_y_offset, 0, 0, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232 fx += gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 if (zap_redraw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 /* Using fast Zap redraw. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 flags = ro_zap_redraw_draw_string(x, y, s, len, flags, clip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 /* Using the system font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245 if (flags & DRAW_ITALIC)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 flags |= DRAW_UNDERL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 if ((flags & DRAW_TRANSP) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250 swi(ColourTrans_SetColour, gui.bg_colour, 0, 0, 0, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 swi(OS_Plot, 4, x, y - gui.char_height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252 swi(OS_Plot, 96 + 5, x + len * gui.char_width - 1, y - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 swi(OS_Plot, 4, /* Move the drawing cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 y - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 swi(ColourTrans_SetColour, gui.fg_colour, 0, 0, 0, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 swi(OS_WriteN, s, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 if (flags & DRAW_BOLD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 swi(OS_Plot, 4, x + (1 << x_eigen_factor), y - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 swi(OS_WriteN, s, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 if (flags & DRAW_UNDERL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 if (ro_current_font || zap_redraw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 swi(ColourTrans_SetColour, gui.fg_colour, 0, 0, 0, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 /* Underlined is the same with all plotting methods */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 swi(OS_Plot, 4, x, y - gui.char_height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 swi(OS_Plot, 1, gui.char_width * len, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279 gui_mch_draw_string(int row, int col, char_u *s, int len, int flags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 int x, y; /* Workarea x,y */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282 x = col * gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 y = -row * gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 if (redraw_block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 ro_draw_string(x + redraw_block[1], y + redraw_block[4],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 s, len, flags, &redraw_block[7]); /* JK230798, added clip window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 int block[44];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 block[1] = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 block[2] = y - gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 block[3] = (col + len) * gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 block[4] = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 swi(Wimp_UpdateWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 while (r0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 ro_draw_string(x + block[1], y + block[4],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302 s, len, flags, &block[7]); /* JK230798, added clip window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 swi(Wimp_GetRectangle, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1308 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 * Return OK if the key with the termcap name "name" is supported.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 gui_mch_haskey(char_u *name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1314 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1315 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1316
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1317 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1318 gui_mch_beep(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 swi(OS_WriteI + 7);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324 * Visual bell.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1325 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1326 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 gui_mch_flash(int msec)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1330 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 * Plot a solid rectangle using the given plot action and colour.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 * Coordinates are inclusive and window-relative.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 plot_rectangle(plot, colour, minx, miny, maxx, maxy)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 int plot; /* OS_Plot action */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 int colour;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 int minx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 int miny;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 int maxx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344 int maxy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1345 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 if (redraw_block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 swi(ColourTrans_SetColour, colour, 0, 0, 0, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 swi(OS_Plot, 4, minx + redraw_block[1], miny + redraw_block[4]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 swi(OS_Plot, plot, maxx + redraw_block[1], maxy + redraw_block[4]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1354 int block[44];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 block[1] = minx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 block[2] = miny;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 block[3] = maxx + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 block[4] = maxy + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 swi(Wimp_UpdateWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 while (r0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 swi(ColourTrans_SetColour, colour, 0, 0, 0, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 swi(OS_Plot, 4, minx + block[1], miny + block[4]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 swi(OS_Plot, plot, maxx + block[1], maxy + block[4]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366 swi(Wimp_GetRectangle, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1367 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 * Invert a rectangle from row r, column c, for nr rows and nc columns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 gui_mch_invert_rectangle(int r, int c, int nr, int nc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 plot_rectangle(96 + 6, 0, FILL_X(c), -FILL_Y(r + nr), FILL_X(c + nc), -FILL_Y(r));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 * Iconify the GUI window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 gui_mch_iconify(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 #if defined(FEAT_EVAL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 * Bring the Vim window to the foreground.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 gui_mch_set_foreground()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1398
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1399 /* Draw a hollow rectangle relative to the current
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1400 * graphics cursor position, with the given width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 * and height. Start position is top-left.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 draw_hollow(w, h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 int w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 int h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 swi(OS_Plot, 1, w - 1, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409 swi(OS_Plot, 1, 0, 1 - h);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 swi(OS_Plot, 1, 1 - w, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 swi(OS_Plot, 1, 0, h - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415 * Draw a cursor without focus.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 gui_mch_draw_hollow_cursor(guicolor_T colour)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 int x = FILL_X(gui.cursor_col); /* Window relative, top-left */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1421 int y = -FILL_Y(gui.cursor_row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422 if (redraw_block == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1423 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1424 int block[11];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 block[1] = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 block[2] = y - gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429 block[3] = x + gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 block[4] = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 swi(Wimp_UpdateWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 while (r0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434 swi(ColourTrans_SetGCOL, colour << 8, 0, 0, 0, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 swi(OS_Plot, 4, x + block[1], y + block[4] - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 draw_hollow(gui.char_width, gui.char_height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 swi(Wimp_GetRectangle, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1442 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1443 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444 swi(ColourTrans_SetGCOL, colour << 8, 0, 0, 0, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446 swi(OS_Plot, 4, x + redraw_block[1], y + redraw_block[4] - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 draw_hollow(gui.char_width, gui.char_height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1452 * Draw part of a cursor, "w" pixels wide, and "h" pixels high, using
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453 * color "color".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1456 gui_mch_draw_part_cursor(w, h, colour)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457 int w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 int h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 guicolor_T colour;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 int x = FILL_X(gui.cursor_col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462 int y = -FILL_Y(gui.cursor_row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 swi(ColourTrans_ReturnGCOL, colour << 8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 plot_rectangle(96 + 5, r0, x, y - h, x + w - 1, y - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 * Catch up with any queued events. This may put keyboard input into the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 * input buffer, call resize call-backs, trigger timers etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 * If there is nothing in the event queue(& no timers pending), then we return
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471 * immediately (well, after a Wimp_Poll).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 gui_mch_update(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 int block[64];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 int reason;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 swi(OS_ReadMonotonicTime);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 if ((r0 - time_of_last_poll) < 50)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481 return; /* Don't return too often */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 reason = wimp_poll(0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484 if (reason)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 process_event(reason, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 ro_return_early = FALSE; /* We're returning anyway. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 redraw_window(block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491 int *block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493 int x, y; /* Vim workarea coords */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 int width, height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 int blank_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 swi(ColourTrans_ReturnGCOL, UNUSED_COLOUR << 8, 0, 0, 1<<7, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498 blank_col = r0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 swi(Wimp_RedrawWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1501 redraw_block = block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502 while (r0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 x = block[7] - block[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 y = block[4] - block[10];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 width = block[9] - block[7];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 height = block[10] - block[8];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 if (height + y > Rows * gui.char_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511 /* Blank everything off the bottom. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 plot_rectangle(96 + 5, blank_col,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 0, block[8] - block[4],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 block[9] - block[1], -FILL_Y(Rows) - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515 height = Rows * gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 if (width + x> Columns * gui.char_width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519 /* Blank everything off to the right. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520 plot_rectangle(96 + 5, blank_col,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 FILL_X(Columns), block[8] - block[4],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 block[9] - block[1], 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 width = Columns * gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 gui_redraw(x , y, width, height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 swi(Wimp_GetRectangle, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 redraw_block = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 /* Check if we have modified data.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 * If we do then ack the message to stop the shutdown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533 * Otherwise, ignore the message.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 ro_prequit(block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 int *block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539 if (!ro_ok_to_quit())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 /* Not OK to quit - stop shutdown */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 block[3] = block[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 swi(Wimp_SendMessage, 19, block, block[1]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1545 /* Do nothing. We may get a Message_Quit later. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1548 /* If there is unsaved data then ask the user if they mind losing it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1549 * Return TRUE if we can quit without saving, FALSE to halt the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1550 * shutdown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 ro_ok_to_quit()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 int old_confirm = cmdmod.confirm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557 cmdmod.confirm = FALSE; /* Use our own, single tasking, box */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1558
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1559 if (check_changed_any(FALSE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1560 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1561 swi(Wimp_ReportError,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1562 "\0\0\0\0Vim contains unsaved data - quit anyway?",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1563 0x17,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1564 "Vim");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565 cmdmod.confirm = old_confirm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1566 if (r1 != 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1567 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569 cmdmod.confirm = old_confirm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1571 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1573 /* Quit without checking for unsaved data. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1574 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1575 ro_quit()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1576 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577 exiting = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578 getout(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1579
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1580 exiting = FALSE; /* probably can't get here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1581 setcursor(); /* position cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1582 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1583 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1584
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1585 /* Insent the given vim special code into the input buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1586 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1587 ro_press(a, b, modifier)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1588 char a;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1589 char b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1590 int modifier; /* %<Ctrl><Shift> 0000 0000 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1591 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1592 char_u buf[6];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1593 int vim_mod;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1594 int key;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1595
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1596
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1597 /* Convert RISC OS modifier to Vim modifier. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1598 vim_mod = ((modifier & 0x10) ? MOD_MASK_SHIFT : 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1599 | ((modifier & 0x20) ? MOD_MASK_CTRL : 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1600 key = simplify_key(TERMCAP2KEY(a, b), &vim_mod);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1601
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1602 buf[3] = CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1603 buf[4] = KEY2TERMCAP0(key);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1604 buf[5] = KEY2TERMCAP1(key);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1605 if (vim_mod)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1606 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1607 buf[0] = CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1608 buf[1] = KS_MODIFIER;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1609 buf[2] = vim_mod;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1610 add_to_input_buf(buf, 6);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1611 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1612 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1613 add_to_input_buf(buf + 3, 3);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1614 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1615
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1616 /* Take a wimp key code and insert the vim equivalent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1617 * into vim's input buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1618 * CTRL-C also sets got_int.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1619 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1620 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1621 ro_insert_key(code)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1622 char_u *code; /* Wimp_ProcessKey code (4 bytes) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1623 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1624 char a = code[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1625 char b = code[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1626 int base, modifier;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1627
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1628 if (a == 3 && ctrl_c_interrupts)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1629 got_int = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1630
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1631 /* Is it a normal key? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1632 if (a > 31 && a < 127)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1633 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1634 add_to_input_buf(code, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1635 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1636 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1637
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1638 /* We should pass any unrecognised keys on, but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1639 * for now just pass on F12 combinations.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1640 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1641 switch (b)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1642 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1643 case 0:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1644 /* Home and Delete are the only special cases */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1645 switch (a)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1646 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1647 case 0x1e:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1648 ro_press('k','h', 0); /* Home */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1649 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1650 case 0x7f:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1651 ro_press('k','D', 0); /* Delete */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1652 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1653 case CSI:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1654 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1655 /* Turn CSI into K_CSI. Untested! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1656 char_u string[3] = {CSI, KS_EXTRA, KE_CSI};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1657
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1658 add_to_input_buf(string, 3);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1659 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1660 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1661 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1662 add_to_input_buf(code, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1663 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1664 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1665 case 1:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1666 if ((a & 0xcf) == 0xcc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1667 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1668 /* F12 pressed - pass it on (quick hack) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1669 swi(Wimp_ProcessKey, a | 0x100);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1670 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1671 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1672 base = a & 0xcf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1673 modifier = a & 0x30;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 switch (base)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1675 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1676 case 0x8a: /* Tab */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1677 add_to_input_buf("\011", 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1678 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679 case 0x8b: /* Copy (End) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 return ro_press('@', '7', modifier);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681 case 0x8c: /* Left */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1682 return ro_press('k', 'l', modifier);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1683 case 0x8d: /* Right */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1684 return ro_press('k', 'r', modifier);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1685 case 0x8e: /* Down */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1686 if (modifier & 0x10)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1687 return ro_press('k', 'N', modifier ^ 0x10);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1688 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1689 return ro_press('k', 'd', modifier);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1690 case 0x8f: /* Up */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1691 if (modifier & 0x10)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1692 return ro_press('k', 'P', modifier ^ 0x10);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1693 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1694 return ro_press('k', 'u', modifier);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1695 case 0xca: /* F10 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696 return ro_press('k', ';', modifier);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 case 0xcb: /* F11 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1698 return ro_press('F', '1', modifier);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1699 case 0xcd: /* Insert */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1700 return ro_press('k', 'I', modifier);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 if (base > 0x80 && base < 0x18a)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1703 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1704 /* One of the other function keys */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1705 return ro_press('k', '0' + (base & 15), modifier);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1706 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1707 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1708 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1709 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1710
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1711 /* Process a mouse event. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1712 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1713 ro_mouse(block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1714 int *block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1715 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1716 int x, y, button, vim_button;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1717 int modifiers = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1718 int min_x, min_y; /* Visible area of editor window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1719 int max_x, max_y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1720
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1721 if (block[3] != gui.window_handle || ro_dragging)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1722 return; /* Not our window or ignoring clicks*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1723
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1724 x = block[0]; /* Click position - screen coords */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1725 y = block[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1726 button = block[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1727
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1728 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1729 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1730 min_x = block[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1731 min_y = block[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1732 max_x = block[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1733 max_y = block[4];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1734
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1735 if (block[3] - x < gui.scrollbar_width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1736 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1737 /* Click in that blank area under the scrollbars */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1738
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1739 if (button & 0x444)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1740 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1741 int front_block[10];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1742 /* Dragging with Select - bring window to front first */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743 front_block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1744 swi(Wimp_GetWindowState, 0, front_block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1745 front_block[7] = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746 ro_open_main(front_block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1747 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1749 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1750 block[1] = 7; /* Drag point */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1751 block[2] = block[4] = 0; /* Coords of point. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1752 block[3] = block[5] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1753 drag_x_offset = max_x - x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 drag_y_offset = min_y - y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756 /* Parent box. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 block[6] = min_x +
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 gui.scrollbar_width * 2 +
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 MIN_COLUMNS * gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760 block[7] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761 gui_mch_get_screen_dimensions(&block[8], &block[9]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1762 block[9] = max_y -
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1763 4 * gui.char_height -
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 gui.scrollbar_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1765
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 swi(Wimp_DragBox, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 ro_dragging = DRAG_RESIZE_WINDOW;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 drag_button = vim_button;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769 drag_modifiers = modifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773 if (button & 0x111)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774 vim_button = MOUSE_RIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 else if (button & 0x222)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776 vim_button = MOUSE_MIDDLE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1778 vim_button = MOUSE_LEFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1780 swi(OS_Byte, 121, 0x80);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1781 if (r1 == 0xff)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 modifiers |= MOUSE_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 swi(OS_Byte, 121, 0x81);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 if (r1 == 0xff)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 modifiers |= MOUSE_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 swi(OS_Byte, 121, 0x82);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787 if (r1 == 0xff)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 modifiers |= MOUSE_ALT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1790 if (button == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792 /* Menu click:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793 * If shift was pressed then do the paste action.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794 * If not, then open the pop-up menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796 modifiers ^= MOUSE_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797 if (modifiers && MOUSE_SHIFT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 vimmenu_T main;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1800 /* Shift was NOT pressed - show menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801 main.dname = (char_u *) "Vim";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 main.children = root_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1803 gui_mch_show_popupmenu(&main);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1805 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1808 /* Gain the input focus */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1809 swi(Wimp_SetCaretPosition, gui.window_handle, -1, 0, 0, -1, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1810
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1811 if (button & 0xf0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1812 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1813 /* Drag operation:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1814 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1815 * Tell the Wimp to start a drag.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1816 * Monitor null events.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1817 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818 block[1] = 7; /* Drag a point. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1819 block[2] = block[4] = x; /* Coords of point. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1820 block[3] = block[5] = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1821 block[6] = 0; /* Coords of bounding box. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1822 block[7] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1823 gui_mch_get_screen_dimensions(&block[8], &block[9]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1824
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1825 drag_x_offset = drag_y_offset = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827 swi(Wimp_DragBox, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1828 ro_dragging = DRAG_SELECTION;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1829 drag_button = vim_button;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1830 drag_modifiers = modifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1831
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1832 vim_button |= MOUSE_DRAG;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1833 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1834
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1835 gui_send_mouse_event(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1836 vim_button,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1837 x - min_x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1838 max_y - y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1839 button & 0xf ? TRUE : FALSE, /* dclick */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1840 modifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1841 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1842
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1843 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1844 ro_continue_drag(block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1845 int *block; /* Just used as scrap. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1846 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1847 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1848
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1849 /* Get screen coords of pointer. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1850 swi(Wimp_GetPointerInfo, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1851 x = block[0] + drag_x_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1852 y = block[1] + drag_y_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1854 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1855 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1856
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857 if (ro_dragging == DRAG_RESIZE_WINDOW)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1859 /* Resizeing the main window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860 block[2] = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1861 block[3] = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1862 ro_open_main(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1864 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1865 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1866 /* Selecting some text. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1867 gui_send_mouse_event(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1868 drag_button | MOUSE_DRAG, /* Always report the same button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1869 x - block[1],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 block[4] - y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1871 FALSE, /* Not a double click. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1872 drag_modifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1873 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1874 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1875
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1876 /* User has released all mouse buttons, marking the end of a drag. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1877 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1878 ro_drag_finished(block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1879 int *block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1880 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1881 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1882 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1883 int width, height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1884
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1885 /* I don't trust the box returned by Wimp_Poll; look at the pointer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1886 * ourselves.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1887 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1888 swi(Wimp_GetPointerInfo, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1889 x = block[0] + drag_x_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1890 y = block[1] + drag_y_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1891
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892 if (ro_dragging == DRAG_RESIZE_WINDOW)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1893 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1894 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1895 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1896 block[2] = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1897 block[3] = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898 ro_open_main(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1900 width = (block[3] - block[1]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 height = (block[4] - block[2]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903 swi(Wimp_ForceRedraw, gui.window_handle, 0, -height, width, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1904 gui_resize_shell(width, height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 gui_send_mouse_event(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 MOUSE_RELEASE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912 x - block[1],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 block[4] - y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 FALSE, /* not a double click */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915 drag_modifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1917 ro_dragging = DRAG_FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1919
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1920 /* Load the file/pathname given in block into a [new] buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1921 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1922 * Modifier Action
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1923 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1924 * None :confirm e <file>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1925 * Ctrl :sp <file>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1926 * Shift <file>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1927 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928 * Insert into typebuf, at the start.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929 * If loading from !Scrap then use saved leafname instead, and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1930 * delete the scrap file. Also, ignore shift key.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1931 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1932 * NB: Doesn't send DataLoadAck (other app might delete temp file?).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1933 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1934 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1935 ro_dataload(block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1936 int *block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1937 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1938 char_u new_path[MAXPATHL];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1939 char_u *path = ((char_u *) block) + 44;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1940 int scrap = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1941
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942 if (block[3] == leaf_ref && leaf_name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943 scrap = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1944
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1945 switch (get_real_state() & 0xff)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1947 case INSERT:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948 case CMDLINE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 case CMDLINE+LANGMAP:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1950 /* For insert mode we can only insert the pathname (currently)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1951 * Make sure Shift is pressed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1952 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1953 swi(OS_Byte, 121, 0x80); /* Is Shift pressed? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1954 if (r1 == 0xff)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1955 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1956 ins_typebuf(" ", REMAP_NONE, 0, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1957 ins_typebuf(path, REMAP_NONE, 0, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1958 ro_return_early = TRUE; /* Return even though nothing was typed. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1959 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1960 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1961 swi(Wimp_ReportError,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1962 "\0\0\0\0Sorry, you can only load text in normal mode", 5, "Vim");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1963 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1964
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1965 case NORMAL:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1966 ro_return_early = TRUE; /* Return even though nothing was typed. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1967
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1968 if (scrap) /* Remove <Wimp$Scrap>. Later. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1969 ins_typebuf(":!~remove <Wimp$Scrap>\r", REMAP_NONE, 0, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1970
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1971 /* Insert {:sp ,:confirm e }[+f\ <leaf> ]<file><CR> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1972 ins_typebuf("\r", REMAP_NONE, 0, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1973 ins_typebuf(path, REMAP_NONE, 0, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1974 ins_typebuf(" ", REMAP_NONE, 0, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1975
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1976 if (scrap)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1977 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1978 /* Loading via !Scrap - change pathname to stored leafname */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1979 ins_typebuf(leaf_name, REMAP_NONE, 0, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1980 ins_typebuf(" +f\\ ", REMAP_NONE, 0, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1981 leaf_ref = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1982 vim_free(leaf_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1983 leaf_name = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1984 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1985
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1986 swi(OS_Byte, 121, 0x81); /* Is Ctrl pressed? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1987 if (r1 == 0xff)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1988 /* Yes, split window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1989 ins_typebuf(":sp", REMAP_NONE, 0, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1990 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 ins_typebuf(":confirm e", REMAP_NONE, 0, TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1993
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1994 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1995 swi(Wimp_ReportError, "\0\0\0\0You can only load text in normal mode.", 5, "Vim");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 /* Send DataSaveAck so other program doesn't think we died
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998 * and delete <Wimp$Scrap>.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1999 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000 block[3] = block[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2001 block[4] = 4;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 swi(Wimp_SendMessage, 17, block, block[1]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2003 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2004
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2006 ro_datasave(block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2007 int *block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2008 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2009 char_u *path = ((char_u *) block) + 44;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2010
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011 /* Preserve the name given so we can use it, not <Wimp$Scrap> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2012 if (leaf_name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2013 vim_free(leaf_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2014 leaf_name = vim_strsave(path);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2015
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2016 block[9] = -1; /* File is unsafe. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2017 strcpy(path, "<Wimp$Scrap>");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2018 block[0] = 60;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2019 block[3] = block[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2020 block[4] = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2021 swi(Wimp_SendMessage, 17, block, block[1]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2022
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2023 leaf_ref = block[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2024 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2025
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2026 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027 ro_message(block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2028 int *block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2029 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2030 char_u *buffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2031 long_u len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2032
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 if (block[1] == task_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2034 return; /* Don't talk to ourself! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2035 switch (block[4])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2036 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2037 case 0: /* Quit. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2038 if (block[4] == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2039 ro_quit();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2040 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2041 case 1: /* DataSave */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2042 ro_datasave(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2043 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2044 case 2: /* DataSaveAck. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2045 if (clip_convert_selection(&buffer, &len, &clip_star) == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2046 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2047
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2048 /* Save the clipboard contents to a file. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2049 swi(OS_File, 10, ((char_u *) block) + 44, 0xfff, 0, buffer, buffer + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2050
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2051 /* Ack with DataLoad message. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2052 block[3] = block[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2053 block[4] = 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2054 block[9] = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2055 swi(Wimp_SendMessage, 17, block, block[1]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2056
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2057 vim_free(buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2058 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 case 3: /* DataLoad */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060 ro_dataload(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2061 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 case 8: /* PreQuit */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063 ro_prequit(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2065 case 0xf: /* Lose clipboard. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2066 if (block[5] & 4)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2067 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2068 clip_free_selection(&clip_star);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2069 clip_star.owned = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2070 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2071 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2072 case 0x10: /* DataRequest (clip_star) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2073 if (clip_star.owned)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2074 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2075 int rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2076
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2077 /* Tell other program that we have the clipboard. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2078 block[0] = 52;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079 block[3] = block[2]; /* Copy myref to yourref. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2080 block[4] = 1; /* DataSave message. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2081 /* Create an estimate for the size (larger or same as true
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2082 * value) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2083 rows = clip_star.end.lnum - clip_star.start.lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2084 if (rows < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2085 rows = -rows;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2086 block[9] = (rows + 1) * Columns + 1; /* Add one for possible
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2087 final newline. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2088 block[10] = 0xfff; /* Clipboard is text. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2089 strcpy( ((char_u *) block) + 44, "VimClip");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2090 swi(Wimp_SendMessage, 17, block, block[1]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2091 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2092 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2093 case 0x400c1: /* Mode change */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2094 changed_mode = TRUE; /* Flag - update on next OpenWindow */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2095 if (zap_redraw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2096 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2097 /* JK230798, re-initialise ZapRedraw stuff */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2098 if (ro_zap_redraw_initialise() == FAIL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2099 zap_redraw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2100 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2101 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2102 case 0x400c3: /* TaskCloseDown */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2103 if (block[1] == child_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2104 child_handle = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2105 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2106 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2107 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2109 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2110 * Converts a scrollbar's window handle into a scrollbar pointer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2111 * NULL on failure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2112 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2113 scrollbar_T *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2114 ro_find_sbar(id)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2115 int id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2116 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2117 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2119 if (gui.bottom_sbar.id == id)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2120 return &gui.bottom_sbar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2121 FOR_ALL_WINDOWS(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2122 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2123 if (wp->w_scrollbars[SBAR_LEFT].id == id)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2124 return &wp->w_scrollbars[SBAR_LEFT];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2125 if (wp->w_scrollbars[SBAR_RIGHT].id == id)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2126 return &wp->w_scrollbars[SBAR_RIGHT];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2127 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2128 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2129 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2130
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2131 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2132 scroll_to(line, sb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2133 int sb; /* Scrollbar number */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2134 int line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2135 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2136 char_u code[8];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2137
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2138 /* Don't put events in the input queue now. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2139 if (hold_gui_events)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2140 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2142 /* Send a scroll event:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2143 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2144 * A scrollbar event is CSI (NOT K_SPECIAL), KS_VER_SCROLLBAR,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2145 * KE_FILLER followed by:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2146 * one byte representing the scrollbar number, and then four bytes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2147 * representing a long_u which is the new value of the scrollbar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2148 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2149 code[0] = CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2150 code[1] = KS_VER_SCROLLBAR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2151 code[2] = KE_FILLER;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2152 code[3] = sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2153 code[4] = line >> 24;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2154 code[5] = line >> 16;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2155 code[6] = line >> 8;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2156 code[7] = line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2157 add_to_input_buf(code, 8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2158 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2159
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2160 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2161 h_scroll_to(col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2162 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2163 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2164 char_u code[8];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2165
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2166 /* Don't put events in the input queue now. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2167 if (hold_gui_events)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2168 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2169
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2170 /* Send a scroll event:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2171 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2172 * A scrollbar event is CSI (NOT K_SPECIAL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2173 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2174 * A horizontal scrollbar event is K_SPECIAL, KS_HOR_SCROLLBAR,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2175 * KE_FILLER followed by four bytes representing a long_u which is the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2176 * new value of the scrollbar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2177 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2178 code[0] = CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2179 code[1] = KS_HOR_SCROLLBAR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2180 code[2] = KE_FILLER;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2181 code[4] = col >> 24;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2182 code[5] = col >> 16;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2183 code[6] = col >> 8;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2184 code[7] = col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2185 add_to_input_buf(code, 8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2186 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2187
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2188 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2189 ro_scroll(block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2190 int *block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2191 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2192 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2193 int offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2194 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2196 /* Block is ready for Wimp_OpenWindow, and also contains:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2197 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2198 * +32 = scroll X direction (-2 .. +2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2199 * +36 = scroll Y direction (-2 .. +2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2200 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2201
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2202 sb = ro_find_sbar(block[0]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2203 if (!sb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2204 return; /* Window not found (error). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2206 wp = sb-> wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2207
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2208 if (wp == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2209 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2210 /* Horizontal bar. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2211 offset = block[8];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2212 if (offset == -2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2213 offset = (block[1] - block[3]) / gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2214 else if (offset == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2215 offset = (block[3] - block[1]) / gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2217 block[5] += offset * gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2219 gui_drag_scrollbar(sb, block[5] / gui.char_width, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2220
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2221 swi(Wimp_OpenWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2222 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2223 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2224 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2225 offset = -block[9];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2226 if (offset == -2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2227 offset = -(wp -> w_height - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2228 else if (offset == 2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2229 offset = wp -> w_height - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2230
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2231 /* Possibly we should reposition the scrollbar?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2232 * Vim seems to update the bar anyway...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2233 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2234 gui_drag_scrollbar(sb, offset - (block[6] / gui.char_height), FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2235 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2236 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2237
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2238 /* Move a window by a given offset. Used to simulate the function of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2239 * nested wimp.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2240 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2241 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2242 ro_move_child(window, x, y, pos_wanted, pos_got)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2243 int window;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2244 int x,y; /* offset to move by */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2245 int pos_wanted, pos_got;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2246 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2247 int block[10];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2248
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2249 block[0] = window;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2250 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2251 block[1] += x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2252 block[2] += y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2253 block[3] += x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2254 block[4] += y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2255 if (pos_wanted == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2256 block[7] = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2257 else if (pos_wanted == -2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2258 block[7] = pos_got;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2259 swi(Wimp_OpenWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2260 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2261
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2262 /* Open the main window. Also updates scrollbars if we are not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2263 * using the nested Wimp.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2264 * If we have just changed mode then re-read all values.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2265 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2266 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2267 ro_open_main(block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2268 int *block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2269 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2270 int toggle_size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2271
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2272 /* Find out if the user clicked on the toggle size icon. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2273 block[20] = block[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2274 swi(Wimp_GetWindowState, 0, block + 20);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2275 toggle_size = block[28] & (1 << 19);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2276
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2277 if (nested_wimp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2278 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2279 swi(Wimp_OpenWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2280 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2281 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2282 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2283 int old[10];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2284 int x_offset, y_offset; /* Move children same as parent. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2285 int pos_wanted, pos_got;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2286 int left_bar = gui.which_scrollbars[SBAR_LEFT];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2287 int right_bar = gui.which_scrollbars[SBAR_RIGHT];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2288 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2289
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2290 /* Three cases to think about:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2291 * 1) Move to top. Open each window at the top.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2292 * 2) Same stack position. Open each with same position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2293 * 3) Open at bottom. Open children with parent's new position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2294 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2296 old[0] = block[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2297 swi(Wimp_GetWindowState, 0, old);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2298 pos_wanted = block[7];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2299 swi(Wimp_OpenWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2300 /* Block updated by OpenWindow? I don't think so! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2301 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2302 pos_got = block[7];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2303
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2304 x_offset = block[1] - old[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2305 y_offset = block[4] - old[4];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2306 if (x_offset || y_offset || pos_wanted == -1 || pos_wanted == -2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2307 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2308 /* If parent has moved, re-open all the child windows. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2309 FOR_ALL_WINDOWS(wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2310 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2311 /* Reopen scrollbars for this window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2312 if (left_bar)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2313 ro_move_child(wp -> w_scrollbars[SBAR_LEFT].id,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2314 x_offset, y_offset,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2315 pos_wanted, pos_got);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2316 if (right_bar)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2317 ro_move_child(wp -> w_scrollbars[SBAR_RIGHT].id,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2318 x_offset, y_offset,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2319 pos_wanted, pos_got);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2320 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2321 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2322 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2323 if (changed_mode || toggle_size)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2324 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2325 int width, height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2326
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2327 if (changed_mode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2328 ro_measure_tools();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2329 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2330 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2331
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2332 width = block[3] - block[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2333 height = block[4] - block[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2334 swi(Wimp_ForceRedraw, gui.window_handle, 0, -height, width, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2335 gui_resize_shell(width, height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2336 changed_mode = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2337 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2338 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2339
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2340 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2341 ro_open_window(block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2342 int *block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2343 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2344 int pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2345 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2346
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2347 if (block[0] == gui.window_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2348 ro_open_main(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2349 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2350 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2351 swi(Wimp_OpenWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2352 if (block[0] != gui.window_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2353 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2354 sb = ro_find_sbar(block[0]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2355 if (sb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2356 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2357 if (sb-> wp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2358 gui_drag_scrollbar(sb, -block[6] / gui.char_height, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2359 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2360 gui_drag_scrollbar(sb, block[5] / gui.char_width, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2361 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2362 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2363 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2364 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2365
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2366 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2367 ro_menu_selection(block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2368 int *block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2369 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2370 int *item = wimp_menu + 7;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2371 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2372 /* wimp_menu points to a wimp menu structure */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2373
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2374 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2375 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2376 while (block[0]--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2377 item += 6;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2378 if (block[1] == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2379 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2380 item = ((int *) item[1]) + 7;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2381 block++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2382 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2383 /* item points to the wimp menu item structure chosen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2384 menu = (vimmenu_T *) item[5];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2385
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2386 swi(Wimp_GetPointerInfo, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2387 if (block[2] == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2388 /* Adjust used - keep menu open */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2389 swi(Wimp_CreateMenu, 0, wimp_menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2390
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2391 if (menu-> cb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2392 menu-> cb(menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2393 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2395 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2396 ro_open_parent()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2397 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2398 int head;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2399 char_u *i = curbuf-> b_ffname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2400 char_u buffer[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2401
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2402 head = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2403 for (; *i; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2404 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2405 if (*i == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2406 head = i - curbuf-> b_ffname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2408
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2409 /* Append head chars to buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2410 if (head < 240 && curbuf-> b_ffname && head)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2411 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2412 strcpy(buffer, "%filer_opendir ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2413 strncpy(buffer + 15, curbuf-> b_ffname, head);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2414 buffer[15 + head] = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2415 swi(OS_CLI, buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2416 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2417 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2418
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2419 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2420 process_event(event, block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2421 int event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2422 int *block;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2423 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2424 switch (event)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2425 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2426 case 0: /* Nothing - update drag state. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2427 if (ro_dragging)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2428 ro_continue_drag(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2429 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2430 case 1: /* Redraw window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2431 redraw_window(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2432 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2433 case 2: /* Open window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2434 ro_open_window(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2435 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2436 case 3: /* Close window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2437 swi(Wimp_GetPointerInfo, 0, block + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2438 if (block[3] == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2439 ro_open_parent();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2440 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2441 if (ro_ok_to_quit())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2442 ro_quit();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2443 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2444 case 6: /* Mouse click. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2445 ro_mouse(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2446 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2447 case 7: /* Finished drag. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2448 ro_drag_finished(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2449 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2450 case 8: /* Key pressed. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2451 ro_insert_key((char_u *) &block[6]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2452 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2453 case 9:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2454 ro_menu_selection(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2455 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2456 case 10: /* Scroll request. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2457 ro_scroll(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2458 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2459 case 11: /* Lose caret. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2460 if (block[0] == gui.window_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2461 gui_focus_change(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2462 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2463 case 12: /* Gain caret. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2464 if (block[0] == gui.window_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2465 gui_focus_change(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2466 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2467 case 17: /* User message. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2468 case 18: /* User message recorded. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2469 ro_message(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2470 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2471 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2472 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2473
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2474 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2475 * GUI input routine called by gui_wait_for_chars(). Waits for a character
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2476 * from the keyboard.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2477 * wtime == -1 Wait forever.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2478 * wtime == 0 This should never happen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2479 * wtime > 0 Wait wtime milliseconds for a character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2480 * Returns OK if a character was found to be available within the given time,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2481 * or FAIL otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2482 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2483 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2484 gui_mch_wait_for_chars(long wtime)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2485 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2486 int block[64];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2487 int reason;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2488 int start_time = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2489 int ctime = wtime / 10; /* delay in cs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2490
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2491 if (wtime != -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2492 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2493 swi(OS_ReadMonotonicTime);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2494 start_time = r0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2495 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2497 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2498 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2499 if (ro_dragging)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2500 reason = wimp_poll(0, block); /* Always return immediately */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2501 else if (wtime == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2502 reason = wimp_poll(1, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2503 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2504 reason = wimp_pollidle(0, block, start_time + ctime);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2505
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2506 process_event(reason, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2507
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2508 if (input_available() || ro_return_early)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2509 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2510 ro_return_early = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2511 return OK; /* There is something to process (key / menu event) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2512 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2513
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2514 if (wtime != -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2515 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2516 swi(OS_ReadMonotonicTime);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2517 if (r0 - start_time > ctime)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2518 return FAIL; /* We've been waiting too long - return failure */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2519 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2520 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2521 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2522
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2523 /* Flush any output to the screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2524 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2525 gui_mch_flush(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2526 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2527 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2530 * Clear a rectangular region of the screen from text pos(row1, col1) to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2531 * (row2, col2) inclusive.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2532 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534 gui_mch_clear_block(int row1, int col1, int row2, int col2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2535 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2536 swi(ColourTrans_ReturnGCOL, gui.back_pixel << 8, 0, 0, 1<<7, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2537 plot_rectangle(96 + 5, r0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2538 FILL_X(col1), -FILL_Y(row2 + 1),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2539 FILL_X(col2 + 1), -FILL_Y(row1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2540 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2541
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2542 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2543 gui_mch_clear_all(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2544 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2545 if (redraw_block)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2546 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2547 swi(ColourTrans_SetGCOL, gui.back_pixel << 8, 0, 0, 1<<7, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2548 swi(OS_WriteI + 16);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2549 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2550 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2551 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2552 int block[44];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2553 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2554 block[1] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2555 block[2] = -gui.num_rows * gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2556 block[3] = gui.num_cols * gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2557 block[4] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2558 swi(Wimp_UpdateWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 while (r0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2560 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2561 swi(ColourTrans_SetGCOL, gui.back_pixel << 8, 0, 0, 1<<7, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562 swi(OS_WriteI + 16);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563 swi(Wimp_GetRectangle, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2564 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2566 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2567
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2568 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2569 * Delete the given number of lines from the given row, scrolling up any
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2570 * text further down within the scroll region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2571 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2572 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2573 gui_mch_delete_lines(int row, int num_lines)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2574 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2575 int top_from = -row - num_lines;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2576 int bot_from = -gui.scroll_region_bot - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2577 int bot_to = bot_from + num_lines;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2578
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2579 swi(ColourTrans_SetGCOL, gui.back_pixel << 8, 0, 0, 0x80, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2580
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 /* Changed without checking! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2582 swi(Wimp_BlockCopy, gui.window_handle,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2583 gui.scroll_region_left * gui.char_width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2584 bot_from * gui.char_height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2585 (gui.scroll_region_right - gui.scroll_region_left
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2586 + 1) * gui.char_width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2587 top_from * gui.char_height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2588
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2589 gui.scroll_region_left * gui.char_width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2590 bot_to * gui.char_height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2591
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2592 gui_clear_block(gui.scroll_region_bot - num_lines + 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2593 gui.scroll_region_left,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2594 gui.scroll_region_bot, gui.scroll_region_right);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2595 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2596
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2597 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2598 * Insert the given number of lines before the given row, scrolling down any
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2599 * following text within the scroll region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2600 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2601 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2602 gui_mch_insert_lines(int row, int num_lines)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2603 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2604 int top_from = -row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2605 int bot_to = -gui.scroll_region_bot - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2606 int bot_from = bot_to + num_lines;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2607
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2608 swi(ColourTrans_SetGCOL, gui.back_pixel << 8, 0, 0, 0x80, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2609
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2610 swi(Wimp_BlockCopy, gui.window_handle,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2611 gui.scroll_region_left * gui.char_width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612 bot_from * gui.char_height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2613 (gui.scroll_region_right - gui.scroll_region_left
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2614 + 1) * gui.char_width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2615 top_from * gui.char_height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2616
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2617 gui.scroll_region_left * gui.char_width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2618 bot_to * gui.char_height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2619
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2620 gui_clear_block(row, gui.scroll_region_left,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2621 row + num_lines - 1, gui.scroll_region_right);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2622 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2623
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2624 /* Put selection in clipboard buffer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2625 * Should we become the new owner?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2626 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2627 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2628 clip_mch_request_selection(VimClipboard *cbd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2629 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2630 int block[64]; /* Will be used in Wimp_Poll. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2631 int reason;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2632 char_u *buffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2633 long_u length;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2634
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2635 block[0] = 48; /* Size of block. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2636 block[3] = 0; /* Orinial message. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2637 block[4] = 0x10; /* Data request. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2638 block[5] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2639 block[6] = RO_LOAD_CLIPBOARD; /* Internal handle. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2640 block[7] = block[8] = 0; /* (x,y) not used. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2641 block[9] = 4;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2642 block[10] = 0xfff; /* We want text files if possible, I think. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2643 block[11] = -1; /* End of list. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2644 swi(Wimp_SendMessage, 17, block, 0); /* Broadcast request. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2645
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2646 /* OK, we've sent the request. Poll until we get a null poll (failure) or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2647 * we load the clipboard.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2648 * If we receive a DataSave event with icon handle = -2 then put it on the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2649 * clipboard. RISC OS should ensure that key events will not be delivered
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2650 * until the clipboard operation completes (unless the owner starts idling
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2651 * - we can't wait forever!).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2652 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2653 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2654 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2655 reason = wimp_poll(0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2656 if (reason == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2657 return; /* Failed to get clipboard. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2658 if ((reason == 17 || reason == 18) &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2659 block[4] == 1 && block[6] == RO_LOAD_CLIPBOARD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2660 break; /* Got it - stop waiting. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2661 process_event(reason, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2662 if (ro_return_early)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2663 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2664 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2665 /* Tell owner to save data in <Wimp$Scrap>. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2666 block[0] = 60;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2667 block[3] = block[2]; /* Copy myref -> yourref */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2668 block[4] = 2; /* DataSaveAck. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2669 block[9] = -1; /* Data is unsafe. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2670 strcpy( ((char_u *) block) + 44, "<Wimp$Scrap>");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2671 swi(Wimp_SendMessage, 17, block, block[1]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2672
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2673 /* Wait again for reply. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2674 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2675 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2676 reason = wimp_poll(0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2677 if (reason == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2678 return; /* Other program has given up! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2679 if ((reason == 17 || reason == 18) && block[4] == 3 && block[6] == RO_LOAD_CLIPBOARD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2680 break; /* Clipboard data saved to <Wimp$Scrap> */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2681 process_event(reason, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2682 if (ro_return_early)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2683 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2684 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2685
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2686 /* <Wimp$Scrap> contains clipboard - load it. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2687 if (xswi(OS_File, 17, "<Wimp$Scrap>") & v_flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2688 return; /* Error! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2689 if (r0 != 1 && r0 != 3)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2690 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2691 length = r4;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2692
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2693 buffer = lalloc(length, TRUE); /* Claim memory (and report errors). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2694 if (buffer == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2695 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2696
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2697 if (xswi(OS_File, 16, "<Wimp$Scrap>", buffer, 0) & v_flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2698 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2699
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2700 clip_yank_selection(MCHAR, buffer, length, cbd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2701
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2702 vim_free(buffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2703
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2704 swi(OS_FSControl, 27, "<Wimp$Scrap>", 0, 0); /* Delete temp file. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2705
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2706 block[4] = 4; /* Send DataLoadAck. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2707 block[3] = block[2]; /* Copy myref -> yourref. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2708 swi(Wimp_SendMessage, 17, block, block[1]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2709 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2710
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2711 /* Not sure what this means under RISC OS. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2712 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2713 clip_mch_lose_selection(VimClipboard *cbd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2714 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2715 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2716
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2717 /* Tell everyone that we now own the clipboard.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2718 * Return OK if our claim is accepted (always, under RISC OS)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2719 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2720 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2721 clip_mch_own_selection(VimClipboard *cbd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2722 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2723 int block[6];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2724 block[0] = 24; /* Length of block. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2725 block[3] = 0; /* Original message. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2726 block[4] = 0xf; /* ClaimEntity. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2727 block[5] = 0x4; /* Claim clipboard only. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2728 swi(Wimp_SendMessage, 17, block, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2729 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2730 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2731
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2732 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2733 * Send the current selection to the clipboard. Do nothing for X because we
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2734 * will fill in the selection only when requested by another app. Sounds good
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2735 * for RISC OS too.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2736 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2737 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2738 clip_mch_set_selection(VimClipboard *cbd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2739 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2740 clip_get_selection(cbd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2741 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2742
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2743 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2744 * Make a menu either grey or not grey.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2745 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2746 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2747 gui_mch_menu_grey(vimmenu_T *menu, int grey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2748 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2749 menu-> greyed_out = grey;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2750 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2751
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2752 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2753 * Make menu item hidden or not hidden
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2754 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2755 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2756 gui_mch_menu_hidden(vimmenu_T *menu, int hidden)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2757 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2758 menu-> hidden = hidden;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2759 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2760
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2761 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2762 * This is called after setting all the menus to grey/hidden or not.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2763 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2764 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2765 gui_mch_draw_menubar(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2766 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2767 swi(Wimp_CreateMenu, 0, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2768 if (wimp_menu != (int *) -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2769 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2770 ro_remove_menu(wimp_menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2771 wimp_menu = (int *) -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2772 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2773 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2774
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2775 /* Add or remove a scrollbar. Note that this is only called when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2776 * the scrollbar state is changing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2777 * The scroll bar window has already been created.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2778 * We can't do anything except remove the scroll bar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2779 * until we know what size to use.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2780 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2781 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2782 gui_mch_enable_scrollbar(sb, flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2783 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2784 int flag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2785 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2786 if (!flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2787 swi(Wimp_CloseWindow, 0, & (sb->id) );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2788 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2789 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2790
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2791 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2792 gui_mch_set_blinking(long waittime, long on, long off)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2793 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2794 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2795
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2796 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2797 * Stop the cursor blinking. Show the cursor if it wasn't shown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2798 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2799 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2800 gui_mch_stop_blink(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2801 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2802 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2803
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2804 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2805 * Start the cursor blinking. If it was already blinking, this restarts the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2806 * waiting time and shows the cursor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2807 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2808 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2809 gui_mch_start_blink(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2810 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2811 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2812
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2813 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2814 * Return the RGB value of a pixel as a long.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2815 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2816 long_u
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2817 gui_mch_get_rgb(guicolor_T pixel)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2818 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2819 return (long_u)pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2820 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2821
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2822 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2823 gui_mch_set_text_area_pos(int x, int y, int w, int h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2824 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2825 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2826
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2827 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2828 gui_mch_enable_menu(int flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2829 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2830 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2831
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2832 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2833 gui_mch_set_menu_pos(int x, int y, int w, int h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2834 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2835 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2836
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2837 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2838 gui_mch_add_menu(vimmenu_T *menu, int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2839 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2840 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2841
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2842 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2843 gui_mch_add_menu_item(vimmenu_T *menu, int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2844 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2845 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2846
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2847 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2848 gui_mch_new_menu_colors(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2849 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2850 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2851
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2852 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2853 gui_mch_destroy_menu(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2854 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2855 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2856
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2857 /* Size of buffer has changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2858 * Add one to max since gui.c substracts one more than it should!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2859 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2860 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2861 gui_mch_set_scrollbar_thumb(sb, val, size, max)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2862 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2863 long val;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2864 long size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2865 long max;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2866 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2867 int block[10], width, height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2868
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2869 width = (max + 1) * gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2870 height = (max + 1 + W_STATUS_HEIGHT(sb->wp)) * gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2871
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2872 block[0] = block[3] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2873 block[1] = -height + (1 << y_eigen_factor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2874 block[2] = width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2875
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2876 swi(Wimp_SetExtent, sb -> id, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2877
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2878 block[0] = sb -> id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2879 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2880 block[5] = val * gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2881 block[6] = -val * gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2882 swi(Wimp_OpenWindow, 0, block, 0x4b534154,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2883 gui.window_handle, /* Parent window handle. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2884 (CHILD_FIX_TO_RIGHT << CHILD_LEFT ) |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2885 (CHILD_FIX_TO_RIGHT << CHILD_RIGHT ) |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2886 (CHILD_FIX_TO_BOTTOM << CHILD_TOP ) |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2887 (CHILD_FIX_TO_BOTTOM << CHILD_BOTTOM) |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2888 (CHILD_SELF_SCROLL << CHILD_SCROLL_X) |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2889 (CHILD_SELF_SCROLL << CHILD_SCROLL_Y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2890 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2891 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2892
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2893 /* Set the position of the scrollbar within the editor
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2894 * window. Note that, for vertical scrollbars, x and w
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2895 * are ignored. For horizontal bars y and h are ignored.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2896 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2897 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2898 gui_mch_set_scrollbar_pos(sb, x, y, w, h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2899 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2900 int x; /* Horizontal sb position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2901 int y; /* Top of scroll bar */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2902 int w; /* Width */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2903 int h; /* Height */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2904 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2905 int block[24];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2906 int px1, py1; /* Parent window min coords */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2907 int px2, py2; /* Parent window max coords */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2908
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2909 /* Find where the parent window is. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2910 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2911 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2912 px1 = block[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2913 py1 = block[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2914 px2 = block[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2915 py2 = block[4];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2916
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2917 block[0] = sb -> id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2918
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2919 /* Find out how big the scroll window is at the moment. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2920 swi(Wimp_GetWindowInfo, 0, ((char_u *)block) + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2921
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2922 if (block[13] < w || block[12] > -h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2923 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2924 /* Current window is too small! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2925 if (block[12] > -h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2926 block[12] = -h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2927 if (block[13] < w)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2928 block[13] = w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2929 swi(Wimp_SetExtent, block[0], block + 11);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2930 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2931
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2932 /* This works better on the nested_wimp. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2933 if (sb-> wp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2934 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2935 /* This is a vertical scrollbar. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2936 block[1] = block[3] = px2 - gui.scrollbar_width + (1 << x_eigen_factor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2937 block[2] = 1 + py2 - (y + h) + (1 << y_eigen_factor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2938 block[4] = 1 + py2 - y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2939 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2940 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2941 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2942 /* This is a horizontal scrollbar. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2943 block[2] = block[4] = py1 + gui.scrollbar_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2944 block[1] = px1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2945 block[3] = px2 - gui.scrollbar_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2946 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2947
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2948 block[5] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2949 block[6] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2950 block[7] = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2951
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2952 swi(Wimp_OpenWindow, 0, block, 0x4b534154,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2953 gui.window_handle, /* Parent window handle. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2954 (CHILD_FIX_TO_RIGHT << CHILD_LEFT ) |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2955 (CHILD_FIX_TO_RIGHT << CHILD_RIGHT ) |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2956 (CHILD_FIX_TO_BOTTOM << CHILD_TOP ) |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2957 (CHILD_FIX_TO_BOTTOM << CHILD_BOTTOM) |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2958 (CHILD_SELF_SCROLL << CHILD_SCROLL_X) |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2959 (CHILD_SELF_SCROLL << CHILD_SCROLL_Y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2960 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2961 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2962
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2963 /* Create a window with no workarea to place inside editor window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2964 * (what happens without the nested wimp?)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2965 * Data for scrollbar is invalid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2966 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2967 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2968 gui_mch_create_scrollbar(sb, orient)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2969 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2970 int orient; /* orient is SBAR_HORIZ or SBAR_VERT */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2971 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2972 int bar[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2973 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2974 0, 0, /* Visible area : min X,Y */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2975 100, 100, /* max X,Y */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2976 0, 0, /* Scroll offsets */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2977 -1, /* Window in front */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2978 0x80800150 | (orient == SBAR_HORIZ ? (1 << 30) : (1 << 28)),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2979 0xff070207, /* Colours */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2980 0x000c0103, /* More colours */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2981 0, -0x4000, /* Workarea extent */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2982 0x4000, 0, /* max X,Y */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2983 0x00000000, /* No title */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2984 0 << 12, /* No workarea button type */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2985 1, /* Wimp sprite area */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2986 0x00010001, /* Minimum width, height */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2987 0, 0, 0, /* Title data (none) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2988 0 /* No icons */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2989 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2990 swi(Wimp_CreateWindow, 0, bar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2991 sb -> id = r0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2992 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2993
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2994 #if defined(FEAT_WINDOWS) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2995 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2996 gui_mch_destroy_scrollbar(scrollbar_T *sb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2997 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2998 swi(Wimp_DeleteWindow, 0, & (sb->id));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2999 sb -> id = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3000 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3001 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3002
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3003 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3004 gui_mch_set_scrollbar_colors(scrollbar_T *sb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3005 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3006 /* Always use default RO colour scheme. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3007 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3008
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3009 /*
87
014ba200db86 updated for version 7.0035
vimboss
parents: 63
diff changeset
3010 * Get current mouse coordinates in text window.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3011 * Note: (0,0) is the bottom left corner, positive y is UP.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3012 */
87
014ba200db86 updated for version 7.0035
vimboss
parents: 63
diff changeset
3013 void
014ba200db86 updated for version 7.0035
vimboss
parents: 63
diff changeset
3014 gui_mch_getmouse(x, y)
014ba200db86 updated for version 7.0035
vimboss
parents: 63
diff changeset
3015 int *x;
014ba200db86 updated for version 7.0035
vimboss
parents: 63
diff changeset
3016 int *y;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3017 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3018 int left;
87
014ba200db86 updated for version 7.0035
vimboss
parents: 63
diff changeset
3019 int top;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3020 int block[10];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3021
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3022 block[0] = gui.window_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3023 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3024 left = block[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3025 top = block[4];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3026
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3027 swi(Wimp_GetPointerInfo, 0, block);
87
014ba200db86 updated for version 7.0035
vimboss
parents: 63
diff changeset
3028 *x = block[0] - left;
014ba200db86 updated for version 7.0035
vimboss
parents: 63
diff changeset
3029 *y = top - block[1];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3030 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3031
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3032 /* MouseTo(x, y) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3033 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3034 gui_mch_setmouse(x, y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3035 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3036 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3037 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3038 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3039
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3040 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3041 gui_mch_toggle_tearoffs(enable)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3042 int enable;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3043 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3044 /* no tearoff menus */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3045 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3046
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3047 /* Redraw a window's title.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3048 * For the nested wimp we use the new 'redraw-title-bar' reason code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3049 * For older wimps we mark the area of the screen where the title bar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3050 * is as invalid.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3051 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3052 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3053 ro_redraw_title(window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3054 int window;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3055 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3056 if (nested_wimp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3057 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3058 swi(Wimp_ForceRedraw, window, 0x4b534154, 3);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3059 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3060 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3061 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3062 int block[10];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3063 int miny;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3064
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3065 block[0] = window;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3066 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3067 miny = block[4];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3068 swi(Wimp_GetWindowOutline, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3069 swi(Wimp_ForceRedraw, -1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3070 block[1], miny,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3071 block[3], block[4]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3072 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3073 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3074
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3075 /* Turn a vimmenu_T structure into a wimp menu structure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3076 * -1 if resulting menu is empty.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3077 * Only the children and dname items in the root menu are used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3078 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3079 int *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3080 ro_build_menu(menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3081 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3082 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3083 int *wimp_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3084 int width = 4;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3085 int w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3086 int size = 28;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3087 vimmenu_T *item;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3088 int *wimp_item;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3089
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3090 /* Find out how big the menu is so we can allocate memory for it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3091 for (item = menu-> children; item; item = item-> next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3092 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3093 if (item-> hidden == FALSE && !menu_is_separator(item->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3094 size += 24;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3095 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3096
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3097 if (size <= 28)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3098 return (int *) -1; /* No children - shouldn't happen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3099
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3100 wimp_menu = (int *) alloc(size);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3102 wimp_menu[0] = (int) menu-> dname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3103 wimp_menu[1] = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3104 wimp_menu[2] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3105 wimp_menu[3] = 0x00070207;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3106 wimp_menu[5] = 44;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3107 wimp_menu[6] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3109 wimp_item = wimp_menu + 7;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3111 for (item = menu-> children; item; item = item-> next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3112 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3113 if (menu_is_separator(item-> name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3114 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3115 /* This menu entry is actually a separator. If it is not the first
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3116 * menu entry then mark the previous menu item as needing a dotted
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3117 * line after it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3118 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3119 if (wimp_item > wimp_menu + 7)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3120 wimp_item[-6] |= 0x2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3121 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3122 else if (item-> hidden == FALSE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3123 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3124 wimp_item[0] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3125 wimp_item[1] = item-> children ? (int) ro_build_menu(item) : -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3126 wimp_item[2] = 0x07009131 | (item-> greyed_out << 22);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3127 wimp_item[3] = (int) item-> dname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3128 wimp_item[4] = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3129 wimp_item[5] = (int) item; /* Stuff the menu address in this unused space */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3130
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3131 w = strlen(item-> dname) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3132 if (w > width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3133 width = w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3134 wimp_item += 6;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3135 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3136 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3137
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3138 wimp_menu[4] = (width + 2) * 16;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3139 wimp_menu[7] |= 0x100; /* Menu title is indirected */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3140 wimp_item[-6] |= 0x080; /* Last entry in menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3141 return wimp_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3142 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3144 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3145 ro_remove_menu(menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3146 int *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3147 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3148 int *item = menu + 7;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3150 if (menu == NULL || menu == (int *) -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3151 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3152
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3153 for (;;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3154 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3155 if (item[1] != -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3156 ro_remove_menu((int *) item[1]); /* Remove sub-menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3157 if (item[0] & 0x80)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3158 break; /* This was the last entry */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3159 item += 6;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3160 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3161 vim_free(menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3162 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3163
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3164 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3165 gui_mch_show_popupmenu(menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3166 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3167 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3168 int block[10];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3169
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3170 /* Remove the existing menu, if any */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3171 if (wimp_menu != (int *) -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3172 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3173 swi(Wimp_CreateMenu, 0, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3174 ro_remove_menu(wimp_menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3175 wimp_menu = (int *) -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3178 wimp_menu = ro_build_menu(menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3179 if (wimp_menu != (int *) -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3180 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3181 swi(Wimp_GetPointerInfo, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3182 swi(Wimp_CreateMenu, 0, wimp_menu, block[0] - 64, block[1] + 64);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3183 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3184 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3186 /* Run a command using the TaskWindow module.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3187 * If SHELL_FILTER is set then output is not echoed to the screen,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3188 * If it is not set, then \r is not sent to the output file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3189 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3190 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3191 gui_mch_call_shell(cmd, options)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3192 char_u *cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3193 int options; /* SHELL_FILTER if called by do_filter() */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3194 /* SHELL_COOKED if term needs cooked mode */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3195 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3196 char_u task_cmd[256]; /* Contains *TaskWindow command. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3197 int block[64];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3198 int reason;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3199 char_u *out;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3200 char_u c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3201 int old_msg_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3202 char_u *out_redir;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3203 int length;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3204 FILE *out_file = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3206 out_redir = strstr(cmd, " > ");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3207 if (out_redir == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3208 length = strlen(cmd); /* No redirection. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3209 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3210 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3211 length = out_redir - cmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3212 out_file = fopen(out_redir + 3, "wb");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3213 if (out_file == NULL)
273
2463194c8cdd updated for version 7.0073
vimboss
parents: 87
diff changeset
3214 smsg("WARNING : Can't open file %s for writing\n", out_redir + 3);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3215 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3217 if (length > 180)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3218 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3219 if (out_file)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3220 fclose(out_file);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3221 return FAIL; /* Command too long. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3222 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3223
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3224 strcpy(task_cmd, "TaskWindow \"");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3225 strncpy(task_cmd + 12, cmd, length);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3226 sprintf(task_cmd + 12 + length,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3227 "\" -task &%08x -ctrl -quit -name \"Vim command\"",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3228 task_handle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3229
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3230 if (options & SHELL_COOKED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3231 settmode(TMODE_COOK);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3232
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3233 if (xswi(Wimp_StartTask, task_cmd) & v_flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3234 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3235 /* Failed to even start a new task (out of memory?) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3236 settmode(TMODE_RAW);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3237 if (out_file)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3238 fclose(out_file);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3239 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3240 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3241
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3242 /* Wait for the child process to initialise. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3243 child_handle = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3244 while (!child_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3245 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3246 reason = wimp_poll(0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3247 if ((reason == 17 || reason == 18) && block[4] == 0x808c2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3248 child_handle = block[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3249 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3250 process_event(reason, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3251 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3252
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3253 /* Block until finished */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3254 while (child_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3255 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3256 reason = wimp_poll(1, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3257 if (reason == 3 || (reason == 8 && block[6] == 3))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3258 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3259 /* Close window request or CTRL-C - kill child task. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3260 block[0] = 20;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3261 block[3] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3262 block[4] = 0x808c4; /* Morite */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3263 swi(Wimp_SendMessage, 17, block, child_handle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3264 MSG_PUTS(_("\nSending message to terminate child process.\n"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3265 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3266 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3267 else if (reason == 8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3268 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3269 block[0] = 28;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3270 block[3] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3271 block[4] = 0x808c0; /* Input */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3272 block[5] = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3273 /* Block[6] is OK as it is! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3274 swi(Wimp_SendMessage, 17, block, child_handle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3275 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3276 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3277 else if (reason == 17 || reason == 18)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3278 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3279 if (block[4] == 0x808c1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3280 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3281 /* Ack message. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3282 block[3] = block[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3283 swi(Wimp_SendMessage, 19, block, block[1]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3284 out = (char_u *)block + 24;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3285 old_msg_col = msg_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3286 while (block[5]--)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3287 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3288 c = *out++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3289 if (out_file && (c != '\r' || (options & SHELL_FILTER)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3290 fputc(c, out_file);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3291 if ((options & SHELL_FILTER) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3292 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3293 if (c == 127)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3294 msg_puts("\b \b");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3295 else if (c > 31)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3296 msg_putchar(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3297 else if (c == 10)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3298 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3299 lines_left = 8; /* Don't do More prompt! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3300 msg_putchar(10);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3301 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3302 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3303 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3304 /* Flush output to the screen. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3305 windgoto(msg_row, msg_col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3306 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3307 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3308 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3309 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3310 process_event(reason, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3311 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3312 msg_putchar('\n');
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3313 settmode(TMODE_RAW);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3314 if (out_file)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3315 fclose(out_file);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3316 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3317 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3318
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3319 /* Like strsave(), but stops at any control char */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3320 char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3321 wimp_strsave(str)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3322 char *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3323 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3324 int strlen = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3325 char_u *retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3326 while (str[strlen] > 31)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3327 strlen++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3328 retval = alloc(strlen + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3329 if (retval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3330 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3331 memcpy(retval, str, strlen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3332 retval[strlen] = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3333 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3334 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3335 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3336
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3337 /* If we are saving then pop up a standard RISC OS save box.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3338 * Otherwise, open a directory viewer on the given directory (and return NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3339 * The string we return will be freed later.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3340 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3341 char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3342 gui_mch_browse(saving, title, dflt, ext, initdir, filter)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3343 int saving; /* write action */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3344 char_u *title; /* title for the window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3345 char_u *dflt; /* default file name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3346 char_u *ext; /* extension added */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3347 char_u *initdir; /* initial directory, NULL for current dir */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3348 char_u *filter; /* file name filter */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3349 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3350 char command[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3351 int length;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3352
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3353 if (saving)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3354 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3355 int block[64];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3356 int reason;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3357 int done_save = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3358 char_u *retval = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3359 char_u *sprname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3360 char_u *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3361 int dragging_icon = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3362 int filetype;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3363
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3364 if (!dflt)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3365 dflt = "TextFile";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3366
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3367 block[0] = save_window;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3368 block[1] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3369 swi(Wimp_GetIconState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3370 sprname = ((char_u *) block[7]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3371 block[1] = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3372 swi(Wimp_GetIconState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3373 fname = ((char *) block[7]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3374 strncpy(fname, dflt, 255);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3375
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3376 if (xswi(OS_FSControl, 31, curbuf->b_p_oft) & v_flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3377 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3378 filetype = 0xfff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3379 strcpy(sprname + 5, "xxx");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3380 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3381 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3382 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3383 filetype = r2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3384 sprintf(sprname + 5, "%03x", filetype);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3385 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3386
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3387 /* Open the save box */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3388
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3389 swi(Wimp_GetPointerInfo, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3390 swi(Wimp_CreateMenu, 0, save_window, block[0] - 64, block[1] + 64);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3391 swi(Wimp_SetCaretPosition, save_window, 1, 0, 0, -1, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3392
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3393 while (!done_save)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3394 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3395 reason = wimp_poll(1, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3396 switch (reason)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3397 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3398 case 1:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3399 redraw_window(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3400 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3401 case 2:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3402 if (block[0] == save_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3403 swi(Wimp_OpenWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3404 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3405 ro_open_window(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3406 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3407 case 3:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3408 done_save = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3409 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3410 case 6:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3411 if (block[3] != save_window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3412 done_save = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3413 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3414 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3415 int drag_box[4];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3416 int min_x, max_y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3417
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3418 switch (block[4])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3419 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3420 case 0: /* Start drag */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3421 block[0] = save_window;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3422 swi(Wimp_GetWindowState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3423 min_x = block[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3424 max_y = block[4];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3425 block[1] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3426 swi(Wimp_GetIconState, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3427 drag_box[0] = block[2] + min_x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3428 drag_box[1] = block[3] + max_y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3429 drag_box[2] = block[4] + min_x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3430 drag_box[3] = block[5] + max_y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3431
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3432 swi(DragASprite_Start,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3433 0x45,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3434 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3435 sprname,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3436 drag_box);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3437 dragging_icon = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3438 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3439 case 2: /* OK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3440 retval = wimp_strsave(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3441 done_save = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3442 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3443 case 3: /* Cancel */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3444 done_save = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3445 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3446 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3447 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3448 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3449 case 7:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3450 if (dragging_icon)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3451 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3452 int len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3453
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3454 dragging_icon = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3455 swi(Wimp_GetPointerInfo, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3456 block[5] = block[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3457 block[6] = block[4];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3458 block[7] = block[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3459 block[8] = block[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3460 block[9] = 0; /* Don't know the size */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3461 block[10] = filetype;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3462
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3463 while (fname[len] > 31)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3464 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3465 if (fname[len] == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3466 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3467 fname += len + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3468 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3469 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3470 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3471 len++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3472 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3473 if (len > 211)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3474 len = 211;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3475
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3476 memcpy(((char_u *) block) + 44, fname, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3477 ((char_u *)block)[44 + len] = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3478
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3479 block[0] = (len + 48) & 0xfc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3480 block[3] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3481 block[4] = 1; /* DataSave */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3482
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3483 swi(Wimp_SendMessage, 17, block, block[5], block[6]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3484 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3485 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3486 ro_drag_finished(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3487 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3488 case 8:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3489 if (block[6] == 13)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3490 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3491 retval = wimp_strsave(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3492 done_save = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3493 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3494 else if (block[6] == 0x1b)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3495 done_save = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3496 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3497 swi(Wimp_ProcessKey, block[6]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3498 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3499 case 17:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3500 case 18:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3501 if (block[4] == 2 && block[9] != -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3502 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3503 /* DataSaveAck from dragging icon. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3504 retval = wimp_strsave(((char_u *) block) + 44);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3505 done_save = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3506 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3507 else if (block[4] == 0x400c9)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3508 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3509 /* MenusDeleted */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3510 done_save = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3511 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3512 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3513 ro_message(block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3514 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3515 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3516 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3517 block[0] = save_window;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3518 swi(Wimp_CloseWindow, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3519 swi(Wimp_GetCaretPosition, 0, block);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3520 if (block[0] == -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3521 swi(Wimp_SetCaretPosition, gui.window_handle, -1, 0, 0, -1, -1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3522
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3523 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3524 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3525 else if (initdir)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3526 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3527 /* Open a directory viewer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3528 length = strlen(initdir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3529
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3530 if (length > 240)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3531 return NULL; /* Path too long! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3532
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3533 length = sprintf(command, "Filer_OpenDir %s", initdir);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3534 while (command[length - 1] == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3535 length--;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3536 command[length] = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3537 swi(OS_CLI, command);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3538 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3539 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3540 }