annotate src/gui_riscos.c @ 63:f6e33184ccc3

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