annotate src/gui_riscos.c @ 2666:1a0d346695fa v7.3.085

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