]> git.ipfire.org Git - ipfire-3.x.git/blob - vim/patches/vim-7.3.187.patch0
7bf82ce4d399e34778b1a9d31c2968725eed7907
[ipfire-3.x.git] / vim / patches / vim-7.3.187.patch0
1 To: vim_dev@googlegroups.com
2 Subject: Patch 7.3.187
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.3.187
11 Problem: The RISC OS port has obvious errors and is not being maintained.
12 Solution: Remove the RISC OS files and code.
13 Files: src/ascii.h, src/eval.c, src/ex_cmds.c, src/ex_cmds2.c,
14 src/ex_docmd.c, src/fileio.c, src/globals.h, src/gui.c, src/gui.h,
15 src/main.c, src/memfile.c, src/memline.c, src/misc1.c,
16 src/proto.h, src/quickfix.c, src/search.c, src/structs.h,
17 src/term.c, src/termlib.c, src/version.c, src/vim.h,
18 src/gui_riscos.h, src/os_riscos.h, src/gui_riscos.c,
19 src/os_riscos.c, runtime/doc/os_risc.txt
20
21
22 *** ../vim-7.3.186/src/ascii.h 2010-08-15 21:57:25.000000000 +0200
23 --- src/ascii.h 2011-05-10 16:22:08.000000000 +0200
24 ***************
25 *** 183,193 ****
26 # define PATHSEP psepc
27 # define PATHSEPSTR pseps
28 #else
29 ! # ifdef RISCOS
30 ! # define PATHSEP '.'
31 ! # define PATHSEPSTR "."
32 ! # else
33 ! # define PATHSEP '/'
34 ! # define PATHSEPSTR "/"
35 ! # endif
36 #endif
37 --- 183,188 ----
38 # define PATHSEP psepc
39 # define PATHSEPSTR pseps
40 #else
41 ! # define PATHSEP '/'
42 ! # define PATHSEPSTR "/"
43 #endif
44 *** ../vim-7.3.186/src/eval.c 2011-04-21 14:27:21.000000000 +0200
45 --- src/eval.c 2011-05-10 16:22:21.000000000 +0200
46 ***************
47 *** 11818,11826 ****
48 #ifdef __QNX__
49 "qnx",
50 #endif
51 - #ifdef RISCOS
52 - "riscos",
53 - #endif
54 #ifdef UNIX
55 "unix",
56 #endif
57 --- 11818,11823 ----
58 *** ../vim-7.3.186/src/ex_cmds.c 2011-05-10 16:00:43.000000000 +0200
59 --- src/ex_cmds.c 2011-05-10 16:23:22.000000000 +0200
60 ***************
61 *** 899,907 ****
62 * Handle the ":!cmd" command. Also for ":r !cmd" and ":w !cmd"
63 * Bangs in the argument are replaced with the previously entered command.
64 * Remember the argument.
65 - *
66 - * RISCOS: Bangs only replaced when followed by a space, since many
67 - * pathnames contain one.
68 */
69 void
70 do_bang(addr_count, eap, forceit, do_in, do_out)
71 --- 899,904 ----
72 ***************
73 *** 980,990 ****
74 trailarg = NULL;
75 while (*p)
76 {
77 ! if (*p == '!'
78 ! #ifdef RISCOS
79 ! && (p[1] == ' ' || p[1] == NUL)
80 ! #endif
81 ! )
82 {
83 if (p > newcmd && p[-1] == '\\')
84 STRMOVE(p - 1, p);
85 --- 977,983 ----
86 trailarg = NULL;
87 while (*p)
88 {
89 ! if (*p == '!')
90 {
91 if (p > newcmd && p[-1] == '\\')
92 STRMOVE(p - 1, p);
93 ***************
94 *** 1578,1591 ****
95 if (p != NULL)
96 *p = NUL;
97 }
98 - # ifdef RISCOS
99 - STRCAT(buf, " { < "); /* Use RISC OS notation for input. */
100 - STRCAT(buf, itmp);
101 - STRCAT(buf, " } ");
102 - # else
103 STRCAT(buf, " <"); /* " < " causes problems on Amiga */
104 STRCAT(buf, itmp);
105 - # endif
106 if (*p_shq == NUL)
107 {
108 p = vim_strchr(cmd, '|');
109 --- 1571,1578 ----
110 ***************
111 *** 1634,1649 ****
112 else
113 vim_snprintf((char *)end, (size_t)(buflen - (end - buf)),
114 #ifdef FEAT_QUICKFIX
115 - # ifndef RISCOS
116 - opt != p_sp ? " %s%s" :
117 - # endif
118 " %s %s",
119 #else
120 - # ifndef RISCOS
121 " %s%s", /* " > %s" causes problems on Amiga */
122 - # else
123 - " %s %s", /* But is needed for 'shellpipe' and RISC OS */
124 - # endif
125 #endif
126 (char *)opt, (char *)fname);
127 }
128 --- 1621,1629 ----
129 ***************
130 *** 1844,1854 ****
131 #ifdef VMS
132 (char_u *)"-tmp",
133 #else
134 - # ifdef RISCOS
135 - (char_u *)"/tmp",
136 - # else
137 (char_u *)".tmp",
138 - # endif
139 #endif
140 FALSE);
141 if (tempname == NULL) /* out of memory */
142 --- 1824,1830 ----
143 *** ../vim-7.3.186/src/ex_cmds2.c 2011-04-11 21:35:03.000000000 +0200
144 --- src/ex_cmds2.c 2011-05-10 16:23:47.000000000 +0200
145 ***************
146 *** 500,517 ****
147 /* Expand the file name in the same way as do_source(). This means
148 * doing it twice, so that $DIR/file gets expanded when $DIR is
149 * "~/dir". */
150 - #ifdef RISCOS
151 - q = mch_munge_fname(p);
152 - #else
153 q = expand_env_save(p);
154 - #endif
155 if (q == NULL)
156 return FAIL;
157 - #ifdef RISCOS
158 - p = mch_munge_fname(q);
159 - #else
160 p = expand_env_save(q);
161 - #endif
162 vim_free(q);
163 if (p == NULL)
164 return FAIL;
165 --- 500,509 ----
166 ***************
167 *** 2940,2950 ****
168 proftime_T wait_start;
169 #endif
170
171 - #ifdef RISCOS
172 - p = mch_munge_fname(fname);
173 - #else
174 p = expand_env_save(fname);
175 - #endif
176 if (p == NULL)
177 return retval;
178 fname_exp = fix_fname(p);
179 --- 2932,2938 ----
180 *** ../vim-7.3.186/src/ex_docmd.c 2011-05-05 14:26:37.000000000 +0200
181 --- src/ex_docmd.c 2011-05-10 16:24:18.000000000 +0200
182 ***************
183 *** 9702,9715 ****
184 valid = 0; /* Must have ":p:h" to be valid */
185 }
186 else
187 - #ifdef RISCOS
188 - /* Always use the full path for RISC OS if possible. */
189 - result = curbuf->b_ffname;
190 - if (result == NULL)
191 - result = curbuf->b_fname;
192 - #else
193 result = curbuf->b_fname;
194 - #endif
195 break;
196
197 case SPEC_HASH: /* '#' or "#99": alternate file */
198 --- 9702,9708 ----
199 ***************
200 *** 9854,9864 ****
201 if (src[*usedlen] == '<') /* remove the file name extension */
202 {
203 ++*usedlen;
204 - #ifdef RISCOS
205 - if ((s = vim_strrchr(result, '/')) != NULL && s >= gettail(result))
206 - #else
207 if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result))
208 - #endif
209 resultlen = (int)(s - result);
210 }
211 #ifdef FEAT_MODIFY_FNAME
212 --- 9847,9853 ----
213 ***************
214 *** 10875,10882 ****
215 else if (vim_ispathsep(*p))
216 {
217 *s++ = '=';
218 ! #if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA) || defined(RISCOS) \
219 ! || defined(VMS)
220 if (*p == ':')
221 *s++ = '-';
222 else
223 --- 10864,10870 ----
224 else if (vim_ispathsep(*p))
225 {
226 *s++ = '=';
227 ! #if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA) || defined(VMS)
228 if (*p == ':')
229 *s++ = '-';
230 else
231 *** ../vim-7.3.186/src/fileio.c 2011-05-05 16:41:19.000000000 +0200
232 --- src/fileio.c 2011-05-10 16:26:06.000000000 +0200
233 ***************
234 *** 504,521 ****
235
236 if (newfile && !read_stdin && !read_buffer)
237 {
238 ! /* Remember time of file.
239 ! * For RISCOS, also remember the filetype.
240 ! */
241 if (mch_stat((char *)fname, &st) >= 0)
242 {
243 buf_store_time(curbuf, &st, fname);
244 curbuf->b_mtime_read = curbuf->b_mtime;
245 -
246 - #if defined(RISCOS) && defined(FEAT_OSFILETYPE)
247 - /* Read the filetype into the buffer local filetype option. */
248 - mch_read_filetype(fname);
249 - #endif
250 #ifdef UNIX
251 /*
252 * Use the protection bits of the original file for the swap file.
253 --- 504,514 ----
254
255 if (newfile && !read_stdin && !read_buffer)
256 {
257 ! /* Remember time of file. */
258 if (mch_stat((char *)fname, &st) >= 0)
259 {
260 buf_store_time(curbuf, &st, fname);
261 curbuf->b_mtime_read = curbuf->b_mtime;
262 #ifdef UNIX
263 /*
264 * Use the protection bits of the original file for the swap file.
265 ***************
266 *** 557,563 ****
267
268 /*
269 * for UNIX: check readonly with perm and mch_access()
270 - * for RISCOS: same as Unix, otherwise file gets re-datestamped!
271 * for MSDOS and Amiga: check readonly by trying to open the file for writing
272 */
273 file_readonly = FALSE;
274 --- 550,555 ----
275 ***************
276 *** 3804,3816 ****
277
278 /* make sure we have a valid backup extension to use */
279 if (*p_bex == NUL)
280 - {
281 - #ifdef RISCOS
282 - backup_ext = (char_u *)"/bak";
283 - #else
284 backup_ext = (char_u *)".bak";
285 - #endif
286 - }
287 else
288 backup_ext = p_bex;
289
290 --- 3796,3802 ----
291 ***************
292 *** 4724,4734 ****
293 #endif
294 if (perm >= 0) /* set perm. of new file same as old file */
295 (void)mch_setperm(wfname, perm);
296 - #ifdef RISCOS
297 - if (!append && !filtering)
298 - /* Set the filetype after writing the file. */
299 - mch_set_filetype(wfname, buf->b_p_oft);
300 - #endif
301 #ifdef HAVE_ACL
302 /* Probably need to set the ACL before changing the user (can't set the
303 * ACL on a file the user doesn't own). */
304 --- 4710,4715 ----
305 ***************
306 *** 6262,6280 ****
307 */
308 for (ptr = retval + fnamelen; ptr > retval; mb_ptr_back(retval, ptr))
309 {
310 - #ifndef RISCOS
311 if (*ext == '.'
312 ! # ifdef USE_LONG_FNAME
313 && (!USE_LONG_FNAME || shortname)
314 ! # else
315 ! # ifndef SHORT_FNAME
316 && shortname
317 - # endif
318 # endif
319 )
320 if (*ptr == '.') /* replace '.' by '_' */
321 *ptr = '_';
322 - #endif
323 if (vim_ispathsep(*ptr))
324 {
325 ++ptr;
326 --- 6243,6259 ----
327 */
328 for (ptr = retval + fnamelen; ptr > retval; mb_ptr_back(retval, ptr))
329 {
330 if (*ext == '.'
331 ! #ifdef USE_LONG_FNAME
332 && (!USE_LONG_FNAME || shortname)
333 ! #else
334 ! # ifndef SHORT_FNAME
335 && shortname
336 # endif
337 + #endif
338 )
339 if (*ptr == '.') /* replace '.' by '_' */
340 *ptr = '_';
341 if (vim_ispathsep(*ptr))
342 {
343 ++ptr;
344 ***************
345 *** 6309,6331 ****
346 if (fname == NULL || *fname == NUL
347 || vim_ispathsep(fname[STRLEN(fname) - 1]))
348 {
349 - #ifdef RISCOS
350 - if (*ext == '/')
351 - #else
352 if (*ext == '.')
353 - #endif
354 *s++ = '_';
355 }
356 /*
357 * If the extension starts with '.', truncate the base name at 8
358 * characters
359 */
360 - #ifdef RISCOS
361 - /* We normally use '/', but swap files are '_' */
362 - else if (*ext == '/' || *ext == '_')
363 - #else
364 else if (*ext == '.')
365 - #endif
366 {
367 if ((size_t)(s - ptr) > (size_t)8)
368 {
369 --- 6288,6301 ----
370 ***************
371 *** 6337,6349 ****
372 * If the extension doesn't start with '.', and the file name
373 * doesn't have an extension yet, append a '.'
374 */
375 - #ifdef RISCOS
376 - else if ((e = vim_strchr(ptr, '/')) == NULL)
377 - *s++ = '/';
378 - #else
379 else if ((e = vim_strchr(ptr, '.')) == NULL)
380 *s++ = '.';
381 - #endif
382 /*
383 * If the extension doesn't start with '.', and there already is an
384 * extension, it may need to be truncated
385 --- 6307,6314 ----
386 ***************
387 *** 6371,6393 ****
388 /*
389 * Prepend the dot.
390 */
391 ! if (prepend_dot && !shortname && *(e = gettail(retval)) !=
392 ! #ifdef RISCOS
393 ! '/'
394 ! #else
395 ! '.'
396 ! #endif
397 #ifdef USE_LONG_FNAME
398 && USE_LONG_FNAME
399 #endif
400 )
401 {
402 STRMOVE(e + 1, e);
403 - #ifdef RISCOS
404 - *e = '/';
405 - #else
406 *e = '.';
407 - #endif
408 }
409 #endif
410
411 --- 6336,6349 ----
412 /*
413 * Prepend the dot.
414 */
415 ! if (prepend_dot && !shortname && *(e = gettail(retval)) != '.'
416 #ifdef USE_LONG_FNAME
417 && USE_LONG_FNAME
418 #endif
419 )
420 {
421 STRMOVE(e + 1, e);
422 *e = '.';
423 }
424 #endif
425
426 ***************
427 *** 10205,10223 ****
428 ++p;
429 break;
430 case '.':
431 - #ifdef RISCOS
432 - if (allow_dirs != NULL)
433 - *allow_dirs = TRUE;
434 - /* FALLTHROUGH */
435 - #endif
436 case '~':
437 reg_pat[i++] = '\\';
438 reg_pat[i++] = *p;
439 break;
440 case '?':
441 - #ifdef RISCOS
442 - case '#':
443 - #endif
444 reg_pat[i++] = '.';
445 break;
446 case '\\':
447 --- 10161,10171 ----
448 *** ../vim-7.3.186/src/globals.h 2011-05-05 14:26:37.000000000 +0200
449 --- src/globals.h 2011-05-10 16:26:13.000000000 +0200
450 ***************
451 *** 1513,1519 ****
452 EXTERN char_u e_sandbox[] INIT(= N_("E48: Not allowed in sandbox"));
453 #endif
454 EXTERN char_u e_secure[] INIT(= N_("E523: Not allowed here"));
455 ! #if defined(AMIGA) || defined(MACOS) || defined(MSWIN) || defined(RISCOS) \
456 || defined(UNIX) || defined(VMS) || defined(OS2)
457 EXTERN char_u e_screenmode[] INIT(= N_("E359: Screen mode setting not supported"));
458 #endif
459 --- 1513,1519 ----
460 EXTERN char_u e_sandbox[] INIT(= N_("E48: Not allowed in sandbox"));
461 #endif
462 EXTERN char_u e_secure[] INIT(= N_("E523: Not allowed here"));
463 ! #if defined(AMIGA) || defined(MACOS) || defined(MSWIN) \
464 || defined(UNIX) || defined(VMS) || defined(OS2)
465 EXTERN char_u e_screenmode[] INIT(= N_("E359: Screen mode setting not supported"));
466 #endif
467 *** ../vim-7.3.186/src/gui.c 2011-01-17 20:08:03.000000000 +0100
468 --- src/gui.c 2011-05-10 16:26:53.000000000 +0200
469 ***************
470 *** 2156,2162 ****
471
472 if (highlight_mask & (HL_INVERSE | HL_STANDOUT))
473 {
474 ! #if defined(AMIGA) || defined(RISCOS)
475 gui_mch_set_colors(bg_color, fg_color);
476 #else
477 gui_mch_set_fg_color(bg_color);
478 --- 2156,2162 ----
479
480 if (highlight_mask & (HL_INVERSE | HL_STANDOUT))
481 {
482 ! #if defined(AMIGA)
483 gui_mch_set_colors(bg_color, fg_color);
484 #else
485 gui_mch_set_fg_color(bg_color);
486 ***************
487 *** 2165,2171 ****
488 }
489 else
490 {
491 ! #if defined(AMIGA) || defined(RISCOS)
492 gui_mch_set_colors(fg_color, bg_color);
493 #else
494 gui_mch_set_fg_color(fg_color);
495 --- 2165,2171 ----
496 }
497 else
498 {
499 ! #if defined(AMIGA)
500 gui_mch_set_colors(fg_color, bg_color);
501 #else
502 gui_mch_set_fg_color(fg_color);
503 ***************
504 *** 2193,2199 ****
505 if (back != 0 && ((draw_flags & DRAW_BOLD) || (highlight_mask & HL_ITALIC)))
506 return FAIL;
507
508 ! #if defined(RISCOS) || defined(FEAT_GUI_GTK)
509 /* If there's no italic font, then fake it.
510 * For GTK2, we don't need a different font for italic style. */
511 if (hl_mask_todo & HL_ITALIC)
512 --- 2193,2199 ----
513 if (back != 0 && ((draw_flags & DRAW_BOLD) || (highlight_mask & HL_ITALIC)))
514 return FAIL;
515
516 ! #if defined(FEAT_GUI_GTK)
517 /* If there's no italic font, then fake it.
518 * For GTK2, we don't need a different font for italic style. */
519 if (hl_mask_todo & HL_ITALIC)
520 ***************
521 *** 2985,3010 ****
522 did_clip = TRUE;
523 }
524 /* Allow the left button to start the selection */
525 - else if (button ==
526 - # ifdef RISCOS
527 - /* Only start a drag on a drag event. Otherwise
528 - * we don't get a release event. */
529 - MOUSE_DRAG
530 - # else
531 - MOUSE_LEFT
532 - # endif
533 - )
534 - {
535 - clip_start_selection(X_2_COL(x), Y_2_ROW(y), repeated_click);
536 - did_clip = TRUE;
537 - }
538 - # ifdef RISCOS
539 else if (button == MOUSE_LEFT)
540 {
541 ! clip_clear_selection();
542 did_clip = TRUE;
543 }
544 - # endif
545
546 /* Always allow pasting */
547 if (button != MOUSE_MIDDLE)
548 --- 2985,2995 ----
549 did_clip = TRUE;
550 }
551 /* Allow the left button to start the selection */
552 else if (button == MOUSE_LEFT)
553 {
554 ! clip_start_selection(X_2_COL(x), Y_2_ROW(y), repeated_click);
555 did_clip = TRUE;
556 }
557
558 /* Always allow pasting */
559 if (button != MOUSE_MIDDLE)
560 *** ../vim-7.3.186/src/gui.h 2010-08-15 21:57:25.000000000 +0200
561 --- src/gui.h 2011-05-10 16:27:19.000000000 +0200
562 ***************
563 *** 52,61 ****
564 # include <SegLoad.h>*/
565 #endif
566
567 - #ifdef RISCOS
568 - # include "gui_riscos.h"
569 - #endif
570 -
571 #ifdef FEAT_GUI_PHOTON
572 # include <Ph.h>
573 # include <Pt.h>
574 --- 52,57 ----
575 ***************
576 *** 151,157 ****
577 #define DRAW_BOLD 0x02 /* draw bold text */
578 #define DRAW_UNDERL 0x04 /* draw underline text */
579 #define DRAW_UNDERC 0x08 /* draw undercurl text */
580 ! #if defined(RISCOS) || defined(FEAT_GUI_GTK)
581 # define DRAW_ITALIC 0x10 /* draw italic text */
582 #endif
583 #define DRAW_CURSOR 0x20 /* drawing block cursor (win32) */
584 --- 147,153 ----
585 #define DRAW_BOLD 0x02 /* draw bold text */
586 #define DRAW_UNDERL 0x04 /* draw underline text */
587 #define DRAW_UNDERC 0x08 /* draw undercurl text */
588 ! #if defined(FEAT_GUI_GTK)
589 # define DRAW_ITALIC 0x10 /* draw italic text */
590 #endif
591 #define DRAW_CURSOR 0x20 /* drawing block cursor (win32) */
592 ***************
593 *** 219,227 ****
594 #ifdef FEAT_GUI_MAC
595 ControlHandle id; /* A handle to the scrollbar */
596 #endif
597 - #ifdef RISCOS
598 - int id; /* Window handle of scrollbar window */
599 - #endif
600 #ifdef FEAT_GUI_PHOTON
601 PtWidget_t *id;
602 #endif
603 --- 215,220 ----
604 ***************
605 *** 450,463 ****
606 int visibility; /* Is window partially/fully obscured? */
607 #endif
608
609 - #ifdef RISCOS
610 - int window_handle;
611 - char_u *window_title;
612 - int window_title_size;
613 - int fg_colour; /* in 0xBBGGRR format */
614 - int bg_colour;
615 - #endif
616 -
617 #ifdef FEAT_GUI_PHOTON
618 PtWidget_t *vimWindow; /* PtWindow */
619 PtWidget_t *vimTextArea; /* PtRaw */
620 --- 443,448 ----
621 *** ../vim-7.3.186/src/main.c 2011-04-11 21:35:03.000000000 +0200
622 --- src/main.c 2011-05-10 16:27:33.000000000 +0200
623 ***************
624 *** 3276,3286 ****
625 main_msg(_("+reverse\t\tDon't use reverse video (also: +rv)"));
626 main_msg(_("-xrm <resource>\tSet the specified resource"));
627 #endif /* FEAT_GUI_X11 */
628 - #if defined(FEAT_GUI) && defined(RISCOS)
629 - mch_msg(_("\nArguments recognised by gvim (RISC OS version):\n"));
630 - main_msg(_("--columns <number>\tInitial width of window in columns"));
631 - main_msg(_("--rows <number>\tInitial height of window in rows"));
632 - #endif
633 #ifdef FEAT_GUI_GTK
634 mch_msg(_("\nArguments recognised by gvim (GTK+ version):\n"));
635 main_msg(_("-font <font>\t\tUse <font> for normal text (also: -fn)"));
636 --- 3276,3281 ----
637 *** ../vim-7.3.186/src/memfile.c 2011-03-22 18:10:34.000000000 +0100
638 --- src/memfile.c 2011-05-10 16:27:38.000000000 +0200
639 ***************
640 *** 1307,1313 ****
641 * fname cannot be NameBuff, because it must have been allocated.
642 */
643 mf_set_ffname(mfp);
644 ! #if defined(MSDOS) || defined(MSWIN) || defined(RISCOS)
645 /*
646 * A ":!cd e:xxx" may change the directory without us knowning, use the
647 * full pathname always. Careful: This frees fname!
648 --- 1307,1313 ----
649 * fname cannot be NameBuff, because it must have been allocated.
650 */
651 mf_set_ffname(mfp);
652 ! #if defined(MSDOS) || defined(MSWIN)
653 /*
654 * A ":!cd e:xxx" may change the directory without us knowning, use the
655 * full pathname always. Careful: This frees fname!
656 *** ../vim-7.3.186/src/memline.c 2011-02-15 11:56:56.000000000 +0100
657 --- src/memline.c 2011-05-10 16:28:40.000000000 +0200
658 ***************
659 *** 748,754 ****
660 continue;
661 if (mf_open_file(mfp, fname) == OK) /* consumes fname! */
662 {
663 ! #if defined(MSDOS) || defined(MSWIN) || defined(RISCOS)
664 /*
665 * set full pathname for swap file now, because a ":!cd dir" may
666 * change directory without us knowing it.
667 --- 748,754 ----
668 continue;
669 if (mf_open_file(mfp, fname) == OK) /* consumes fname! */
670 {
671 ! #if defined(MSDOS) || defined(MSWIN)
672 /*
673 * set full pathname for swap file now, because a ":!cd dir" may
674 * change directory without us knowing it.
675 ***************
676 *** 933,939 ****
677 b0p->b0_fname[0] = NUL;
678 else
679 {
680 ! #if defined(MSDOS) || defined(MSWIN) || defined(AMIGA) || defined(RISCOS)
681 /* Systems that cannot translate "~user" back into a path: copy the
682 * file name unmodified. Do use slashes instead of backslashes for
683 * portability. */
684 --- 933,939 ----
685 b0p->b0_fname[0] = NUL;
686 else
687 {
688 ! #if defined(MSDOS) || defined(MSWIN) || defined(AMIGA)
689 /* Systems that cannot translate "~user" back into a path: copy the
690 * file name unmodified. Do use slashes instead of backslashes for
691 * portability. */
692 ***************
693 *** 1103,1109 ****
694 fname = (char_u *)"";
695 len = (int)STRLEN(fname);
696 if (len >= 4 &&
697 ! #if defined(VMS) || defined(RISCOS)
698 STRNICMP(fname + len - 4, "_s" , 2)
699 #else
700 STRNICMP(fname + len - 4, ".s" , 2)
701 --- 1103,1109 ----
702 fname = (char_u *)"";
703 len = (int)STRLEN(fname);
704 if (len >= 4 &&
705 ! #if defined(VMS)
706 STRNICMP(fname + len - 4, "_s" , 2)
707 #else
708 STRNICMP(fname + len - 4, ".s" , 2)
709 ***************
710 *** 1773,1783 ****
711 #ifdef VMS
712 names[0] = vim_strsave((char_u *)"*_sw%");
713 #else
714 - # ifdef RISCOS
715 - names[0] = vim_strsave((char_u *)"*_sw#");
716 - # else
717 names[0] = vim_strsave((char_u *)"*.sw?");
718 - # endif
719 #endif
720 #if defined(UNIX) || defined(WIN3264)
721 /* For Unix names starting with a dot are special. MS-Windows
722 --- 1773,1779 ----
723 ***************
724 *** 1804,1814 ****
725 #ifdef VMS
726 names[0] = concat_fnames(dir_name, (char_u *)"*_sw%", TRUE);
727 #else
728 - # ifdef RISCOS
729 - names[0] = concat_fnames(dir_name, (char_u *)"*_sw#", TRUE);
730 - # else
731 names[0] = concat_fnames(dir_name, (char_u *)"*.sw?", TRUE);
732 - # endif
733 #endif
734 #if defined(UNIX) || defined(WIN3264)
735 /* For Unix names starting with a dot are special. MS-Windows
736 --- 1800,1806 ----
737 ***************
738 *** 1877,1883 ****
739 char_u *swapname;
740
741 swapname = modname(fname_res,
742 ! #if defined(VMS) || defined(RISCOS)
743 (char_u *)"_swp", FALSE
744 #else
745 (char_u *)".swp", TRUE
746 --- 1869,1875 ----
747 char_u *swapname;
748
749 swapname = modname(fname_res,
750 ! #if defined(VMS)
751 (char_u *)"_swp", FALSE
752 #else
753 (char_u *)".swp", TRUE
754 ***************
755 *** 2176,2186 ****
756 #ifdef VMS
757 names[num_names] = concat_fnames(path, (char_u *)"_sw%", FALSE);
758 #else
759 - # ifdef RISCOS
760 - names[num_names] = concat_fnames(path, (char_u *)"_sw#", FALSE);
761 - # else
762 names[num_names] = concat_fnames(path, (char_u *)".sw?", FALSE);
763 - # endif
764 #endif
765 if (names[num_names] == NULL)
766 goto end;
767 --- 2168,2174 ----
768 ***************
769 *** 2207,2217 ****
770 #ifdef VMS
771 names[num_names] = modname(path, (char_u *)"_sw%", FALSE);
772 #else
773 - # ifdef RISCOS
774 - names[num_names] = modname(path, (char_u *)"_sw#", FALSE);
775 - # else
776 names[num_names] = modname(path, (char_u *)".sw?", FALSE);
777 - # endif
778 #endif
779 if (names[num_names] == NULL)
780 goto end;
781 --- 2195,2201 ----
782 ***************
783 *** 3205,3211 ****
784 mf_free(mfp, hp); /* free the data block */
785 buf->b_ml.ml_locked = NULL;
786
787 ! for (stack_idx = buf->b_ml.ml_stack_top - 1; stack_idx >= 0; --stack_idx)
788 {
789 buf->b_ml.ml_stack_top = 0; /* stack is invalid when failing */
790 ip = &(buf->b_ml.ml_stack[stack_idx]);
791 --- 3189,3196 ----
792 mf_free(mfp, hp); /* free the data block */
793 buf->b_ml.ml_locked = NULL;
794
795 ! for (stack_idx = buf->b_ml.ml_stack_top - 1; stack_idx >= 0;
796 ! --stack_idx)
797 {
798 buf->b_ml.ml_stack_top = 0; /* stack is invalid when failing */
799 ip = &(buf->b_ml.ml_stack[stack_idx]);
800 ***************
801 *** 3956,3969 ****
802 #else
803 (buf->b_p_sn || buf->b_shortname),
804 #endif
805 - #ifdef RISCOS
806 - /* Avoid problems if fname has special chars, eg <Wimp$Scrap> */
807 - ffname,
808 - #else
809 fname_res,
810 - #endif
811 (char_u *)
812 ! #if defined(VMS) || defined(RISCOS)
813 "_swp",
814 #else
815 ".swp",
816 --- 3941,3949 ----
817 #else
818 (buf->b_p_sn || buf->b_shortname),
819 #endif
820 fname_res,
821 (char_u *)
822 ! #if defined(VMS)
823 "_swp",
824 #else
825 ".swp",
826 ***************
827 *** 4427,4440 ****
828 }
829 close(fd);
830 }
831 - #ifdef RISCOS
832 - else
833 - /* Can't open swap file, though it does exist.
834 - * Assume that the user is editing two files with
835 - * the same name in different directories. No error.
836 - */
837 - differ = TRUE;
838 - #endif
839
840 /* give the ATTENTION message when there is an old swap file
841 * for the current file, and the buffer was not recovered. */
842 --- 4407,4412 ----
843 *** ../vim-7.3.186/src/misc1.c 2011-05-10 14:44:07.000000000 +0200
844 --- src/misc1.c 2011-05-10 16:29:29.000000000 +0200
845 ***************
846 *** 4589,4613 ****
847 vim_ispathsep(c)
848 int c;
849 {
850 ! #ifdef RISCOS
851 ! return (c == '.' || c == ':');
852 ! #else
853 ! # ifdef UNIX
854 return (c == '/'); /* UNIX has ':' inside file names */
855 ! # else
856 ! # ifdef BACKSLASH_IN_FILENAME
857 return (c == ':' || c == '/' || c == '\\');
858 ! # else
859 ! # ifdef VMS
860 /* server"user passwd"::device:[full.path.name]fname.extension;version" */
861 return (c == ':' || c == '[' || c == ']' || c == '/'
862 || c == '<' || c == '>' || c == '"' );
863 ! # else /* Amiga */
864 return (c == ':' || c == '/');
865 ! # endif /* VMS */
866 ! # endif
867 # endif
868 ! #endif /* RISC OS */
869 }
870
871 #if defined(FEAT_SEARCHPATH) || defined(PROTO)
872 --- 4589,4609 ----
873 vim_ispathsep(c)
874 int c;
875 {
876 ! #ifdef UNIX
877 return (c == '/'); /* UNIX has ':' inside file names */
878 ! #else
879 ! # ifdef BACKSLASH_IN_FILENAME
880 return (c == ':' || c == '/' || c == '\\');
881 ! # else
882 ! # ifdef VMS
883 /* server"user passwd"::device:[full.path.name]fname.extension;version" */
884 return (c == ':' || c == '[' || c == ']' || c == '/'
885 || c == '<' || c == '>' || c == '"' );
886 ! # else
887 return (c == ':' || c == '/');
888 ! # endif /* VMS */
889 # endif
890 ! #endif
891 }
892
893 #if defined(FEAT_SEARCHPATH) || defined(PROTO)
894 *** ../vim-7.3.186/src/proto.h 2010-08-15 21:57:29.000000000 +0200
895 --- src/proto.h 2011-05-10 16:29:45.000000000 +0200
896 ***************
897 *** 62,70 ****
898 # ifdef __BEOS__
899 # include "os_beos.pro"
900 # endif
901 - # ifdef RISCOS
902 - # include "os_riscos.pro"
903 - # endif
904 # ifdef __QNX__
905 # include "os_qnx.pro"
906 # endif
907 --- 62,67 ----
908 ***************
909 *** 245,253 ****
910 # ifdef FEAT_GUI_X11
911 # include "gui_x11.pro"
912 # endif
913 - # ifdef RISCOS
914 - # include "gui_riscos.pro"
915 - # endif
916 # ifdef FEAT_GUI_PHOTON
917 # include "gui_photon.pro"
918 # endif
919 --- 242,247 ----
920 *** ../vim-7.3.186/src/quickfix.c 2011-05-05 17:14:07.000000000 +0200
921 --- src/quickfix.c 2011-05-10 16:30:18.000000000 +0200
922 ***************
923 *** 1182,1202 ****
924 if (fname == NULL || *fname == NUL) /* no file name */
925 return 0;
926 {
927 - #ifdef RISCOS
928 - /* Name is reported as `main.c', but file is `c.main' */
929 - return ro_buflist_add(fname);
930 - #else
931 char_u *ptr;
932 int fnum;
933
934 ! # ifdef VMS
935 vms_remove_version(fname);
936 ! # endif
937 ! # ifdef BACKSLASH_IN_FILENAME
938 if (directory != NULL)
939 slash_adjust(directory);
940 slash_adjust(fname);
941 ! # endif
942 if (directory != NULL && !vim_isAbsName(fname)
943 && (ptr = concat_fnames(directory, fname, TRUE)) != NULL)
944 {
945 --- 1182,1198 ----
946 if (fname == NULL || *fname == NUL) /* no file name */
947 return 0;
948 {
949 char_u *ptr;
950 int fnum;
951
952 ! #ifdef VMS
953 vms_remove_version(fname);
954 ! #endif
955 ! #ifdef BACKSLASH_IN_FILENAME
956 if (directory != NULL)
957 slash_adjust(directory);
958 slash_adjust(fname);
959 ! #endif
960 if (directory != NULL && !vim_isAbsName(fname)
961 && (ptr = concat_fnames(directory, fname, TRUE)) != NULL)
962 {
963 ***************
964 *** 1221,1227 ****
965 return fnum;
966 }
967 return buflist_add(fname, 0);
968 - #endif
969 }
970 }
971
972 --- 1217,1222 ----
973 *** ../vim-7.3.186/src/search.c 2011-02-25 18:38:29.000000000 +0100
974 --- src/search.c 2011-05-10 16:30:38.000000000 +0200
975 ***************
976 *** 4581,4589 ****
977 char_u *already = NULL;
978 char_u *startp = NULL;
979 char_u *inc_opt = NULL;
980 - #ifdef RISCOS
981 - int previous_munging = __riscosify_control;
982 - #endif
983 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
984 win_T *curwin_save = NULL;
985 #endif
986 --- 4581,4586 ----
987 ***************
988 *** 4596,4606 ****
989 if (file_line == NULL)
990 return;
991
992 - #ifdef RISCOS
993 - /* UnixLib knows best how to munge c file names - turn munging back on. */
994 - int __riscosify_control = 0;
995 - #endif
996 -
997 if (type != CHECK_PATH && type != FIND_DEFINE
998 #ifdef FEAT_INS_EXPAND
999 /* when CONT_SOL is set compare "ptr" with the beginning of the line
1000 --- 4593,4598 ----
1001 ***************
1002 *** 5228,5238 ****
1003 vim_free(regmatch.regprog);
1004 vim_free(incl_regmatch.regprog);
1005 vim_free(def_regmatch.regprog);
1006 -
1007 - #ifdef RISCOS
1008 - /* Restore previous file munging state. */
1009 - __riscosify_control = previous_munging;
1010 - #endif
1011 }
1012
1013 static void
1014 --- 5220,5225 ----
1015 *** ../vim-7.3.186/src/structs.h 2011-03-22 18:10:34.000000000 +0100
1016 --- src/structs.h 2011-05-10 16:30:49.000000000 +0200
1017 ***************
1018 *** 2366,2376 ****
1019 MenuHandle menu_handle;
1020 MenuHandle submenu_handle;
1021 #endif
1022 - #ifdef RISCOS
1023 - int *id; /* Not used, but gui.c needs it */
1024 - int greyed_out; /* Flag */
1025 - int hidden;
1026 - #endif
1027 #ifdef FEAT_GUI_PHOTON
1028 PtWidget_t *id;
1029 PtWidget_t *submenu_id;
1030 --- 2366,2371 ----
1031 *** ../vim-7.3.186/src/term.c 2010-12-30 14:47:32.000000000 +0100
1032 --- src/term.c 2011-05-10 16:31:41.000000000 +0200
1033 ***************
1034 *** 52,58 ****
1035
1036 /*
1037 * Here are the builtin termcap entries. They are not stored as complete
1038 ! * Tcarr structures, as such a structure is too big.
1039 *
1040 * The entries are compact, therefore they normally are included even when
1041 * HAVE_TGETENT is defined. When HAVE_TGETENT is defined, the builtin entries
1042 --- 52,58 ----
1043
1044 /*
1045 * Here are the builtin termcap entries. They are not stored as complete
1046 ! * structures with all entries, as such a structure is too big.
1047 *
1048 * The entries are compact, therefore they normally are included even when
1049 * HAVE_TGETENT is defined. When HAVE_TGETENT is defined, the builtin entries
1050 ***************
1051 *** 199,269 ****
1052 #endif
1053
1054 #ifndef NO_BUILTIN_TCAPS
1055 - # if defined(RISCOS) || defined(ALL_BUILTIN_TCAPS)
1056 - /*
1057 - * Default for the Acorn.
1058 - */
1059 - {(int)KS_NAME, "riscos"},
1060 - {(int)KS_CL, "\014"}, /* Cls and Home Cursor */
1061 - {(int)KS_CM, "\001%d\001%d\002"}, /* Position cursor */
1062 -
1063 - {(int)KS_CCO, "16"}, /* Allow 16 colors */
1064 -
1065 - {(int)KS_CAF, "\001%d\021"}, /* Set foreground colour */
1066 - {(int)KS_CAB, "\001%d\022"}, /* Set background colour */
1067 -
1068 -
1069 - {(int)KS_ME, "\004"}, /* Normal mode */
1070 - {(int)KS_MR, "\005"}, /* Reverse */
1071 -
1072 - {(int)KS_VI, "\016"}, /* Cursor invisible */
1073 - {(int)KS_VE, "\017"}, /* Cursor visible */
1074 - {(int)KS_VS, "\020"}, /* Cursor very visible */
1075 -
1076 - {(int)KS_CS, "\001%d\001%d\003"}, /* Set scroll region */
1077 - {(int)KS_SR, "\023"}, /* Scroll text down */
1078 - {K_UP, "\217"},
1079 - {K_DOWN, "\216"},
1080 - {K_LEFT, "\214"},
1081 - {K_RIGHT, "\215"},
1082 - {K_S_UP, "\237"},
1083 - {K_S_DOWN, "\236"},
1084 - {K_S_LEFT, "\234"},
1085 - {K_S_RIGHT, "\235"},
1086 -
1087 - {K_F1, "\201"},
1088 - {K_F2, "\202"},
1089 - {K_F3, "\203"},
1090 - {K_F4, "\204"},
1091 - {K_F5, "\205"},
1092 - {K_F6, "\206"},
1093 - {K_F7, "\207"},
1094 - {K_F8, "\210"},
1095 - {K_F9, "\211"},
1096 - {K_F10, "\312"},
1097 - {K_F11, "\313"},
1098 - {K_F12, "\314"},
1099 - {K_S_F1, "\221"},
1100 - {K_S_F2, "\222"},
1101 - {K_S_F3, "\223"},
1102 - {K_S_F4, "\224"},
1103 - {K_S_F5, "\225"},
1104 - {K_S_F6, "\226"},
1105 - {K_S_F7, "\227"},
1106 - {K_S_F8, "\230"},
1107 - {K_S_F9, "\231"},
1108 - {K_S_F10, "\332"},
1109 - {K_S_F11, "\333"},
1110 - {K_S_F12, "\334"},
1111 - {K_BS, "\010"},
1112 - {K_INS, "\315"},
1113 - {K_DEL, "\177"},
1114 - {K_HOME, "\036"},
1115 - {K_END, "\213"},
1116 - {K_PAGEUP, "\237"},
1117 - {K_PAGEDOWN, "\236"},
1118 - # endif /* Acorn terminal */
1119 -
1120
1121 # if defined(AMIGA) || defined(ALL_BUILTIN_TCAPS)
1122 /*
1123 --- 199,204 ----
1124 ***************
1125 *** 1399,1408 ****
1126 /*
1127 * DEFAULT_TERM is used, when no terminal is specified with -T option or $TERM.
1128 */
1129 - #ifdef RISCOS
1130 - # define DEFAULT_TERM (char_u *)"riscos"
1131 - #endif
1132 -
1133 #ifdef AMIGA
1134 # define DEFAULT_TERM (char_u *)"amiga"
1135 #endif
1136 --- 1334,1339 ----
1137 *** ../vim-7.3.186/src/termlib.c 2010-08-15 21:57:30.000000000 +0200
1138 --- src/termlib.c 2011-05-10 16:31:58.000000000 +0200
1139 ***************
1140 *** 13,19 ****
1141 #include "vim.h"
1142 #include "termlib.pro"
1143
1144 ! #if !defined(AMIGA) && !defined(VMS) && !defined(MACOS) && !defined(RISCOS)
1145 # include <sgtty.h>
1146 #endif
1147
1148 --- 13,19 ----
1149 #include "vim.h"
1150 #include "termlib.pro"
1151
1152 ! #if !defined(AMIGA) && !defined(VMS) && !defined(MACOS)
1153 # include <sgtty.h>
1154 #endif
1155
1156 *** ../vim-7.3.186/src/version.c 2011-05-10 16:12:40.000000000 +0200
1157 --- src/version.c 2011-05-10 16:37:20.000000000 +0200
1158 ***************
1159 *** 1205,1213 ****
1160 # endif
1161 #endif
1162
1163 - #ifdef RISCOS
1164 - MSG_PUTS(_("\nRISC OS version"));
1165 - #endif
1166 #ifdef VMS
1167 MSG_PUTS(_("\nOpenVMS version"));
1168 # ifdef HAVE_PATHDEF
1169 --- 1207,1212 ----
1170 *** ../vim-7.3.186/src/vim.h 2011-05-05 16:41:19.000000000 +0200
1171 --- src/vim.h 2011-05-10 16:32:40.000000000 +0200
1172 ***************
1173 *** 184,192 ****
1174 # define SIZEOF_INT 2
1175 # endif
1176 #endif
1177 - #ifdef RISCOS
1178 - # define SIZEOF_INT 4
1179 - #endif
1180
1181
1182 #include "feature.h" /* #defines for optionals and features */
1183 --- 184,189 ----
1184 ***************
1185 *** 340,349 ****
1186 # include "os_mac.h"
1187 #endif
1188
1189 - #ifdef RISCOS
1190 - # include "os_riscos.h"
1191 - #endif
1192 -
1193 #ifdef __QNX__
1194 # include "os_qnx.h"
1195 #endif
1196 --- 337,342 ----
1197 *** ../vim-7.3.186/src/gui_riscos.h 2010-08-15 21:57:28.000000000 +0200
1198 --- src/gui_riscos.h 1970-01-01 01:00:00.000000000 +0100
1199 ***************
1200 *** 1,32 ****
1201 - /* vi:set ts=8 sts=4 sw=4:
1202 - *
1203 - * VIM - Vi IMproved by Bram Moolenaar
1204 - *
1205 - * Do ":help uganda" in Vim to read copying and usage conditions.
1206 - * Do ":help credits" in Vim to see a list of people who contributed.
1207 - */
1208 -
1209 - #define FEAT_BROWSE
1210 -
1211 - #define TASK 0x4b534154
1212 -
1213 - /* Nested wimp flags: */
1214 - #define CHILD_FIX_TO_WORKAREA 0
1215 - #define CHILD_FIX_TO_LEFT 1
1216 - #define CHILD_FIX_TO_BOTTOM 1
1217 - #define CHILD_FIX_TO_RIGHT 2
1218 - #define CHILD_FIX_TO_TOP 2
1219 -
1220 - #define CHILD_SELF_SCROLL 0
1221 - #define CHILD_PARENT_SCROLL 1
1222 -
1223 - #define CHILD_LEFT 16
1224 - #define CHILD_BOTTOM 18
1225 - #define CHILD_RIGHT 20
1226 - #define CHILD_TOP 22
1227 - #define CHILD_SCROLL_X 24
1228 - #define CHILD_SCROLL_Y 26
1229 -
1230 - int wimp_poll(int mask, int *block);
1231 - int wimp_poll_idle(int mask, int *block, int end_time);
1232 - void ro_open_main(int *block);
1233 --- 0 ----
1234 *** ../vim-7.3.186/src/os_riscos.h 2010-08-15 21:57:30.000000000 +0200
1235 --- src/os_riscos.h 1970-01-01 01:00:00.000000000 +0100
1236 ***************
1237 *** 1,166 ****
1238 - /* vi:set ts=8 sts=4 sw=4:
1239 - *
1240 - * VIM - Vi IMproved by Bram Moolenaar
1241 - *
1242 - * Do ":help uganda" in Vim to read copying and usage conditions.
1243 - * Do ":help credits" in Vim to see a list of people who contributed.
1244 - */
1245 -
1246 - #include <sys/types.h>
1247 - #include <sys/stat.h>
1248 - #include <sys/ioctl.h>
1249 - #include <termios.h>
1250 - #include <stdlib.h>
1251 - #include <unixlib/local.h>
1252 - #include <errno.h>
1253 - #include <fcntl.h>
1254 -
1255 - #define CASE_INSENSITIVE_FILENAME
1256 - #define FEAT_MODIFY_FNAME
1257 - #define FEAT_OSFILETYPE
1258 - #define DFLT_OFT "Text"
1259 - #define USE_TERM_CONSOLE
1260 - #define HAVE_AVAIL_MEM
1261 -
1262 - /* Longer filenames now accessible to all */
1263 - #ifndef BASENAMELEN
1264 - # define BASENAMELEN 64 /* Same length as unzip */
1265 - #endif
1266 -
1267 - #ifndef TEMNAME
1268 - # define TEMPNAME "<Wimp$ScrapDir>.v?XXXXXX"
1269 - # define TEMPNAMELEN 25
1270 - #endif
1271 -
1272 - #ifndef DFLT_HELPFILE
1273 - # define DFLT_HELPFILE "Vim:doc.help"
1274 - #endif
1275 -
1276 - #ifndef DFLT_BDIR
1277 - # define DFLT_BDIR ".,<Wimp$ScrapDir>." /* default for 'backupdir' */
1278 - #endif
1279 -
1280 - /* Paths to try putting swap file in. */
1281 - #ifndef DFLT_DIR
1282 - # define DFLT_DIR "<Wimp$ScrapDir>.,." /* default for 'directory' */
1283 - #endif
1284 -
1285 - #ifndef DFLT_VDIR
1286 - # define DFLT_VDIR "Choices:Vim.view" /* default for 'viewdir' */
1287 - #endif
1288 -
1289 - #ifndef TERMCAPFILE
1290 - # define TERMCAPFILE "Vim:TermCap"
1291 - #endif
1292 - #define HAVE_TGETENT
1293 -
1294 - #ifndef SYNTAX_FNAME
1295 - # define SYNTAX_FNAME "Vim:Syntax.%s"
1296 - #endif
1297 -
1298 - #ifndef EVIM_FILE
1299 - # define EVIM_FILE "Vim:Evim"
1300 - #endif
1301 -
1302 - #define FEAT_VIMINFO
1303 -
1304 - #ifndef VIMINFO_FILE
1305 - # define VIMINFO_FILE "<Choices$Write>.Vim.VimInfo"
1306 - #endif
1307 - #ifndef VIMINFO_FILE2
1308 - # define VIMINFO_FILE2 "Choices:Vim.VimInfo"
1309 - #endif
1310 -
1311 - #ifndef VIMRC_FILE
1312 - # define VIMRC_FILE "/vimrc"
1313 - #endif
1314 - #ifndef EXRC_FILE
1315 - # define EXRC_FILE "/exrc"
1316 - #endif
1317 - #ifndef GVIMRC_FILE
1318 - # define GVIMRC_FILE "/gvimrc"
1319 - #endif
1320 - #ifndef USR_VIMRC_FILE
1321 - # define USR_VIMRC_FILE "Vim:Evim"
1322 - #endif
1323 - #ifndef SESSION_FILE
1324 - # define SESSION_FILE "/Session.vim"
1325 - #endif
1326 - #ifndef USR_VIMRC_FILE
1327 - # define USR_VIMRC_FILE "Choices:Vim.VimRC"
1328 - #endif
1329 - #ifndef USR_GVIMRC_FILE
1330 - # define USR_GVIMRC_FILE "Choices:Vim.GVimRC"
1331 - #endif
1332 - #ifndef USR_EXRC_FILE
1333 - # define USR_EXRC_FILE "Choices:Vim.ExRC"
1334 - #endif
1335 - #ifndef SYS_VIMRC_FILE
1336 - # define SYS_VIMRC_FILE "Vim:VimRC"
1337 - #endif
1338 - #ifndef SYS_GVIMRC_FILE
1339 - # define SYS_GVIMRC_FILE "Vim:GVimRC"
1340 - #endif
1341 - #ifndef SYS_MENU_FILE
1342 - # define SYS_MENU_FILE "Vim:Menu"
1343 - #endif
1344 - #ifndef SYS_OPTWIN_FILE
1345 - # define SYS_OPTWIN_FILE "Vim:Optwin"
1346 - #endif
1347 - #ifndef FILETYPE_FILE
1348 - # define FILETYPE_FILE "Vim:Filetype"
1349 - #endif
1350 - #ifndef FTPLUGIN_FILE
1351 - # define FTPLUGIN_FILE "Vim:Ftplugin/vim"
1352 - #endif
1353 - #ifndef INDENT_FILE
1354 - # define INDENT_FILE "Vim:Indent/vim"
1355 - #endif
1356 - #ifndef FTOFF_FILE
1357 - # define FTOFF_FILE "Vim:Ftoff"
1358 - #endif
1359 - #ifndef FTPLUGOF_FILE
1360 - # define FTPLUGOF_FILE "Vim:Ftplugof"
1361 - #endif
1362 - #ifndef INDOFF_FILE
1363 - # define INDOFF_FILE "Vim:Indoff"
1364 - #endif
1365 -
1366 - #define DFLT_ERRORFILE "errors/vim"
1367 - #define DFLT_RUNTIMEPATH "Choices:Vim,Vim:,Choices:Vim.after"
1368 -
1369 - /*
1370 - * RISC PCs have plenty of memory, use large buffers
1371 - */
1372 - #define CMDBUFFSIZE 1024 /* size of the command processing buffer */
1373 - #define MAXPATHL 256 /* paths are always quite short though */
1374 -
1375 - #ifndef DFLT_MAXMEM
1376 - # define DFLT_MAXMEM (5*1024) /* use up to 5 Mbyte for a buffer */
1377 - #endif
1378 -
1379 - #ifndef DFLT_MAXMEMTOT
1380 - # define DFLT_MAXMEMTOT (10*1024) /* use up to 10 Mbyte for Vim */
1381 - #endif
1382 -
1383 - #ifdef HAVE_SIGSET
1384 - # define signal sigset
1385 - #endif
1386 -
1387 - #define n_flag (1<<31)
1388 - #define z_flag (1<<30)
1389 - #define c_flag (1<<29)
1390 - #define v_flag (1<<28)
1391 -
1392 - /* These take r0-r7 as inputs, returns r0-r7 in global variables. */
1393 - void swi(int swinum, ...); /* Handles errors itself */
1394 - int xswi(int swinum, ...); /* Returns errors using v flag */
1395 - extern int r0, r1, r2, r3, r4, r5, r6, r7; /* For return values */
1396 -
1397 - #include <kernel.h>
1398 - #include <swis.h>
1399 -
1400 - #define mch_memmove(to, from, len) memmove((char *)(to), (char *)(from), len)
1401 - #define mch_rename(src, dst) rename(src, dst)
1402 - #define mch_getenv(x) (char_u *)getenv((char *)x)
1403 - #define mch_setenv(name, val, x) setenv(name, val, x)
1404 --- 0 ----
1405 *** ../vim-7.3.186/src/gui_riscos.c 2011-05-10 15:52:10.000000000 +0200
1406 --- src/gui_riscos.c 1970-01-01 01:00:00.000000000 +0100
1407 ***************
1408 *** 1,3558 ****
1409 - /* vi:set ts=8 sts=4 sw=4:
1410 - *
1411 - * VIM - Vi IMproved by Bram Moolenaar
1412 - *
1413 - * Do ":help uganda" in Vim to read copying and usage conditions.
1414 - * Do ":help credits" in Vim to see a list of people who contributed.
1415 - * See README.txt for an overview of the Vim source code.
1416 - */
1417 -
1418 - #include "vim.h"
1419 - #include <string.h>
1420 -
1421 - /*
1422 - * gui_riscos.c
1423 - *
1424 - * Thomas Leonard <tal197@ecs.soton.ac.uk>
1425 - * Updated by Andy Wingate <andy@sparse.net>
1426 - */
1427 -
1428 - extern int time_of_last_poll;
1429 -
1430 - int task_handle = 0; /* Zero means we are not yet a Wimp task */
1431 - int child_handle = 0; /* Task handle of our child process (zero if none). */
1432 - int *wimp_menu = (int *) -1; /* Pointer to a Wimp menu structure (or -1) */
1433 - int save_window = -1; /* Save As window handle */
1434 -
1435 - int *redraw_block = NULL; /* NULL means not in a redraw loop. */
1436 - int ro_return_early = FALSE; /* Break out of gui_mch_wait_for_chars() */
1437 -
1438 - int leaf_ref = 0; /* Wimp message number - send via Wimp$Scrap */
1439 - char_u *leaf_name = NULL; /* Leaf name from DataSave */
1440 -
1441 - int default_columns = 120; /* These values are used if the --rows and --columns */
1442 - int default_rows = 32; /* options aren't used on startup. */
1443 -
1444 - #define DRAG_FALSE 0
1445 - #define DRAG_SELECTION 1
1446 - #define DRAG_RESIZE_WINDOW 2
1447 - int ro_dragging = DRAG_FALSE;
1448 - int drag_button;
1449 - int drag_modifiers;
1450 - int drag_x_offset;
1451 - int drag_y_offset;
1452 -
1453 - int nested_wimp = FALSE; /* Bool - can we use the new wimp? */
1454 -
1455 - int changed_mode = FALSE;
1456 - int x_eigen_factor;
1457 - int y_eigen_factor;
1458 -
1459 - /* If ro_current_font is non-zero then use the outline font with that handle,
1460 - * otherwise, if zap_redraw is TRUE then use ZapRedraw, otherwise use the
1461 - * system font.
1462 - *
1463 - * If zap_redraw is TRUE then zap_file[] contains valid Zap font file
1464 - * pointers (or NULLs).
1465 - */
1466 - int ro_current_font = 0; /* 0 is system font, or ZapRedraw */
1467 - int font_x_offset = 0; /* Where to position each char in its box */
1468 - int font_y_offset = 0;
1469 -
1470 - int zap_redraw = FALSE;
1471 - int double_height = FALSE; /* Plot each line twice? */
1472 -
1473 - #define grgb(r,g,b) ((b<<16) + (g<<8) + (r))
1474 - #define UNUSED_COLOUR (gui.back_pixel)
1475 -
1476 - #define RO_LOAD_CLIPBOARD -2 /* Internal handle for DataSave message. */
1477 -
1478 - /* Changes by John Kortink, 22-23 July 1998
1479 - *
1480 - * Stuff to make redraw a lot faster. Almost all of it is right here below,
1481 - * elsewhere changes are marked with 'JK230798'. Apart from a small change in
1482 - * 'gui.c' all changes are limited to this file, 'gui_riscos.c'. The change in
1483 - * 'gui.c' is to make Vim stop being 'smart' not redrawing characters that are
1484 - * 'already there' (i.e. from the previous line, by coincidence). This caused a
1485 - * lot more calls to the redraw code, which we want to avoid because a few nice
1486 - * big strings at a time is a lot faster than a truckload of small ones. ('Dear
1487 - * Bram ...').
1488 - */
1489 -
1490 - /* The ZapRedraw structure */
1491 -
1492 - static struct
1493 - {
1494 - int r_flags;
1495 - int r_minx;
1496 - int r_miny;
1497 - int r_maxx;
1498 - int r_maxy;
1499 - int r_screen;
1500 - int r_bpl;
1501 - int r_bpp;
1502 - int r_charw;
1503 - int r_charh;
1504 - char *r_caddr;
1505 - int r_cbpl;
1506 - int r_cbpc;
1507 - int r_linesp;
1508 - int r_data;
1509 - int r_scrollx;
1510 - int r_scrolly;
1511 - int *r_palette;
1512 - int r_for;
1513 - int r_bac;
1514 - char *r_workarea;
1515 - int r_magx;
1516 - int r_magy;
1517 - int r_xsize;
1518 - int r_ysize;
1519 - int r_mode;
1520 - }
1521 - zap_redraw_block;
1522 -
1523 - /* Other globals */
1524 -
1525 - static int zap_redraw_initialised = FALSE;
1526 - static int zap_redraw_update_colours;
1527 - static int zap_redraw_colours[2];
1528 - static int zap_redraw_palette[16];
1529 -
1530 - /* Holds the current Zap font file(s).
1531 - * The font is recreated from this block on a mode change.
1532 - * When using zap, element ZAP_NORMAL is always valid, but
1533 - * the others can be NULL.
1534 - */
1535 -
1536 - #define ZAP_NORMAL 0
1537 - #define ZAP_BOLD 1
1538 - #define ZAP_ITALIC 2
1539 - #define ZAP_BITALIC 3
1540 - #define ZAP_STYLES 4
1541 -
1542 - /* Zap font file format data */
1543 - static char *zap_file[ZAP_STYLES] = {NULL, NULL, NULL, NULL};
1544 -
1545 - /* r_caddr format for current mode */
1546 - static char *zap_caddr[ZAP_STYLES] = {NULL, NULL, NULL, NULL};
1547 -
1548 - static void ro_remove_menu(int *menu);
1549 -
1550 - /*
1551 - * Initialise all the ZapRedraw stuff.
1552 - * Call this when changing font and after each mode change.
1553 - * zap_redraw_bitmap must contain a valid Zap font file (possibly
1554 - * created from the system font).
1555 - *
1556 - * Return FAIL to revert to system font (if we can't use ZapRedraw).
1557 - */
1558 - int
1559 - ro_zap_redraw_initialise()
1560 - {
1561 - int bytes_per_bitmap_char;
1562 - int first, last;
1563 - int i;
1564 -
1565 - /* Can't have initialisers for struct members :-(, ok, this way then ... */
1566 - if (!zap_redraw_initialised)
1567 - {
1568 - zap_redraw_block.r_workarea = NULL;
1569 - zap_redraw_initialised = TRUE;
1570 - }
1571 -
1572 - /* We redraw in DSA mode */
1573 - zap_redraw_block.r_flags = 0x0;
1574 -
1575 - /* Let ZapRedraw get the screen address for us */
1576 - zap_redraw_block.r_screen = 0;
1577 -
1578 - /* Read the font width and height from the font file header.
1579 - * Assume that all styles are the same size.
1580 - * ZAP_NORMAL is always present.
1581 - */
1582 - zap_redraw_block.r_charw = ((int *) zap_file[ZAP_NORMAL])[2];
1583 - zap_redraw_block.r_charh = ((int *) zap_file[ZAP_NORMAL])[3];
1584 -
1585 - /* We have no linespacing */
1586 - zap_redraw_block.r_linesp = 0;
1587 -
1588 - /* Fix foreground = colour 1 */
1589 - zap_redraw_block.r_for = 1;
1590 -
1591 - /* Fix background = colour 0 */
1592 - zap_redraw_block.r_bac = 0;
1593 -
1594 - /* Colour mask buffer */
1595 - zap_redraw_block.r_palette = zap_redraw_palette;
1596 -
1597 - /* Allocate local workspace (for the few calls following here) */
1598 - if (zap_redraw_block.r_workarea != NULL)
1599 - free(zap_redraw_block.r_workarea);
1600 - zap_redraw_block.r_workarea = (char*) malloc(128);
1601 - if (!zap_redraw_block.r_workarea)
1602 - return FAIL; /* Out of memory */
1603 -
1604 - /* Fill in VDU variables */
1605 - if (xswi(ZapRedraw_ReadVduVars, 0, &zap_redraw_block) & v_flag)
1606 - return FAIL; /* Can't find ZapRedraw module - use VDU instead */
1607 -
1608 - /* Determine cbpl and cbpc */
1609 - swi(ZapRedraw_CachedCharSize, zap_redraw_block.r_bpp, 0,
1610 - zap_redraw_block.r_charw, zap_redraw_block.r_charh);
1611 - zap_redraw_block.r_cbpl = r2;
1612 - zap_redraw_block.r_cbpc = r3;
1613 -
1614 - /* Allocate general workspace (for the calls outside) */
1615 - if (zap_redraw_block.r_workarea != NULL)
1616 - free(zap_redraw_block.r_workarea);
1617 - zap_redraw_block.r_workarea = (char*) malloc(128 + zap_redraw_block.r_cbpl);
1618 - if (!zap_redraw_block.r_workarea)
1619 - return FAIL; /* Out of memory */
1620 -
1621 - /* Now convert the 1 bpp character data ready for the current mode */
1622 -
1623 - bytes_per_bitmap_char = (zap_redraw_block.r_charw * zap_redraw_block.r_charh + 7) / 8;
1624 -
1625 - /* Convert the fonts from 1bpp to a format suitable for the
1626 - * current mode.
1627 - */
1628 - for (i = 0; i < ZAP_STYLES; i++)
1629 - {
1630 - first = ((int *) zap_file[i])[4];
1631 - last = ((int *) zap_file[i])[5];
1632 -
1633 - if (last > 255)
1634 - last = 255; /* Don't convert cursors (overwrites memory!) */
1635 -
1636 - /* Allocate the font cache */
1637 - vim_free(zap_caddr[i]);
1638 - if (zap_file[i])
1639 - zap_caddr[i] = (char*) malloc(zap_redraw_block.r_cbpc * 256);
1640 - else
1641 - zap_caddr[i] = NULL; /* No file for this style */
1642 -
1643 - if (zap_caddr[i])
1644 - {
1645 - zap_redraw_block.r_caddr = zap_caddr[i];
1646 -
1647 - swi(ZapRedraw_ConvertBitmap, 0, &zap_redraw_block,
1648 - first, last, /* Range of characters to convert */
1649 - zap_file[i] + 0x20 /* Addr of first char provided by font */
1650 - - first * bytes_per_bitmap_char);
1651 - }
1652 - }
1653 -
1654 - if (!zap_caddr[ZAP_NORMAL])
1655 - {
1656 - zap_redraw = FALSE; /* Out of memory */
1657 - return FAIL;
1658 - }
1659 -
1660 - /* Next time we need them, we have to update the colour masks */
1661 - zap_redraw_update_colours = TRUE;
1662 -
1663 - return OK;
1664 - }
1665 -
1666 - /*
1667 - * Redraw a string at OS coordinates <x,y> (top-left, x inclusive, y exclusive).
1668 - * Graphics clip window is window[0..3] as in R1+28..40 of Wimp_RedrawWindow.
1669 - * Returns (possibly modified) flags.
1670 - */
1671 - int
1672 - ro_zap_redraw_draw_string(x, y, string, length, flags, clip)
1673 - int x;
1674 - int y;
1675 - char *string;
1676 - int length;
1677 - int flags; /* DRAW_TRANSP, DRAW_BOLD, DRAW_UNDERL, DRAW_ITALIC */
1678 - int *clip;
1679 - {
1680 - char redraw_data[1024];
1681 - int clip_minx;
1682 - int clip_miny;
1683 - int clip_maxx;
1684 - int clip_maxy;
1685 - int os_xshift = zap_redraw_block.r_magx;
1686 - int os_yshift = zap_redraw_block.r_magy;
1687 -
1688 - if (flags & DRAW_TRANSP)
1689 - return flags; /* We don't do transparent plotting yet. */
1690 -
1691 - if (flags & DRAW_BOLD)
1692 - {
1693 - if (flags & DRAW_ITALIC && zap_caddr[ZAP_BITALIC])
1694 - zap_redraw_block.r_caddr = zap_caddr[ZAP_BITALIC];
1695 - else
1696 - zap_redraw_block.r_caddr = zap_caddr[ZAP_BOLD];
1697 - }
1698 - else
1699 - {
1700 - if (flags & DRAW_ITALIC)
1701 - zap_redraw_block.r_caddr = zap_caddr[ZAP_ITALIC];
1702 - else
1703 - zap_redraw_block.r_caddr = zap_caddr[ZAP_NORMAL];
1704 - }
1705 - if (!zap_redraw_block.r_caddr)
1706 - {
1707 - zap_redraw_block.r_caddr = zap_caddr[ZAP_NORMAL];
1708 - flags |= DRAW_UNDERL; /* Style missing - we can always underline */
1709 - }
1710 -
1711 - /* Set the vertical scaling flag */
1712 - if (double_height)
1713 - zap_redraw_block.r_flags = 1 << 1;
1714 - else
1715 - zap_redraw_block.r_flags = 0;
1716 -
1717 - /* Update the colour masks (if needed) */
1718 - if (zap_redraw_update_colours)
1719 - {
1720 - swi(ZapRedraw_CreatePalette, 2,
1721 - &zap_redraw_block,
1722 - zap_redraw_colours,
1723 - zap_redraw_block.r_palette, 2);
1724 - zap_redraw_update_colours = FALSE;
1725 - }
1726 -
1727 - /* Target rectangle in ZapRedraw rectangle coordinates (pixels, Y-min/max reversed !!!) */
1728 - zap_redraw_block.r_minx = x >> os_xshift; /* inclusive */
1729 - zap_redraw_block.r_miny = zap_redraw_block.r_ysize - (y >> os_yshift); /* inclusive */
1730 - zap_redraw_block.r_maxx = (x + length * gui.char_width) >> os_xshift; /* exclusive */
1731 - zap_redraw_block.r_maxy = zap_redraw_block.r_ysize - ((y - gui.char_height) >> os_yshift);
1732 - /* exclusive */
1733 -
1734 - /* Clip rectangle in ZapRedraw rectangle coordinates (pixels, Y-min/max reversed !!!) */
1735 - clip_minx = clip[0] >> os_xshift; /* inclusive */
1736 - clip_miny = zap_redraw_block.r_ysize - (clip[3] >> os_yshift); /* inclusive */
1737 - clip_maxx = clip[2] >> os_xshift; /* exclusive */
1738 - clip_maxy = zap_redraw_block.r_ysize - (clip[1] >> os_yshift); /* exclusive */
1739 -
1740 - /* Clip target rectangle against the current graphics window */
1741 - if (zap_redraw_block.r_minx < clip_minx)
1742 - {
1743 - zap_redraw_block.r_scrollx = clip_minx - zap_redraw_block.r_minx;
1744 - zap_redraw_block.r_minx = clip_minx;
1745 - }
1746 - else
1747 - zap_redraw_block.r_scrollx = 0;
1748 - if (zap_redraw_block.r_miny < clip_miny)
1749 - {
1750 - zap_redraw_block.r_scrolly = clip_miny - zap_redraw_block.r_miny;
1751 - zap_redraw_block.r_miny = clip_miny;
1752 - }
1753 - else
1754 - zap_redraw_block.r_scrolly = 0;
1755 - if (zap_redraw_block.r_maxx > clip_maxx)
1756 - zap_redraw_block.r_maxx = clip_maxx;
1757 - if (zap_redraw_block.r_maxy > clip_maxy)
1758 - zap_redraw_block.r_maxy = clip_maxy;
1759 -
1760 - /* Fill in the character data structure */
1761 - if (length > (sizeof(redraw_data) - 2 * 4 - 2))
1762 - length = sizeof(redraw_data) - 2 * 4 - 2;
1763 - ((int*) redraw_data)[0] = 2 * 4;
1764 - ((int*) redraw_data)[1] = 0;
1765 - strncpy(redraw_data + 2 * 4, string, length);
1766 - redraw_data[2 * 4 + length + 0] = '\0';
1767 - redraw_data[2 * 4 + length + 1] = '\x2';
1768 - zap_redraw_block.r_data = (int) redraw_data;
1769 -
1770 - /* Perform the draw */
1771 - swi(ZapRedraw_RedrawArea, 0, &zap_redraw_block);
1772 -
1773 - return flags;
1774 - }
1775 -
1776 - /*
1777 - * Okay that was it from me, back to Thomas ...
1778 - */
1779 -
1780 - /*
1781 - * Parse the GUI related command-line arguments. Any arguments used are
1782 - * deleted from argv, and *argc is decremented accordingly. This is called
1783 - * when vim is started, whether or not the GUI has been started.
1784 - */
1785 - void
1786 - gui_mch_prepare(int *argc, char **argv)
1787 - {
1788 - int arg = 1;
1789 -
1790 - while (arg < *argc - 1)
1791 - {
1792 - if (strcmp(argv[arg], "--rows") == 0 || strcmp(argv[arg], "--columns") == 0)
1793 - {
1794 - int value;
1795 -
1796 - value = atoi(argv[arg + 1]);
1797 -
1798 - if (argv[arg][2] == 'r')
1799 - default_rows = value;
1800 - else
1801 - default_columns = value;
1802 -
1803 - /* Delete argument from argv[]. (hope this is read/write!) */
1804 -
1805 - *argc -= 2;
1806 - if (*argc > arg)
1807 - mch_memmove(&argv[arg], &argv[arg + 2], (*argc - arg)
1808 - * sizeof(char *));
1809 - }
1810 - else
1811 - arg++;
1812 - }
1813 - }
1814 -
1815 - /* Fatal error on initialisation - report it and die. */
1816 - void
1817 - ro_die(error)
1818 - char_u *error; /* RISC OS error block */
1819 - {
1820 - swi(Wimp_ReportError, error, 5, "GVim");
1821 - exit(EXIT_FAILURE);
1822 - }
1823 -
1824 - /* Find the sizes of the window tools:
1825 - *
1826 - * Create a test window.
1827 - * Find inner and outer sizes.
1828 - * Find the difference.
1829 - * Delete window.
1830 - *
1831 - * While we're here, find the eigen values too.
1832 - */
1833 - void
1834 - ro_measure_tools()
1835 - {
1836 - int block[10];
1837 - int vdu[] = { 4, 5, -1};
1838 - int test_window[] =
1839 - {
1840 - -100, -100, /* Visible area : min X,Y */
1841 - -50, -50, /* max X,Y */
1842 - 0, 0, /* Scroll offsets */
1843 - -1, /* Window in front */
1844 - 0xd0800150, /* Window flags */
1845 - 0xff070207, /* Colours */
1846 - 0x000c0103, /* More colours */
1847 - 0, -0x4000, /* Workarea extent */
1848 - 0x4000, 0, /* max X,Y */
1849 - 0x00000000, /* No title */
1850 - 0 << 12, /* No workarea button type */
1851 - 1, /* Wimp sprite area */
1852 - 0x00010001, /* Minimum width, height */
1853 - 0, 0, 0, /* Title data (none) */
1854 - 0 /* No icons */
1855 - };
1856 - int inner_max_x, inner_min_y;
1857 -
1858 - swi(Wimp_CreateWindow, 0, test_window);
1859 -
1860 - block[0] = r0;
1861 - /* Open the window (and read state).
1862 - * GetWindowOutline needs it too if the wimp isn't nested.
1863 - */
1864 - swi(Wimp_OpenWindow, 0, block);
1865 - inner_max_x = block[3];
1866 - inner_min_y = block[2];
1867 -
1868 - swi(Wimp_GetWindowOutline, 0, block);
1869 -
1870 - gui.scrollbar_width = block[3] - inner_max_x;
1871 - gui.scrollbar_height = inner_min_y - block[2];
1872 -
1873 - swi(Wimp_DeleteWindow, 0, block);
1874 -
1875 - /* Read the size of one pixel. */
1876 - swi(OS_ReadVduVariables, vdu, vdu);
1877 - x_eigen_factor = vdu[0];
1878 - y_eigen_factor = vdu[1];
1879 - }
1880 -
1881 - /* Load a template from the current templates file.
1882 - * Create the window and return its handle.
1883 - */
1884 - int
1885 - ro_load_template(str_name, title, title_size)
1886 - char_u *str_name; /* Identifier of window in file (max 12 chars) */
1887 - char_u **title; /* If not NULL then return pointer to title here */
1888 - int *title_size; /* If not NULL then return the title length here */
1889 - {
1890 - int *window;
1891 - char *data;
1892 - int name[4];
1893 -
1894 - strcpy( (char *) name, str_name);
1895 -
1896 - /* Find how big we must make the buffers */
1897 -
1898 - if (xswi(Wimp_LoadTemplate, 0, 0, 0, 0, -1, name, 0) & v_flag)
1899 - ro_die( (char *) r0);
1900 -
1901 - window = malloc(r1); /* Don't print text messages from alloc() */
1902 - data = malloc(r2);
1903 - if (window == NULL || data == NULL)
1904 - ro_die("\0\0\0\0Out of memory - Can't load templates");
1905 -
1906 - /* Load the template into the buffers */
1907 -
1908 - swi(Wimp_LoadTemplate, 0,
1909 - window, /* Temp block */
1910 - data, /* Icon data */
1911 - data + r2 + 1, /* End of icon data */
1912 - -1, /* No fonts */
1913 - name, 0); /* First match */
1914 - if (r6 == 0)
1915 - ro_die("\0\0\0\0Can't find window in Templates file");
1916 -
1917 - /* Create the window */
1918 -
1919 - if (xswi(Wimp_CreateWindow, 0, window) & v_flag)
1920 - ro_die( (char *) r0);
1921 -
1922 - if (title)
1923 - *title = (char_u *) window[18];
1924 - if (title_size)
1925 - *title_size = window[20];
1926 -
1927 - free(window); /* Free temp block */
1928 - return r0; /* Return the window handle */
1929 - }
1930 -
1931 - /*
1932 - * Check if the GUI can be started. Called before gvimrc is sourced.
1933 - * Return OK or FAIL.
1934 - */
1935 - int
1936 - gui_mch_init_check()
1937 - {
1938 - return OK; /* TODO: GUI can always be started? */
1939 - }
1940 -
1941 - /*
1942 - * Initialise the RISC OS GUI.
1943 - * Create all the windows.
1944 - * Returns OK for success, FAIL when the GUI can't be started.
1945 - */
1946 - int
1947 - gui_mch_init()
1948 - {
1949 - int messages[] = {
1950 - 1, 2, 3, 4, /* DataSave, DataSaveAck, DataLoad, DataLoadAck */
1951 - 8, /* PreQuit */
1952 - 0xf, /* ClaimEntity (for clipboard) */
1953 - 0x10, /* DataRequest (for clipboard) */
1954 - 0x400c1, /* Mode change */
1955 - 0x400c3, /* TaskCloseDown */
1956 - 0x400c9, /* MenusDeleted */
1957 - 0x808c1, /* TW_Output */
1958 - 0x808c2, /* TW_Ego */
1959 - 0x808c3, /* TW_Morio */
1960 - 0x808c4, /* TW_Morite */
1961 - 0}; /* End-of-list. */
1962 -
1963 -
1964 - /* There may have been some errors reported in the
1965 - * command window before we get here. Wait if so.
1966 - */
1967 - swi(Wimp_ReadSysInfo, 3);
1968 - if (r0 == 0)
1969 - swi(Wimp_CommandWindow, 0); /* Window opened - close with prompt */
1970 -
1971 - if (xswi(Wimp_Initialise, 310, 0x4b534154, "GVim", messages) & v_flag)
1972 - return FAIL;
1973 - nested_wimp = r0 >= 397;
1974 - task_handle = r1;
1975 -
1976 - /* Load the templates. */
1977 -
1978 - if (xswi(Wimp_OpenTemplate, 0, "Vim:Templates") & v_flag)
1979 - ro_die( (char *) r0);
1980 -
1981 - gui.window_handle = ro_load_template("editor",
1982 - &gui.window_title,
1983 - &gui.window_title_size);
1984 -
1985 - save_window = ro_load_template("save", NULL, NULL);
1986 -
1987 - swi(Wimp_CloseTemplate);
1988 -
1989 - /* Set default foreground and background colours. */
1990 -
1991 - gui.norm_pixel = gui.def_norm_pixel;
1992 - gui.back_pixel = gui.def_back_pixel;
1993 -
1994 - /* Get the colours from the "Normal" and "Menu" group (set in syntax.c or
1995 - * in a vimrc file) */
1996 -
1997 - set_normal_colors();
1998 -
1999 - /*
2000 - * Check that none of the colors are the same as the background color
2001 - */
2002 -
2003 - gui_check_colors();
2004 -
2005 - /* Get the colours for the highlight groups (gui_check_colors() might have
2006 - * changed them) */
2007 -
2008 - highlight_gui_started(); /* re-init colours and fonts */
2009 -
2010 - /* Set geometry based on values read on initialisation. */
2011 -
2012 - gui.num_cols = Columns = default_columns;
2013 - gui.num_rows = Rows = default_rows;
2014 -
2015 - /* Get some information about our environment. */
2016 -
2017 - ro_measure_tools();
2018 -
2019 - return OK;
2020 - }
2021 -
2022 - /*
2023 - * Called when the foreground or background colour has been changed.
2024 - */
2025 - void
2026 - gui_mch_new_colors()
2027 - {
2028 - }
2029 -
2030 - /*
2031 - * Open the GUI window which was created by a call to gui_mch_init().
2032 - */
2033 - int
2034 - gui_mch_open(void)
2035 - {
2036 - int block[10];
2037 -
2038 - block[0] = gui.window_handle;
2039 - swi(Wimp_GetWindowState, 0, block);
2040 - block[7] = -1; /* Open at the top of the stack */
2041 - swi(Wimp_OpenWindow, 0, block);
2042 -
2043 - /* Give the new window the input focus */
2044 - swi(Wimp_SetCaretPosition, gui.window_handle, -1, 0, 0, -1, -1);
2045 -
2046 - if (gui_win_x != -1 && gui_win_y != -1)
2047 - gui_mch_set_winpos(gui_win_x, gui_win_y);
2048 -
2049 - return OK;
2050 - }
2051 -
2052 - void
2053 - gui_mch_exit(int rc)
2054 - {
2055 - int block[64];
2056 -
2057 - /* Close window. Stops us from getting troublesome events
2058 - * if we take a while to die.
2059 - */
2060 - block[0] = gui.window_handle;
2061 - swi(Wimp_CloseWindow, 0, block);
2062 -
2063 - if (child_handle)
2064 - {
2065 - /* We still have a sub-task running - kill it */
2066 - block[0] = 20;
2067 - block[3] = 0;
2068 - block[4] = 0; /* Quit */
2069 - if ((xswi(Wimp_SendMessage, 17, block, child_handle) & v_flag) == 0)
2070 - {
2071 - /* Idle until child dies. */
2072 - while (child_handle)
2073 - {
2074 - process_event(wimp_poll(1, block), block);
2075 - }
2076 - }
2077 - }
2078 -
2079 - exit(rc);
2080 - }
2081 -
2082 - /*
2083 - * Get the position of the top left corner of the window.
2084 - */
2085 - int
2086 - gui_mch_get_winpos(int *x, int *y)
2087 - {
2088 - /* TODO */
2089 - return FAIL;
2090 - }
2091 -
2092 - /*
2093 - * Set the position of the top left corner of the window to the given
2094 - * coordinates.
2095 - */
2096 - void
2097 - gui_mch_set_winpos(int x, int y)
2098 - {
2099 - /* TODO */
2100 - }
2101 -
2102 - void
2103 - gui_mch_set_shellsize(width, height, min_width, min_height, base_width, base_height, direction)
2104 - int width; /* In OS units */
2105 - int height;
2106 - int min_width; /* Smallest permissible window size (ignored) */
2107 - int min_height;
2108 - int base_width; /* Space for scroll bars, etc */
2109 - int base_height;
2110 - int direction;
2111 - {
2112 - int s_width, s_height;
2113 - int block[] = {
2114 - gui.window_handle,
2115 - 0,
2116 - -height + 1,
2117 - width,
2118 - 1};
2119 -
2120 - gui_mch_get_screen_dimensions(&s_width, &s_height);
2121 - s_width -= base_width;
2122 - s_height -= base_height; /* Underestimate - ignores titlebar */
2123 -
2124 - swi(Wimp_GetWindowState, 0, block);
2125 - block[3] = block[1] + width;
2126 - block[2] = block[4] - height;
2127 - if (block[3] > s_width)
2128 - {
2129 - block[3] = s_width;
2130 - block[1] = block[3] - width;
2131 - }
2132 - if (block[2] < gui.scrollbar_height)
2133 - {
2134 - block[2] = gui.scrollbar_height;
2135 - block[4] = block[2] + height;
2136 - }
2137 - swi(Wimp_OpenWindow, 0, block);
2138 - swi(Wimp_ForceRedraw, gui.window_handle, 0, -height, width, 0);
2139 - }
2140 -
2141 - void
2142 - gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
2143 - {
2144 - int block[] = {4, 5, 11, 12, -1};
2145 -
2146 - swi(OS_ReadVduVariables, block, block);
2147 - *screen_w = (block[2] + 1) << block[0];
2148 - *screen_h = (block[3] + 1) << block[1];
2149 - }
2150 -
2151 - /* Take a font name with options and return a font handle, or
2152 - * zero for failure.
2153 - * Replace extension with 'Bold' or 'Italic' depending on modifiers.
2154 - */
2155 - int
2156 - ro_get_font(fullname, weight)
2157 - char_u *fullname;
2158 - int weight; /* Initial weights:
2159 - * BIT MEANING
2160 - * 0 bold
2161 - * 1 italic
2162 - */
2163 - {
2164 - char_u *arg;
2165 - char_u font[41];
2166 - int width = -1;
2167 - int height = -1;
2168 - int name_len;
2169 - int i;
2170 - char_u c;
2171 -
2172 - for (i = 0; i < 39;)
2173 - {
2174 - c = fullname[i];
2175 - if (c == ':' || c == NUL || c == '.')
2176 - break;
2177 - font[i++] = c;
2178 - }
2179 -
2180 - /* find the first modifier, NULL if none */
2181 - arg = strchr(fullname + i, ':');
2182 -
2183 - while (arg)
2184 - {
2185 - switch (*++arg)
2186 - {
2187 - case 'h':
2188 - height = strtol(arg + 1, (char **) &arg, 10);
2189 - break;
2190 - case 'w':
2191 - width = strtol(arg + 1, (char **) &arg, 10);
2192 - break;
2193 - case 'b':
2194 - weight |= 1;
2195 - break;
2196 - case 'i':
2197 - weight |= 2;
2198 - break;
2199 - default:
2200 - return 0;
2201 - }
2202 - arg = strchr(arg, ':');
2203 - }
2204 -
2205 - if ((weight & 1) && i < 35)
2206 - {
2207 - /* Bold goes instead of given suffix */
2208 - strncpy(font + i, ".Bold", 5);
2209 - i += 5;
2210 - }
2211 - else
2212 - {
2213 - /* Copy rest of name unless we are using Bold */
2214 - while (i < 39)
2215 - {
2216 - c = fullname[i];
2217 - if (c == ':' || c == NUL)
2218 - break;
2219 - font[i++] = c;
2220 - }
2221 - }
2222 - if ((weight & 2) && i < 32)
2223 - {
2224 - strncpy(font + i, ".Oblique", 8);
2225 - i += 8;
2226 - }
2227 -
2228 - font[i] = 0;
2229 -
2230 - if (height < 1 && width < 1)
2231 - height = width = 10; /* Default to 10pt */
2232 - else if (height < 1)
2233 - height = width;
2234 - else if (width < 1)
2235 - width = height;
2236 -
2237 - if (xswi(Font_FindFont, 0, font, width << 4, height << 4, 0, 0) & v_flag)
2238 - return NOFONT; /* Can't find font */
2239 -
2240 - return r0;
2241 - }
2242 -
2243 - /* Load a file into allocated memory and check it is valid.
2244 - * Return a pointer to the allocated block on success.
2245 - */
2246 - char *
2247 - zap_load_file(name, style)
2248 - char_u *name; /* Name of directory containing styles */
2249 - char_u *style; /* Name of style within directory */
2250 - {
2251 - char_u fname[256];
2252 - char_u *file;
2253 -
2254 - if (strlen(name) + strlen(style) > 254)
2255 - return NULL; /* Names too long */
2256 -
2257 - sprintf(fname, "%s.%s", name, style);
2258 -
2259 - /* Load the named font in 1bpp format. */
2260 - if (xswi(OS_File, 13, fname, 0, 0, "VimFonts:") & v_flag || r0 != 1)
2261 - return NULL; /* Error reading file info, or not a file */
2262 -
2263 - /* Allocate enough memory to load the whole file */
2264 - file = (char *) alloc(r4);
2265 - if (!file)
2266 - return NULL; /* Out of memory */
2267 -
2268 - if (xswi(OS_File, 12, fname, file, 0, "VimFonts:") & v_flag)
2269 - return NULL; /* Unable to load file */
2270 -
2271 - if (strncmp(file, "ZapFont\015", 8) == 0)
2272 - return file; /* Loaded OK! */
2273 -
2274 - vim_free(file);
2275 - return NULL; /* Not a valid font file */
2276 - }
2277 -
2278 - /* Load and convert the named font.
2279 - * If name is NULL or a null string then convert the system font.
2280 - * Return OK on success; FAIL and we revert to using the VDU drivers.
2281 - *
2282 - * 'name' is the name of a directory.
2283 - * Tries to load 'name.0', 'name.B', 'name.I' and 'name.IB'.
2284 - */
2285 - int
2286 - zap_load_font(name)
2287 - char_u *name;
2288 - {
2289 - int i;
2290 -
2291 - /* Free the existing font files, if any */
2292 - for (i = 0; i < ZAP_STYLES; i++)
2293 - {
2294 - vim_free(zap_file[i]);
2295 - zap_file[i] = NULL;
2296 - }
2297 -
2298 - if (name && *name == '!')
2299 - {
2300 - name++;
2301 - double_height = TRUE;
2302 - }
2303 - else
2304 - double_height = FALSE;
2305 -
2306 - if (name && *name)
2307 - {
2308 - zap_file[ZAP_NORMAL] = zap_load_file(name, "0");
2309 - if (!zap_file[ZAP_NORMAL])
2310 - return FAIL; /* Can't load the 'normal' style - error */
2311 -
2312 - zap_file[ZAP_BOLD] = zap_load_file(name, "B");
2313 - zap_file[ZAP_ITALIC] = zap_load_file(name, "I");
2314 - zap_file[ZAP_BITALIC] = zap_load_file(name, "IB");
2315 - }
2316 - else
2317 - {
2318 - int *header;
2319 - char workarea[16];
2320 - char *old_wa;
2321 -
2322 - /* Allocate memory for system font (8 x 8 x 256 bits, plus header) */
2323 - header = (int *) alloc(0x20 + 8 * 256);
2324 - if (header == NULL)
2325 - return FAIL;
2326 - zap_file[ZAP_NORMAL] = (char *) header;
2327 -
2328 - /* Store details about the system font */
2329 - header[2] = 8; /* Width */
2330 - header[3] = 8; /* Height */
2331 - header[4] = 0; /* First char */
2332 - header[5] = 255; /* Last char */
2333 - header[6] = header[7] = 0; /* Reserved */
2334 -
2335 - /* Get system font bitmap */
2336 - old_wa = zap_redraw_block.r_workarea;
2337 - zap_redraw_block.r_workarea = workarea;
2338 - swi(ZapRedraw_ReadSystemChars, zap_file[ZAP_NORMAL] + 0x20, &zap_redraw_block);
2339 - zap_redraw_block.r_workarea = old_wa;
2340 - }
2341 -
2342 - return ro_zap_redraw_initialise();
2343 - }
2344 -
2345 - /*
2346 - * Initialise vim to use the font with the given name.
2347 - * Return FAIL if the font could not be loaded, OK otherwise.
2348 - */
2349 - int
2350 - gui_mch_init_font(char_u *font_name, int fontset)
2351 - {
2352 - int new_handle = 0; /* Use the system font by default */
2353 -
2354 - if (font_name[0] == '!')
2355 - {
2356 - /* Select a ZapRedraw font */
2357 - if (zap_load_font(font_name + 1))
2358 - zap_redraw = TRUE;
2359 - else
2360 - {
2361 - EMSG2(_("E610: Can't load Zap font '%s'"), font_name);
2362 - font_name = "System"; /* Error - use system font */
2363 - zap_redraw = FALSE;
2364 - }
2365 - }
2366 - else
2367 - {
2368 - zap_redraw = FALSE;
2369 -
2370 - if (font_name)
2371 - {
2372 - /* Extract any extra details about the font */
2373 - new_handle = ro_get_font(font_name, 0);
2374 - if (!new_handle)
2375 - return FAIL;
2376 - }
2377 - else
2378 - font_name = "System";
2379 - }
2380 -
2381 - /* Free the previous font, if any */
2382 - gui_mch_free_font(gui.norm_font);
2383 - gui.norm_font = new_handle;
2384 - gui.char_ascent = 0;
2385 -
2386 - if (new_handle)
2387 - {
2388 - /* Read details about the chosen font */
2389 - swi(Font_ReadInfo, new_handle);
2390 -
2391 - gui.char_width = r3 - r1;
2392 - gui.char_height = r4 - r2;
2393 -
2394 - font_x_offset = -r1; /* Where to position each char in its box */
2395 - font_y_offset = -r4;
2396 -
2397 - /* Try to load other fonts for bold, italic, and bold-italic */
2398 - gui_mch_free_font(gui.bold_font);
2399 - gui.bold_font = ro_get_font(font_name, 1);
2400 - gui_mch_free_font(gui.ital_font);
2401 - gui.ital_font = ro_get_font(font_name, 2);
2402 - gui_mch_free_font(gui.boldital_font);
2403 - gui.boldital_font = ro_get_font(font_name, 3);
2404 - }
2405 - else
2406 - {
2407 - /* Use the system font or ZapRedraw. */
2408 - if (zap_redraw)
2409 - {
2410 - gui.char_width = zap_redraw_block.r_charw << zap_redraw_block.r_magx;
2411 - gui.char_height = zap_redraw_block.r_charh << zap_redraw_block.r_magy;
2412 - if (double_height)
2413 - gui.char_height <<= 1;
2414 - }
2415 - else
2416 - {
2417 - gui.char_width = 16;
2418 - gui.char_height = 32;
2419 - }
2420 -
2421 - gui_mch_free_font(gui.bold_font);
2422 - gui.bold_font = 0;
2423 - gui_mch_free_font(gui.ital_font);
2424 - gui.ital_font = 0;
2425 - gui_mch_free_font(gui.boldital_font);
2426 - gui.boldital_font = 0;
2427 - }
2428 - hl_set_font_name(font_name);
2429 -
2430 - must_redraw = CLEAR;
2431 - return OK;
2432 - }
2433 -
2434 - /*
2435 - * Adjust gui.char_height (after 'linespace' was changed).
2436 - */
2437 - int
2438 - gui_mch_adjust_charheight()
2439 - {
2440 - return FAIL;
2441 - }
2442 -
2443 - /*
2444 - * Get a font structure for highlighting.
2445 - */
2446 - GuiFont
2447 - gui_mch_get_font(name, giveErrorIfMissing)
2448 - char_u *name;
2449 - int giveErrorIfMissing;
2450 - {
2451 - int handle;
2452 -
2453 - if (!name)
2454 - return NOFONT; /* System font if no name */
2455 -
2456 - handle = ro_get_font(name, 0);
2457 - if (!handle)
2458 - {
2459 - if (giveErrorIfMissing)
2460 - EMSG2(_("E611: Can't use font %s"), name);
2461 - return NOFONT;
2462 - }
2463 -
2464 - return handle;
2465 - }
2466 -
2467 - #if defined(FEAT_EVAL) || defined(PROTO)
2468 - /*
2469 - * Return the name of font "font" in allocated memory.
2470 - * Don't know how to get the actual name, thus use the provided name.
2471 - */
2472 - char_u *
2473 - gui_mch_get_fontname(font, name)
2474 - GuiFont font;
2475 - char_u *name;
2476 - {
2477 - if (name == NULL)
2478 - return NULL;
2479 - return vim_strsave(name);
2480 - }
2481 - #endif
2482 -
2483 - /*
2484 - * Set the current text font.
2485 - */
2486 - void
2487 - gui_mch_set_font(GuiFont font)
2488 - {
2489 - ro_current_font = font;
2490 -
2491 - if (font)
2492 - {
2493 - /* Not the system font or ZapRedraw font - select it */
2494 - swi(Font_SetFont, font);
2495 - }
2496 - }
2497 -
2498 - /*
2499 - * If a font is not going to be used, free its structure.
2500 - */
2501 - void
2502 - gui_mch_free_font(GuiFont font)
2503 - {
2504 - if (font)
2505 - swi(Font_LoseFont, font);
2506 - }
2507 -
2508 - /*
2509 - * Return the Pixel value (colour) for the given colour name.
2510 - * Return INVALCOLOR for error.
2511 - * NB: I've changed Green for now, since it looked really sick
2512 - */
2513 - guicolor_T
2514 - gui_mch_get_color(char_u *name)
2515 - {
2516 - int i;
2517 - struct colour
2518 - {
2519 - char_u *name;
2520 - guicolor_T value;
2521 - } colours[] =
2522 - {
2523 - { "Red", grgb(255, 0, 0) },
2524 - { "LightRed", grgb(255, 0, 0) },
2525 - { "DarkRed", grgb(139, 0, 0) },
2526 -
2527 - { "Green", grgb(50, 200, 50) },
2528 - { "LightGreen", grgb(144, 238, 144) },
2529 - { "DarkGreen", grgb(0, 100, 0) },
2530 - { "SeaGreen", grgb(46, 139, 87) },
2531 -
2532 - { "Blue", grgb(0, 0, 255) },
2533 - { "LightBlue", grgb(173, 216, 230) },
2534 - { "DarkBlue", grgb(0, 0, 139) },
2535 - { "SlateBlue", grgb(160, 90, 205) },
2536 -
2537 - { "Cyan", grgb(0, 255, 255) },
2538 - { "LightCyan", grgb(224, 255, 255) },
2539 - { "DarkCyan", grgb(0, 139, 139) },
2540 -
2541 - { "Magenta", grgb(255, 0, 255) },
2542 - { "LightMagenta", grgb(255, 224, 255) },
2543 - { "DarkMagenta", grgb(139, 0, 139) },
2544 -
2545 - { "Yellow", grgb(255, 255, 0) },
2546 - { "LightYellow", grgb(255, 255, 224) },
2547 - { "DarkYellow", grgb(139, 139, 0) },
2548 - { "Brown", grgb(165, 42, 42) },
2549 -
2550 - { "Gray", grgb(190, 190, 190) },
2551 - { "Grey", grgb(190, 190, 190) },
2552 - { "LightGray", grgb(211, 211, 211) },
2553 - { "LightGrey", grgb(211, 211, 211) },
2554 - { "DarkGray", grgb(169, 169, 169) },
2555 - { "DarkGrey", grgb(169, 169, 169) },
2556 - { "Gray10", grgb(26, 26, 26) },
2557 - { "Grey10", grgb(26, 26, 26) },
2558 - { "Gray20", grgb(51, 51, 51) },
2559 - { "Grey20", grgb(51, 51, 51) },
2560 - { "Gray30", grgb(77, 77, 77) },
2561 - { "Grey30", grgb(77, 77, 77) },
2562 - { "Gray40", grgb(102, 102, 102) },
2563 - { "Grey40", grgb(102, 102, 102) },
2564 - { "Gray50", grgb(127, 127, 127) },
2565 - { "Grey50", grgb(127, 127, 127) },
2566 - { "Gray60", grgb(153, 153, 153) },
2567 - { "Grey60", grgb(153, 153, 153) },
2568 - { "Gray70", grgb(179, 179, 179) },
2569 - { "Grey70", grgb(179, 179, 179) },
2570 - { "Gray80", grgb(204, 204, 204) },
2571 - { "Grey80", grgb(204, 204, 204) },
2572 - { "Gray90", grgb(229, 229, 229) },
2573 - { "Grey90", grgb(229, 229, 229) },
2574 -
2575 - { "Black", grgb(0, 0, 0) },
2576 - { "White", grgb(255, 255, 255) },
2577 -
2578 - { "Orange", grgb(255, 165, 0) },
2579 - { "Purple", grgb(160, 32, 240) },
2580 - { "Violet", grgb(238, 130, 238) },
2581 - {NULL, 0}
2582 - };
2583 -
2584 - if (name[0] == '#')
2585 - {
2586 - char *end;
2587 - int c;
2588 -
2589 - c = strtol(name + 1, &end, 16);
2590 - return (guicolor_T) ((c >> 16) & 0xff) | (c & 0xff00) | ((c & 0xff) << 16);
2591 - }
2592 -
2593 - for (i = 0; colours[i].name != NULL; i++)
2594 - {
2595 - if (STRICMP(name, colours[i].name) == 0)
2596 - return colours[i].value;
2597 - }
2598 - if (strnicmp(name, "grey", 4) == 0 || strnicmp(name, "gray", 4) == 0)
2599 - {
2600 - int level = (255 * atoi(name + 4)) / 100;
2601 - return (guicolor_T) grgb(level, level, level);
2602 - }
2603 - return INVALCOLOR;
2604 - }
2605 -
2606 - /*
2607 - * Set the current text colours.
2608 - * If we are using fonts then set the antialiasing colours too.
2609 - */
2610 - void
2611 - gui_mch_set_colors(guicolor_T fg, guicolor_T bg)
2612 - {
2613 - zap_redraw_colours[0] = bg << 8; /* JK230798, register new background colour */
2614 - zap_redraw_colours[1] = fg << 8; /* JK230798, register new foreground colour */
2615 - zap_redraw_update_colours = TRUE; /* JK230798, need update of colour masks */
2616 -
2617 - swi(ColourTrans_ReturnGCOL, fg << 8);
2618 - gui.fg_colour = r0;
2619 - swi(ColourTrans_ReturnGCOL, bg << 8);
2620 - gui.bg_colour = r0;
2621 -
2622 - if (ro_current_font)
2623 - swi(ColourTrans_SetFontColours, 0, bg << 8, fg << 8, 14);
2624 - }
2625 -
2626 - void
2627 - ro_draw_string(x, y, s, len, flags, clip)
2628 - int x; /* Top-left coord to plot at (x incl, y excl) */
2629 - int y; /* (screen coords) */
2630 - char_u *s; /* String to plot */
2631 - int len; /* Length of string */
2632 - int flags; /* DRAW_TRANSP, DRAW_BOLD, DRAW_UNDERL */
2633 - int* clip; /* JK230798, added clip window */
2634 - {
2635 - if (ro_current_font)
2636 - {
2637 - int fx;
2638 - int flen = len; /* Preserve for underline */
2639 -
2640 - /* Use the Font manager to paint the string.
2641 - * Must do one char at a time to get monospacing.
2642 - */
2643 -
2644 - if (flags & DRAW_ITALIC && !gui.ital_font)
2645 - flags |= DRAW_UNDERL; /* No italic - underline instead */
2646 -
2647 - if ((flags & DRAW_TRANSP) == 0)
2648 - {
2649 - swi(ColourTrans_SetColour, gui.bg_colour, 0, 0, 0, 0);
2650 - swi(OS_Plot, 4, x, y - gui.char_height);
2651 - swi(OS_Plot, 96 + 5, x + len * gui.char_width - 1, y - 1);
2652 - }
2653 -
2654 - fx = x + font_x_offset;
2655 - while (flen--)
2656 - {
2657 - swi(Font_Paint, 0, s++, 0x90, fx, y + font_y_offset, 0, 0, 1);
2658 - fx += gui.char_width;
2659 - }
2660 - }
2661 - else
2662 - {
2663 - if (zap_redraw)
2664 - {
2665 - /* Using fast Zap redraw. */
2666 - flags = ro_zap_redraw_draw_string(x, y, s, len, flags, clip);
2667 - }
2668 - else
2669 - {
2670 - /* Using the system font */
2671 - if (flags & DRAW_ITALIC)
2672 - flags |= DRAW_UNDERL;
2673 -
2674 - if ((flags & DRAW_TRANSP) == 0)
2675 - {
2676 - swi(ColourTrans_SetColour, gui.bg_colour, 0, 0, 0, 0);
2677 - swi(OS_Plot, 4, x, y - gui.char_height);
2678 - swi(OS_Plot, 96 + 5, x + len * gui.char_width - 1, y - 1);
2679 - }
2680 - swi(OS_Plot, 4, /* Move the drawing cursor */
2681 - x,
2682 - y - 1);
2683 - swi(ColourTrans_SetColour, gui.fg_colour, 0, 0, 0, 0);
2684 - swi(OS_WriteN, s, len);
2685 -
2686 - if (flags & DRAW_BOLD)
2687 - {
2688 - swi(OS_Plot, 4, x + (1 << x_eigen_factor), y - 1);
2689 - swi(OS_WriteN, s, len);
2690 - }
2691 - }
2692 - }
2693 -
2694 - if (flags & DRAW_UNDERL)
2695 - {
2696 - if (ro_current_font || zap_redraw)
2697 - swi(ColourTrans_SetColour, gui.fg_colour, 0, 0, 0, 0);
2698 - /* Underlined is the same with all plotting methods */
2699 - swi(OS_Plot, 4, x, y - gui.char_height);
2700 - swi(OS_Plot, 1, gui.char_width * len, 0);
2701 - }
2702 - }
2703 -
2704 - void
2705 - gui_mch_draw_string(int row, int col, char_u *s, int len, int flags)
2706 - {
2707 - int x, y; /* Workarea x,y */
2708 - x = col * gui.char_width;
2709 - y = -row * gui.char_height;
2710 -
2711 - if (redraw_block)
2712 - {
2713 - ro_draw_string(x + redraw_block[1], y + redraw_block[4],
2714 - s, len, flags, &redraw_block[7]); /* JK230798, added clip window */
2715 - }
2716 - else
2717 - {
2718 - int block[44];
2719 - block[0] = gui.window_handle;
2720 - block[1] = x;
2721 - block[2] = y - gui.char_height;
2722 - block[3] = (col + len) * gui.char_width;
2723 - block[4] = y;
2724 - swi(Wimp_UpdateWindow, 0, block);
2725 - while (r0)
2726 - {
2727 - ro_draw_string(x + block[1], y + block[4],
2728 - s, len, flags, &block[7]); /* JK230798, added clip window */
2729 - swi(Wimp_GetRectangle, 0, block);
2730 - }
2731 - }
2732 - }
2733 -
2734 - /*
2735 - * Return OK if the key with the termcap name "name" is supported.
2736 - */
2737 - int
2738 - gui_mch_haskey(char_u *name)
2739 - {
2740 - return FAIL;
2741 - }
2742 -
2743 - void
2744 - gui_mch_beep(void)
2745 - {
2746 - swi(OS_WriteI + 7);
2747 - }
2748 -
2749 - /*
2750 - * Visual bell.
2751 - */
2752 - void
2753 - gui_mch_flash(int msec)
2754 - {
2755 - /* TODO */
2756 - }
2757 -
2758 -
2759 - /*
2760 - * Plot a solid rectangle using the given plot action and colour.
2761 - * Coordinates are inclusive and window-relative.
2762 - */
2763 - void
2764 - plot_rectangle(plot, colour, minx, miny, maxx, maxy)
2765 - int plot; /* OS_Plot action */
2766 - int colour;
2767 - int minx;
2768 - int miny;
2769 - int maxx;
2770 - int maxy;
2771 - {
2772 - if (redraw_block)
2773 - {
2774 - swi(ColourTrans_SetColour, colour, 0, 0, 0, 0);
2775 - swi(OS_Plot, 4, minx + redraw_block[1], miny + redraw_block[4]);
2776 - swi(OS_Plot, plot, maxx + redraw_block[1], maxy + redraw_block[4]);
2777 - }
2778 - else
2779 - {
2780 - int block[44];
2781 - block[0] = gui.window_handle;
2782 - block[1] = minx;
2783 - block[2] = miny;
2784 - block[3] = maxx + 1;
2785 - block[4] = maxy + 1;
2786 - swi(Wimp_UpdateWindow, 0, block);
2787 - while (r0)
2788 - {
2789 - swi(ColourTrans_SetColour, colour, 0, 0, 0, 0);
2790 - swi(OS_Plot, 4, minx + block[1], miny + block[4]);
2791 - swi(OS_Plot, plot, maxx + block[1], maxy + block[4]);
2792 - swi(Wimp_GetRectangle, 0, block);
2793 - }
2794 - }
2795 - }
2796 -
2797 - /*
2798 - * Invert a rectangle from row r, column c, for nr rows and nc columns.
2799 - */
2800 - void
2801 - gui_mch_invert_rectangle(int r, int c, int nr, int nc)
2802 - {
2803 - plot_rectangle(96 + 6, 0, FILL_X(c), -FILL_Y(r + nr), FILL_X(c + nc), -FILL_Y(r));
2804 - }
2805 -
2806 - /*
2807 - * Iconify the GUI window.
2808 - */
2809 - void
2810 - gui_mch_iconify(void)
2811 - {
2812 - }
2813 -
2814 - #if defined(FEAT_EVAL) || defined(PROTO)
2815 - /*
2816 - * Bring the Vim window to the foreground.
2817 - */
2818 - void
2819 - gui_mch_set_foreground()
2820 - {
2821 - /* TODO */
2822 - }
2823 - #endif
2824 -
2825 - /* Draw a hollow rectangle relative to the current
2826 - * graphics cursor position, with the given width
2827 - * and height. Start position is top-left.
2828 - */
2829 - void
2830 - draw_hollow(w, h)
2831 - int w;
2832 - int h;
2833 - {
2834 - swi(OS_Plot, 1, w - 1, 0);
2835 - swi(OS_Plot, 1, 0, 1 - h);
2836 - swi(OS_Plot, 1, 1 - w, 0);
2837 - swi(OS_Plot, 1, 0, h - 1);
2838 - }
2839 -
2840 - /*
2841 - * Draw a cursor without focus.
2842 - */
2843 - void
2844 - gui_mch_draw_hollow_cursor(guicolor_T colour)
2845 - {
2846 - int x = FILL_X(gui.cursor_col); /* Window relative, top-left */
2847 - int y = -FILL_Y(gui.cursor_row);
2848 - if (redraw_block == NULL)
2849 - {
2850 - int block[11];
2851 -
2852 - block[0] = gui.window_handle;
2853 - block[1] = x;
2854 - block[2] = y - gui.char_height;
2855 - block[3] = x + gui.char_width;
2856 - block[4] = y;
2857 - swi(Wimp_UpdateWindow, 0, block);
2858 - while (r0)
2859 - {
2860 - swi(ColourTrans_SetGCOL, colour << 8, 0, 0, 0, 0);
2861 -
2862 - swi(OS_Plot, 4, x + block[1], y + block[4] - 1);
2863 - draw_hollow(gui.char_width, gui.char_height);
2864 -
2865 - swi(Wimp_GetRectangle, 0, block);
2866 - }
2867 - }
2868 - else
2869 - {
2870 - swi(ColourTrans_SetGCOL, colour << 8, 0, 0, 0, 0);
2871 -
2872 - swi(OS_Plot, 4, x + redraw_block[1], y + redraw_block[4] - 1);
2873 - draw_hollow(gui.char_width, gui.char_height);
2874 - }
2875 - }
2876 -
2877 - /*
2878 - * Draw part of a cursor, "w" pixels wide, and "h" pixels high, using
2879 - * color "color".
2880 - */
2881 - void
2882 - gui_mch_draw_part_cursor(w, h, colour)
2883 - int w;
2884 - int h;
2885 - guicolor_T colour;
2886 - {
2887 - int x = FILL_X(gui.cursor_col);
2888 - int y = -FILL_Y(gui.cursor_row);
2889 - swi(ColourTrans_ReturnGCOL, colour << 8);
2890 - plot_rectangle(96 + 5, r0, x, y - h, x + w - 1, y - 1);
2891 - }
2892 -
2893 - /*
2894 - * Catch up with any queued events. This may put keyboard input into the
2895 - * input buffer, call resize call-backs, trigger timers etc.
2896 - * If there is nothing in the event queue(& no timers pending), then we return
2897 - * immediately (well, after a Wimp_Poll).
2898 - */
2899 - void
2900 - gui_mch_update(void)
2901 - {
2902 - int block[64];
2903 - int reason;
2904 -
2905 - swi(OS_ReadMonotonicTime);
2906 - if ((r0 - time_of_last_poll) < 50)
2907 - return; /* Don't return too often */
2908 -
2909 - reason = wimp_poll(0, block);
2910 - if (reason)
2911 - process_event(reason, block);
2912 - ro_return_early = FALSE; /* We're returning anyway. */
2913 - }
2914 -
2915 - void
2916 - redraw_window(block)
2917 - int *block;
2918 - {
2919 - int x, y; /* Vim workarea coords */
2920 - int width, height;
2921 - int blank_col;
2922 -
2923 - swi(ColourTrans_ReturnGCOL, UNUSED_COLOUR << 8, 0, 0, 1<<7, 0);
2924 - blank_col = r0;
2925 -
2926 - swi(Wimp_RedrawWindow, 0, block);
2927 - redraw_block = block;
2928 - while (r0)
2929 - {
2930 - x = block[7] - block[1];
2931 - y = block[4] - block[10];
2932 - width = block[9] - block[7];
2933 - height = block[10] - block[8];
2934 -
2935 - if (height + y > Rows * gui.char_height)
2936 - {
2937 - /* Blank everything off the bottom. */
2938 - plot_rectangle(96 + 5, blank_col,
2939 - 0, block[8] - block[4],
2940 - block[9] - block[1], -FILL_Y(Rows) - 1);
2941 - height = Rows * gui.char_height;
2942 - }
2943 - if (width + x> Columns * gui.char_width)
2944 - {
2945 - /* Blank everything off to the right. */
2946 - plot_rectangle(96 + 5, blank_col,
2947 - FILL_X(Columns), block[8] - block[4],
2948 - block[9] - block[1], 0);
2949 - width = Columns * gui.char_width;
2950 - }
2951 - gui_redraw(x , y, width, height);
2952 - swi(Wimp_GetRectangle, 0, block);
2953 - }
2954 - redraw_block = NULL;
2955 - }
2956 -
2957 - /* Check if we have modified data.
2958 - * If we do then ack the message to stop the shutdown.
2959 - * Otherwise, ignore the message.
2960 - */
2961 - void
2962 - ro_prequit(block)
2963 - int *block;
2964 - {
2965 - if (!ro_ok_to_quit())
2966 - {
2967 - /* Not OK to quit - stop shutdown */
2968 - block[3] = block[2];
2969 - swi(Wimp_SendMessage, 19, block, block[1]);
2970 - }
2971 - /* Do nothing. We may get a Message_Quit later. */
2972 - }
2973 -
2974 - /* If there is unsaved data then ask the user if they mind losing it.
2975 - * Return TRUE if we can quit without saving, FALSE to halt the
2976 - * shutdown.
2977 - */
2978 - int
2979 - ro_ok_to_quit()
2980 - {
2981 - int old_confirm = cmdmod.confirm;
2982 -
2983 - cmdmod.confirm = FALSE; /* Use our own, single tasking, box */
2984 -
2985 - if (check_changed_any(FALSE))
2986 - {
2987 - swi(Wimp_ReportError,
2988 - "\0\0\0\0Vim contains unsaved data - quit anyway?",
2989 - 0x17,
2990 - "Vim");
2991 - cmdmod.confirm = old_confirm;
2992 - if (r1 != 1)
2993 - return FALSE;
2994 - }
2995 - cmdmod.confirm = old_confirm;
2996 - return TRUE;
2997 - }
2998 -
2999 - /* Quit without checking for unsaved data. */
3000 - void
3001 - ro_quit()
3002 - {
3003 - exiting = TRUE;
3004 - getout(0);
3005 -
3006 - exiting = FALSE; /* probably can't get here */
3007 - setcursor(); /* position cursor */
3008 - out_flush();
3009 - }
3010 -
3011 - /* Insent the given vim special code into the input buffer */
3012 - void
3013 - ro_press(a, b, modifier)
3014 - char a;
3015 - char b;
3016 - int modifier; /* %<Ctrl><Shift> 0000 0000 */
3017 - {
3018 - char_u buf[6];
3019 - int vim_mod;
3020 - int key;
3021 -
3022 -
3023 - /* Convert RISC OS modifier to Vim modifier. */
3024 - vim_mod = ((modifier & 0x10) ? MOD_MASK_SHIFT : 0)
3025 - | ((modifier & 0x20) ? MOD_MASK_CTRL : 0);
3026 - key = simplify_key(TERMCAP2KEY(a, b), &vim_mod);
3027 -
3028 - buf[3] = CSI;
3029 - buf[4] = KEY2TERMCAP0(key);
3030 - buf[5] = KEY2TERMCAP1(key);
3031 - if (vim_mod)
3032 - {
3033 - buf[0] = CSI;
3034 - buf[1] = KS_MODIFIER;
3035 - buf[2] = vim_mod;
3036 - add_to_input_buf(buf, 6);
3037 - }
3038 - else
3039 - add_to_input_buf(buf + 3, 3);
3040 - }
3041 -
3042 - /* Take a wimp key code and insert the vim equivalent
3043 - * into vim's input buffer.
3044 - * CTRL-C also sets got_int.
3045 - */
3046 - void
3047 - ro_insert_key(code)
3048 - char_u *code; /* Wimp_ProcessKey code (4 bytes) */
3049 - {
3050 - char a = code[0];
3051 - char b = code[1];
3052 - int base, modifier;
3053 -
3054 - if (a == 3 && ctrl_c_interrupts)
3055 - got_int = TRUE;
3056 -
3057 - /* Is it a normal key? */
3058 - if (a > 31 && a < 127)
3059 - {
3060 - add_to_input_buf(code, 1);
3061 - return;
3062 - }
3063 -
3064 - /* We should pass any unrecognised keys on, but
3065 - * for now just pass on F12 combinations.
3066 - */
3067 - switch (b)
3068 - {
3069 - case 0:
3070 - /* Home and Delete are the only special cases */
3071 - switch (a)
3072 - {
3073 - case 0x1e:
3074 - ro_press('k','h', 0); /* Home */
3075 - return;
3076 - case 0x7f:
3077 - ro_press('k','D', 0); /* Delete */
3078 - return;
3079 - case CSI:
3080 - {
3081 - /* Turn CSI into K_CSI. Untested! */
3082 - char_u string[3] = {CSI, KS_EXTRA, KE_CSI};
3083 -
3084 - add_to_input_buf(string, 3);
3085 - return;
3086 - }
3087 - default:
3088 - add_to_input_buf(code, 1);
3089 - return;
3090 - }
3091 - case 1:
3092 - if ((a & 0xcf) == 0xcc)
3093 - {
3094 - /* F12 pressed - pass it on (quick hack) */
3095 - swi(Wimp_ProcessKey, a | 0x100);
3096 - return;
3097 - }
3098 - base = a & 0xcf;
3099 - modifier = a & 0x30;
3100 - switch (base)
3101 - {
3102 - case 0x8a: /* Tab */
3103 - add_to_input_buf("\011", 1);
3104 - return;
3105 - case 0x8b: /* Copy (End) */
3106 - return ro_press('@', '7', modifier);
3107 - case 0x8c: /* Left */
3108 - return ro_press('k', 'l', modifier);
3109 - case 0x8d: /* Right */
3110 - return ro_press('k', 'r', modifier);
3111 - case 0x8e: /* Down */
3112 - if (modifier & 0x10)
3113 - return ro_press('k', 'N', modifier ^ 0x10);
3114 - else
3115 - return ro_press('k', 'd', modifier);
3116 - case 0x8f: /* Up */
3117 - if (modifier & 0x10)
3118 - return ro_press('k', 'P', modifier ^ 0x10);
3119 - else
3120 - return ro_press('k', 'u', modifier);
3121 - case 0xca: /* F10 */
3122 - return ro_press('k', ';', modifier);
3123 - case 0xcb: /* F11 */
3124 - return ro_press('F', '1', modifier);
3125 - case 0xcd: /* Insert */
3126 - return ro_press('k', 'I', modifier);
3127 - default:
3128 - if (base > 0x80 && base < 0x18a)
3129 - {
3130 - /* One of the other function keys */
3131 - return ro_press('k', '0' + (base & 15), modifier);
3132 - }
3133 - }
3134 - }
3135 - }
3136 -
3137 - /* Process a mouse event. */
3138 - void
3139 - ro_mouse(block)
3140 - int *block;
3141 - {
3142 - int x, y, button, vim_button;
3143 - int modifiers = 0;
3144 - int min_x, min_y; /* Visible area of editor window */
3145 - int max_x, max_y;
3146 -
3147 - if (block[3] != gui.window_handle || ro_dragging)
3148 - return; /* Not our window or ignoring clicks*/
3149 -
3150 - x = block[0]; /* Click position - screen coords */
3151 - y = block[1];
3152 - button = block[2];
3153 -
3154 - block[0] = gui.window_handle;
3155 - swi(Wimp_GetWindowState, 0, block);
3156 - min_x = block[1];
3157 - min_y = block[2];
3158 - max_x = block[3];
3159 - max_y = block[4];
3160 -
3161 - if (block[3] - x < gui.scrollbar_width)
3162 - {
3163 - /* Click in that blank area under the scrollbars */
3164 -
3165 - if (button & 0x444)
3166 - {
3167 - int front_block[64];
3168 - /* Dragging with Select - bring window to front first */
3169 - front_block[0] = gui.window_handle;
3170 - swi(Wimp_GetWindowState, 0, front_block);
3171 - front_block[7] = -1;
3172 - ro_open_main(front_block);
3173 - }
3174 -
3175 - block[0] = gui.window_handle;
3176 - block[1] = 7; /* Drag point */
3177 - block[2] = block[4] = 0; /* Coords of point. */
3178 - block[3] = block[5] = 0;
3179 - drag_x_offset = max_x - x;
3180 - drag_y_offset = min_y - y;
3181 -
3182 - /* Parent box. */
3183 - block[6] = min_x +
3184 - gui.scrollbar_width * 2 +
3185 - MIN_COLUMNS * gui.char_width;
3186 - block[7] = 0;
3187 - gui_mch_get_screen_dimensions(&block[8], &block[9]);
3188 - block[9] = max_y -
3189 - 4 * gui.char_height -
3190 - gui.scrollbar_height;
3191 -
3192 - swi(Wimp_DragBox, 0, block);
3193 - ro_dragging = DRAG_RESIZE_WINDOW;
3194 - drag_button = vim_button;
3195 - drag_modifiers = modifiers;
3196 - return;
3197 - }
3198 -
3199 - if (button & 0x111)
3200 - vim_button = MOUSE_RIGHT;
3201 - else if (button & 0x222)
3202 - vim_button = MOUSE_MIDDLE;
3203 - else
3204 - vim_button = MOUSE_LEFT;
3205 -
3206 - swi(OS_Byte, 121, 0x80);
3207 - if (r1 == 0xff)
3208 - modifiers |= MOUSE_SHIFT;
3209 - swi(OS_Byte, 121, 0x81);
3210 - if (r1 == 0xff)
3211 - modifiers |= MOUSE_CTRL;
3212 - swi(OS_Byte, 121, 0x82);
3213 - if (r1 == 0xff)
3214 - modifiers |= MOUSE_ALT;
3215 -
3216 - if (button == 2)
3217 - {
3218 - /* Menu click:
3219 - * If shift was pressed then do the paste action.
3220 - * If not, then open the pop-up menu.
3221 - */
3222 - modifiers ^= MOUSE_SHIFT;
3223 - if (modifiers && MOUSE_SHIFT)
3224 - {
3225 - vimmenu_T main;
3226 - /* Shift was NOT pressed - show menu */
3227 - main.dname = (char_u *) "Vim";
3228 - main.children = root_menu;
3229 - gui_mch_show_popupmenu(&main);
3230 - return;
3231 - }
3232 - }
3233 -
3234 - /* Gain the input focus */
3235 - swi(Wimp_SetCaretPosition, gui.window_handle, -1, 0, 0, -1, -1);
3236 -
3237 - if (button & 0xf0)
3238 - {
3239 - /* Drag operation:
3240 - *
3241 - * Tell the Wimp to start a drag.
3242 - * Monitor null events.
3243 - */
3244 - block[1] = 7; /* Drag a point. */
3245 - block[2] = block[4] = x; /* Coords of point. */
3246 - block[3] = block[5] = y;
3247 - block[6] = 0; /* Coords of bounding box. */
3248 - block[7] = 0;
3249 - gui_mch_get_screen_dimensions(&block[8], &block[9]);
3250 -
3251 - drag_x_offset = drag_y_offset = 0;
3252 -
3253 - swi(Wimp_DragBox, 0, block);
3254 - ro_dragging = DRAG_SELECTION;
3255 - drag_button = vim_button;
3256 - drag_modifiers = modifiers;
3257 -
3258 - vim_button |= MOUSE_DRAG;
3259 - }
3260 -
3261 - gui_send_mouse_event(
3262 - vim_button,
3263 - x - min_x,
3264 - max_y - y,
3265 - button & 0xf ? TRUE : FALSE, /* dclick */
3266 - modifiers);
3267 - }
3268 -
3269 - void
3270 - ro_continue_drag(block)
3271 - int *block; /* Just used as scrap. */
3272 - {
3273 - int x, y;
3274 -
3275 - /* Get screen coords of pointer. */
3276 - swi(Wimp_GetPointerInfo, 0, block);
3277 - x = block[0] + drag_x_offset;
3278 - y = block[1] + drag_y_offset;
3279 -
3280 - block[0] = gui.window_handle;
3281 - swi(Wimp_GetWindowState, 0, block);
3282 -
3283 - if (ro_dragging == DRAG_RESIZE_WINDOW)
3284 - {
3285 - /* Resizing the main window. */
3286 - block[2] = y;
3287 - block[3] = x;
3288 - ro_open_main(block);
3289 - }
3290 - else
3291 - {
3292 - /* Selecting some text. */
3293 - gui_send_mouse_event(
3294 - drag_button | MOUSE_DRAG, /* Always report the same button */
3295 - x - block[1],
3296 - block[4] - y,
3297 - FALSE, /* Not a double click. */
3298 - drag_modifiers);
3299 - }
3300 - }
3301 -
3302 - /* User has released all mouse buttons, marking the end of a drag. */
3303 - void
3304 - ro_drag_finished(block)
3305 - int *block;
3306 - {
3307 - int x;
3308 - int y;
3309 - int width, height;
3310 -
3311 - /* I don't trust the box returned by Wimp_Poll; look at the pointer
3312 - * ourselves.
3313 - */
3314 - swi(Wimp_GetPointerInfo, 0, block);
3315 - x = block[0] + drag_x_offset;
3316 - y = block[1] + drag_y_offset;
3317 -
3318 - if (ro_dragging == DRAG_RESIZE_WINDOW)
3319 - {
3320 - block[0] = gui.window_handle;
3321 - swi(Wimp_GetWindowState, 0, block);
3322 - block[2] = y;
3323 - block[3] = x;
3324 - ro_open_main(block);
3325 -
3326 - width = (block[3] - block[1]);
3327 - height = (block[4] - block[2]);
3328 -
3329 - swi(Wimp_ForceRedraw, gui.window_handle, 0, -height, width, 0);
3330 - gui_resize_shell(width, height);
3331 - }
3332 - else
3333 - {
3334 - block[0] = gui.window_handle;
3335 - swi(Wimp_GetWindowState, 0, block);
3336 - gui_send_mouse_event(
3337 - MOUSE_RELEASE,
3338 - x - block[1],
3339 - block[4] - y,
3340 - FALSE, /* not a double click */
3341 - drag_modifiers);
3342 - }
3343 - ro_dragging = DRAG_FALSE;
3344 - }
3345 -
3346 - /* Load the file/pathname given in block into a [new] buffer.
3347 - *
3348 - * Modifier Action
3349 - *
3350 - * None :confirm e <file>
3351 - * Ctrl :sp <file>
3352 - * Shift <file>
3353 - *
3354 - * Insert into typebuf, at the start.
3355 - * If loading from !Scrap then use saved leafname instead, and
3356 - * delete the scrap file. Also, ignore shift key.
3357 - *
3358 - * NB: Doesn't send DataLoadAck (other app might delete temp file?).
3359 - */
3360 - void
3361 - ro_dataload(block)
3362 - int *block;
3363 - {
3364 - char_u new_path[MAXPATHL];
3365 - char_u *path = ((char_u *) block) + 44;
3366 - int scrap = FALSE;
3367 -
3368 - if (block[3] == leaf_ref && leaf_name)
3369 - scrap = TRUE;
3370 -
3371 - switch (get_real_state() & 0xff)
3372 - {
3373 - case INSERT:
3374 - case CMDLINE:
3375 - case CMDLINE+LANGMAP:
3376 - /* For insert mode we can only insert the pathname (currently)
3377 - * Make sure Shift is pressed.
3378 - */
3379 - swi(OS_Byte, 121, 0x80); /* Is Shift pressed? */
3380 - if (r1 == 0xff)
3381 - {
3382 - ins_typebuf(" ", REMAP_NONE, 0, TRUE, FALSE);
3383 - ins_typebuf(path, REMAP_NONE, 0, TRUE, FALSE);
3384 - ro_return_early = TRUE; /* Return even though nothing was typed. */
3385 - }
3386 - else
3387 - swi(Wimp_ReportError,
3388 - "\0\0\0\0Sorry, you can only load text in normal mode", 5, "Vim");
3389 - break;
3390 -
3391 - case NORMAL:
3392 - ro_return_early = TRUE; /* Return even though nothing was typed. */
3393 -
3394 - if (scrap) /* Remove <Wimp$Scrap>. Later. */
3395 - ins_typebuf(":!~remove <Wimp$Scrap>\r", REMAP_NONE, 0, TRUE, FALSE);
3396 -
3397 - /* Insert {:sp ,:confirm e }[+f\ <leaf> ]<file><CR> */
3398 - ins_typebuf("\r", REMAP_NONE, 0, TRUE, FALSE);
3399 - ins_typebuf(path, REMAP_NONE, 0, TRUE, FALSE);
3400 - ins_typebuf(" ", REMAP_NONE, 0, TRUE, FALSE);
3401 -
3402 - if (scrap)
3403 - {
3404 - /* Loading via !Scrap - change pathname to stored leafname */
3405 - ins_typebuf(leaf_name, REMAP_NONE, 0, TRUE, FALSE);
3406 - ins_typebuf(" +f\\ ", REMAP_NONE, 0, TRUE, FALSE);
3407 - leaf_ref = 0;
3408 - vim_free(leaf_name);
3409 - leaf_name = NULL;
3410 - }
3411 -
3412 - swi(OS_Byte, 121, 0x81); /* Is Ctrl pressed? */
3413 - if (r1 == 0xff)
3414 - /* Yes, split window */
3415 - ins_typebuf(":sp", REMAP_NONE, 0, TRUE, FALSE);
3416 - else
3417 - ins_typebuf(":confirm e", REMAP_NONE, 0, TRUE, FALSE);
3418 - break;
3419 -
3420 - default:
3421 - swi(Wimp_ReportError, "\0\0\0\0You can only load text in normal mode.", 5, "Vim");
3422 - }
3423 - /* Send DataSaveAck so other program doesn't think we died
3424 - * and delete <Wimp$Scrap>.
3425 - */
3426 - block[3] = block[2];
3427 - block[4] = 4;
3428 - swi(Wimp_SendMessage, 17, block, block[1]);
3429 - }
3430 -
3431 - void
3432 - ro_datasave(block)
3433 - int *block;
3434 - {
3435 - char_u *path = ((char_u *) block) + 44;
3436 -
3437 - /* Preserve the name given so we can use it, not <Wimp$Scrap> */
3438 - if (leaf_name)
3439 - vim_free(leaf_name);
3440 - leaf_name = vim_strsave(path);
3441 -
3442 - block[9] = -1; /* File is unsafe. */
3443 - strcpy(path, "<Wimp$Scrap>");
3444 - block[0] = 60;
3445 - block[3] = block[2];
3446 - block[4] = 2;
3447 - swi(Wimp_SendMessage, 17, block, block[1]);
3448 -
3449 - leaf_ref = block[2];
3450 - }
3451 -
3452 - void
3453 - ro_message(block)
3454 - int *block;
3455 - {
3456 - char_u *buffer;
3457 - long_u len;
3458 -
3459 - if (block[1] == task_handle)
3460 - return; /* Don't talk to ourself! */
3461 - switch (block[4])
3462 - {
3463 - case 0: /* Quit. */
3464 - if (block[4] == 0)
3465 - ro_quit();
3466 - break;
3467 - case 1: /* DataSave */
3468 - ro_datasave(block);
3469 - break;
3470 - case 2: /* DataSaveAck. */
3471 - if (clip_convert_selection(&buffer, &len, &clip_star) == -1)
3472 - return;
3473 -
3474 - /* Save the clipboard contents to a file. */
3475 - swi(OS_File, 10, ((char_u *) block) + 44, 0xfff, 0, buffer, buffer + len);
3476 -
3477 - /* Ack with DataLoad message. */
3478 - block[3] = block[2];
3479 - block[4] = 3;
3480 - block[9] = len;
3481 - swi(Wimp_SendMessage, 17, block, block[1]);
3482 -
3483 - vim_free(buffer);
3484 - break;
3485 - case 3: /* DataLoad */
3486 - ro_dataload(block);
3487 - break;
3488 - case 8: /* PreQuit */
3489 - ro_prequit(block);
3490 - break;
3491 - case 0xf: /* Lose clipboard. */
3492 - if (block[5] & 4)
3493 - {
3494 - clip_free_selection(&clip_star);
3495 - clip_star.owned = FALSE;
3496 - }
3497 - break;
3498 - case 0x10: /* DataRequest (clip_star) */
3499 - if (clip_star.owned)
3500 - {
3501 - int rows;
3502 -
3503 - /* Tell other program that we have the clipboard. */
3504 - block[0] = 52;
3505 - block[3] = block[2]; /* Copy myref to yourref. */
3506 - block[4] = 1; /* DataSave message. */
3507 - /* Create an estimate for the size (larger or same as true
3508 - * value) */
3509 - rows = clip_star.end.lnum - clip_star.start.lnum;
3510 - if (rows < 0)
3511 - rows = -rows;
3512 - block[9] = (rows + 1) * Columns + 1; /* Add one for possible
3513 - final newline. */
3514 - block[10] = 0xfff; /* Clipboard is text. */
3515 - strcpy( ((char_u *) block) + 44, "VimClip");
3516 - swi(Wimp_SendMessage, 17, block, block[1]);
3517 - }
3518 - break;
3519 - case 0x400c1: /* Mode change */
3520 - changed_mode = TRUE; /* Flag - update on next OpenWindow */
3521 - if (zap_redraw)
3522 - {
3523 - /* JK230798, re-initialise ZapRedraw stuff */
3524 - if (ro_zap_redraw_initialise() == FAIL)
3525 - zap_redraw = FALSE;
3526 - }
3527 - break;
3528 - case 0x400c3: /* TaskCloseDown */
3529 - if (block[1] == child_handle)
3530 - child_handle = 0;
3531 - break;
3532 - }
3533 - }
3534 -
3535 - /*
3536 - * Converts a scrollbar's window handle into a scrollbar pointer.
3537 - * NULL on failure.
3538 - */
3539 - scrollbar_T *
3540 - ro_find_sbar(id)
3541 - int id;
3542 - {
3543 - win_T *wp;
3544 -
3545 - if (gui.bottom_sbar.id == id)
3546 - return &gui.bottom_sbar;
3547 - FOR_ALL_WINDOWS(wp)
3548 - {
3549 - if (wp->w_scrollbars[SBAR_LEFT].id == id)
3550 - return &wp->w_scrollbars[SBAR_LEFT];
3551 - if (wp->w_scrollbars[SBAR_RIGHT].id == id)
3552 - return &wp->w_scrollbars[SBAR_RIGHT];
3553 - }
3554 - return NULL;
3555 - }
3556 -
3557 - void
3558 - scroll_to(line, sb)
3559 - int sb; /* Scrollbar number */
3560 - int line;
3561 - {
3562 - char_u code[8];
3563 -
3564 - /* Don't put events in the input queue now. */
3565 - if (hold_gui_events)
3566 - return;
3567 -
3568 - /* Send a scroll event:
3569 - *
3570 - * A scrollbar event is CSI (NOT K_SPECIAL), KS_VER_SCROLLBAR,
3571 - * KE_FILLER followed by:
3572 - * one byte representing the scrollbar number, and then four bytes
3573 - * representing a long_u which is the new value of the scrollbar.
3574 - */
3575 - code[0] = CSI;
3576 - code[1] = KS_VER_SCROLLBAR;
3577 - code[2] = KE_FILLER;
3578 - code[3] = sb;
3579 - code[4] = line >> 24;
3580 - code[5] = line >> 16;
3581 - code[6] = line >> 8;
3582 - code[7] = line;
3583 - add_to_input_buf(code, 8);
3584 - }
3585 -
3586 - void
3587 - h_scroll_to(col)
3588 - int col;
3589 - {
3590 - char_u code[8];
3591 -
3592 - /* Don't put events in the input queue now. */
3593 - if (hold_gui_events)
3594 - return;
3595 -
3596 - /* Send a scroll event:
3597 - *
3598 - * A scrollbar event is CSI (NOT K_SPECIAL)
3599 - *
3600 - * A horizontal scrollbar event is K_SPECIAL, KS_HOR_SCROLLBAR,
3601 - * KE_FILLER followed by four bytes representing a long_u which is the
3602 - * new value of the scrollbar.
3603 - */
3604 - code[0] = CSI;
3605 - code[1] = KS_HOR_SCROLLBAR;
3606 - code[2] = KE_FILLER;
3607 - code[4] = col >> 24;
3608 - code[5] = col >> 16;
3609 - code[6] = col >> 8;
3610 - code[7] = col;
3611 - add_to_input_buf(code, 8);
3612 - }
3613 -
3614 - void
3615 - ro_scroll(block)
3616 - int *block;
3617 - {
3618 - scrollbar_T *sb;
3619 - int offset;
3620 - win_T *wp;
3621 -
3622 - /* Block is ready for Wimp_OpenWindow, and also contains:
3623 - *
3624 - * +32 = scroll X direction (-2 .. +2)
3625 - * +36 = scroll Y direction (-2 .. +2)
3626 - */
3627 -
3628 - sb = ro_find_sbar(block[0]);
3629 - if (!sb)
3630 - return; /* Window not found (error). */
3631 -
3632 - wp = sb-> wp;
3633 -
3634 - if (wp == NULL)
3635 - {
3636 - /* Horizontal bar. */
3637 - offset = block[8];
3638 - if (offset == -2)
3639 - offset = (block[1] - block[3]) / gui.char_width;
3640 - else if (offset == 2)
3641 - offset = (block[3] - block[1]) / gui.char_width;
3642 -
3643 - block[5] += offset * gui.char_width;
3644 -
3645 - gui_drag_scrollbar(sb, block[5] / gui.char_width, FALSE);
3646 -
3647 - swi(Wimp_OpenWindow, 0, block);
3648 - }
3649 - else
3650 - {
3651 - offset = -block[9];
3652 - if (offset == -2)
3653 - offset = -(wp -> w_height - 1);
3654 - else if (offset == 2)
3655 - offset = wp -> w_height - 1;
3656 -
3657 - /* Possibly we should reposition the scrollbar?
3658 - * Vim seems to update the bar anyway...
3659 - */
3660 - gui_drag_scrollbar(sb, offset - (block[6] / gui.char_height), FALSE);
3661 - }
3662 - }
3663 -
3664 - /* Move a window by a given offset. Used to simulate the function of the
3665 - * nested wimp.
3666 - */
3667 - void
3668 - ro_move_child(window, x, y, pos_wanted, pos_got)
3669 - int window;
3670 - int x,y; /* offset to move by */
3671 - int pos_wanted, pos_got;
3672 - {
3673 - int block[10];
3674 -
3675 - block[0] = window;
3676 - swi(Wimp_GetWindowState, 0, block);
3677 - block[1] += x;
3678 - block[2] += y;
3679 - block[3] += x;
3680 - block[4] += y;
3681 - if (pos_wanted == -1)
3682 - block[7] = -1;
3683 - else if (pos_wanted == -2)
3684 - block[7] = pos_got;
3685 - swi(Wimp_OpenWindow, 0, block);
3686 - }
3687 -
3688 - /* Open the main window. Also updates scrollbars if we are not
3689 - * using the nested Wimp.
3690 - * If we have just changed mode then re-read all values.
3691 - */
3692 - void
3693 - ro_open_main(block)
3694 - int *block;
3695 - {
3696 - int toggle_size;
3697 -
3698 - /* Find out if the user clicked on the toggle size icon. */
3699 - block[20] = block[0];
3700 - swi(Wimp_GetWindowState, 0, block + 20);
3701 - toggle_size = block[28] & (1 << 19);
3702 -
3703 - if (nested_wimp)
3704 - {
3705 - swi(Wimp_OpenWindow, 0, block);
3706 - }
3707 - else
3708 - {
3709 - int old[10];
3710 - int x_offset, y_offset; /* Move children same as parent. */
3711 - int pos_wanted, pos_got;
3712 - int left_bar = gui.which_scrollbars[SBAR_LEFT];
3713 - int right_bar = gui.which_scrollbars[SBAR_RIGHT];
3714 - win_T *wp;
3715 -
3716 - /* Three cases to think about:
3717 - * 1) Move to top. Open each window at the top.
3718 - * 2) Same stack position. Open each with same position.
3719 - * 3) Open at bottom. Open children with parent's new position.
3720 - */
3721 -
3722 - old[0] = block[0];
3723 - swi(Wimp_GetWindowState, 0, old);
3724 - pos_wanted = block[7];
3725 - swi(Wimp_OpenWindow, 0, block);
3726 - /* Block updated by OpenWindow? I don't think so! */
3727 - swi(Wimp_GetWindowState, 0, block);
3728 - pos_got = block[7];
3729 -
3730 - x_offset = block[1] - old[1];
3731 - y_offset = block[4] - old[4];
3732 - if (x_offset || y_offset || pos_wanted == -1 || pos_wanted == -2)
3733 - {
3734 - /* If parent has moved, re-open all the child windows. */
3735 - FOR_ALL_WINDOWS(wp)
3736 - {
3737 - /* Reopen scrollbars for this window. */
3738 - if (left_bar)
3739 - ro_move_child(wp -> w_scrollbars[SBAR_LEFT].id,
3740 - x_offset, y_offset,
3741 - pos_wanted, pos_got);
3742 - if (right_bar)
3743 - ro_move_child(wp -> w_scrollbars[SBAR_RIGHT].id,
3744 - x_offset, y_offset,
3745 - pos_wanted, pos_got);
3746 - }
3747 - }
3748 - }
3749 - if (changed_mode || toggle_size)
3750 - {
3751 - int width, height;
3752 -
3753 - if (changed_mode)
3754 - ro_measure_tools();
3755 - block[0] = gui.window_handle;
3756 - swi(Wimp_GetWindowState, 0, block);
3757 -
3758 - width = block[3] - block[1];
3759 - height = block[4] - block[2];
3760 - swi(Wimp_ForceRedraw, gui.window_handle, 0, -height, width, 0);
3761 - gui_resize_shell(width, height);
3762 - changed_mode = FALSE;
3763 - }
3764 - }
3765 -
3766 - void
3767 - ro_open_window(block)
3768 - int *block;
3769 - {
3770 - int pos;
3771 - scrollbar_T *sb;
3772 -
3773 - if (block[0] == gui.window_handle)
3774 - ro_open_main(block);
3775 - else
3776 - {
3777 - swi(Wimp_OpenWindow, 0, block);
3778 - if (block[0] != gui.window_handle)
3779 - {
3780 - sb = ro_find_sbar(block[0]);
3781 - if (sb)
3782 - {
3783 - if (sb-> wp != NULL)
3784 - gui_drag_scrollbar(sb, -block[6] / gui.char_height, FALSE);
3785 - else
3786 - gui_drag_scrollbar(sb, block[5] / gui.char_width, FALSE);
3787 - }
3788 - }
3789 - }
3790 - }
3791 -
3792 - void
3793 - ro_menu_selection(block)
3794 - int *block;
3795 - {
3796 - int *item = wimp_menu + 7;
3797 - vimmenu_T *menu;
3798 - /* wimp_menu points to a wimp menu structure */
3799 -
3800 - for (;;)
3801 - {
3802 - while (block[0]--)
3803 - item += 6;
3804 - if (block[1] == -1)
3805 - break;
3806 - item = ((int *) item[1]) + 7;
3807 - block++;
3808 - }
3809 - /* item points to the wimp menu item structure chosen */
3810 - menu = (vimmenu_T *) item[5];
3811 -
3812 - swi(Wimp_GetPointerInfo, 0, block);
3813 - if (block[2] == 1)
3814 - /* Adjust used - keep menu open */
3815 - swi(Wimp_CreateMenu, 0, wimp_menu);
3816 -
3817 - if (menu-> cb)
3818 - menu-> cb(menu);
3819 - }
3820 -
3821 - void
3822 - ro_open_parent()
3823 - {
3824 - int head;
3825 - char_u *i = curbuf-> b_ffname;
3826 - char_u buffer[256];
3827 -
3828 - head = 0;
3829 - for (; *i; i++)
3830 - {
3831 - if (*i == '.')
3832 - head = i - curbuf-> b_ffname;
3833 - }
3834 -
3835 - /* Append head chars to buffer */
3836 - if (head < 240 && curbuf-> b_ffname && head)
3837 - {
3838 - strcpy(buffer, "%filer_opendir ");
3839 - strncpy(buffer + 15, curbuf-> b_ffname, head);
3840 - buffer[15 + head] = '\0';
3841 - swi(OS_CLI, buffer);
3842 - }
3843 - }
3844 -
3845 - void
3846 - process_event(event, block)
3847 - int event;
3848 - int *block;
3849 - {
3850 - switch (event)
3851 - {
3852 - case 0: /* Nothing - update drag state. */
3853 - if (ro_dragging)
3854 - ro_continue_drag(block);
3855 - break;
3856 - case 1: /* Redraw window. */
3857 - redraw_window(block);
3858 - break;
3859 - case 2: /* Open window. */
3860 - ro_open_window(block);
3861 - break;
3862 - case 3: /* Close window. */
3863 - swi(Wimp_GetPointerInfo, 0, block + 1);
3864 - if (block[3] == 1)
3865 - ro_open_parent();
3866 - else
3867 - if (ro_ok_to_quit())
3868 - ro_quit();
3869 - break;
3870 - case 6: /* Mouse click. */
3871 - ro_mouse(block);
3872 - break;
3873 - case 7: /* Finished drag. */
3874 - ro_drag_finished(block);
3875 - break;
3876 - case 8: /* Key pressed. */
3877 - ro_insert_key((char_u *) &block[6]);
3878 - break;
3879 - case 9:
3880 - ro_menu_selection(block);
3881 - break;
3882 - case 10: /* Scroll request. */
3883 - ro_scroll(block);
3884 - break;
3885 - case 11: /* Lose caret. */
3886 - if (block[0] == gui.window_handle)
3887 - gui_focus_change(FALSE);
3888 - break;
3889 - case 12: /* Gain caret. */
3890 - if (block[0] == gui.window_handle)
3891 - gui_focus_change(TRUE);
3892 - break;
3893 - case 17: /* User message. */
3894 - case 18: /* User message recorded. */
3895 - ro_message(block);
3896 - break;
3897 - }
3898 - }
3899 -
3900 - /*
3901 - * GUI input routine called by gui_wait_for_chars(). Waits for a character
3902 - * from the keyboard.
3903 - * wtime == -1 Wait forever.
3904 - * wtime == 0 This should never happen.
3905 - * wtime > 0 Wait wtime milliseconds for a character.
3906 - * Returns OK if a character was found to be available within the given time,
3907 - * or FAIL otherwise.
3908 - */
3909 - int
3910 - gui_mch_wait_for_chars(long wtime)
3911 - {
3912 - int block[64];
3913 - int reason;
3914 - int start_time = -1;
3915 - int ctime = wtime / 10; /* delay in cs */
3916 -
3917 - if (wtime != -1)
3918 - {
3919 - swi(OS_ReadMonotonicTime);
3920 - start_time = r0;
3921 - }
3922 -
3923 - for (;;)
3924 - {
3925 - if (ro_dragging)
3926 - reason = wimp_poll(0, block); /* Always return immediately */
3927 - else if (wtime == -1)
3928 - reason = wimp_poll(1, block);
3929 - else
3930 - reason = wimp_pollidle(0, block, start_time + ctime);
3931 -
3932 - process_event(reason, block);
3933 -
3934 - if (input_available() || ro_return_early)
3935 - {
3936 - ro_return_early = FALSE;
3937 - return OK; /* There is something to process (key / menu event) */
3938 - }
3939 -
3940 - if (wtime != -1)
3941 - {
3942 - swi(OS_ReadMonotonicTime);
3943 - if (r0 - start_time > ctime)
3944 - return FAIL; /* We've been waiting too long - return failure */
3945 - }
3946 - }
3947 - }
3948 -
3949 - /* Flush any output to the screen */
3950 - void
3951 - gui_mch_flush(void)
3952 - {
3953 - }
3954 -
3955 - /*
3956 - * Clear a rectangular region of the screen from text pos(row1, col1) to
3957 - * (row2, col2) inclusive.
3958 - */
3959 - void
3960 - gui_mch_clear_block(int row1, int col1, int row2, int col2)
3961 - {
3962 - swi(ColourTrans_ReturnGCOL, gui.back_pixel << 8, 0, 0, 1<<7, 0);
3963 - plot_rectangle(96 + 5, r0,
3964 - FILL_X(col1), -FILL_Y(row2 + 1),
3965 - FILL_X(col2 + 1), -FILL_Y(row1));
3966 - }
3967 -
3968 - void
3969 - gui_mch_clear_all(void)
3970 - {
3971 - if (redraw_block)
3972 - {
3973 - swi(ColourTrans_SetGCOL, gui.back_pixel << 8, 0, 0, 1<<7, 0);
3974 - swi(OS_WriteI + 16);
3975 - }
3976 - else
3977 - {
3978 - int block[44];
3979 - block[0] = gui.window_handle;
3980 - block[1] = 0;
3981 - block[2] = -gui.num_rows * gui.char_height;
3982 - block[3] = gui.num_cols * gui.char_width;
3983 - block[4] = 0;
3984 - swi(Wimp_UpdateWindow, 0, block);
3985 - while (r0)
3986 - {
3987 - swi(ColourTrans_SetGCOL, gui.back_pixel << 8, 0, 0, 1<<7, 0);
3988 - swi(OS_WriteI + 16);
3989 - swi(Wimp_GetRectangle, 0, block);
3990 - }
3991 - }
3992 - }
3993 -
3994 - /*
3995 - * Delete the given number of lines from the given row, scrolling up any
3996 - * text further down within the scroll region.
3997 - */
3998 - void
3999 - gui_mch_delete_lines(int row, int num_lines)
4000 - {
4001 - int top_from = -row - num_lines;
4002 - int bot_from = -gui.scroll_region_bot - 1;
4003 - int bot_to = bot_from + num_lines;
4004 -
4005 - swi(ColourTrans_SetGCOL, gui.back_pixel << 8, 0, 0, 0x80, 0);
4006 -
4007 - /* Changed without checking! */
4008 - swi(Wimp_BlockCopy, gui.window_handle,
4009 - gui.scroll_region_left * gui.char_width,
4010 - bot_from * gui.char_height,
4011 - (gui.scroll_region_right - gui.scroll_region_left
4012 - + 1) * gui.char_width,
4013 - top_from * gui.char_height,
4014 -
4015 - gui.scroll_region_left * gui.char_width,
4016 - bot_to * gui.char_height);
4017 -
4018 - gui_clear_block(gui.scroll_region_bot - num_lines + 1,
4019 - gui.scroll_region_left,
4020 - gui.scroll_region_bot, gui.scroll_region_right);
4021 - }
4022 -
4023 - /*
4024 - * Insert the given number of lines before the given row, scrolling down any
4025 - * following text within the scroll region.
4026 - */
4027 - void
4028 - gui_mch_insert_lines(int row, int num_lines)
4029 - {
4030 - int top_from = -row;
4031 - int bot_to = -gui.scroll_region_bot - 1;
4032 - int bot_from = bot_to + num_lines;
4033 -
4034 - swi(ColourTrans_SetGCOL, gui.back_pixel << 8, 0, 0, 0x80, 0);
4035 -
4036 - swi(Wimp_BlockCopy, gui.window_handle,
4037 - gui.scroll_region_left * gui.char_width,
4038 - bot_from * gui.char_height,
4039 - (gui.scroll_region_right - gui.scroll_region_left
4040 - + 1) * gui.char_width,
4041 - top_from * gui.char_height,
4042 -
4043 - gui.scroll_region_left * gui.char_width,
4044 - bot_to * gui.char_height);
4045 -
4046 - gui_clear_block(row, gui.scroll_region_left,
4047 - row + num_lines - 1, gui.scroll_region_right);
4048 - }
4049 -
4050 - /* Put selection in clipboard buffer.
4051 - * Should we become the new owner?
4052 - */
4053 - void
4054 - clip_mch_request_selection(VimClipboard *cbd)
4055 - {
4056 - int block[64]; /* Will be used in Wimp_Poll. */
4057 - int reason;
4058 - char_u *buffer;
4059 - long_u length;
4060 -
4061 - block[0] = 48; /* Size of block. */
4062 - block[3] = 0; /* Original message. */
4063 - block[4] = 0x10; /* Data request. */
4064 - block[5] = gui.window_handle;
4065 - block[6] = RO_LOAD_CLIPBOARD; /* Internal handle. */
4066 - block[7] = block[8] = 0; /* (x,y) not used. */
4067 - block[9] = 4;
4068 - block[10] = 0xfff; /* We want text files if possible, I think. */
4069 - block[11] = -1; /* End of list. */
4070 - swi(Wimp_SendMessage, 17, block, 0); /* Broadcast request. */
4071 -
4072 - /* OK, we've sent the request. Poll until we get a null poll (failure) or
4073 - * we load the clipboard.
4074 - * If we receive a DataSave event with icon handle = -2 then put it on the
4075 - * clipboard. RISC OS should ensure that key events will not be delivered
4076 - * until the clipboard operation completes (unless the owner starts idling
4077 - * - we can't wait forever!).
4078 - */
4079 - for (;;)
4080 - {
4081 - reason = wimp_poll(0, block);
4082 - if (reason == 0)
4083 - return; /* Failed to get clipboard. */
4084 - if ((reason == 17 || reason == 18) &&
4085 - block[4] == 1 && block[6] == RO_LOAD_CLIPBOARD)
4086 - break; /* Got it - stop waiting. */
4087 - process_event(reason, block);
4088 - if (ro_return_early)
4089 - return;
4090 - }
4091 - /* Tell owner to save data in <Wimp$Scrap>. */
4092 - block[0] = 60;
4093 - block[3] = block[2]; /* Copy myref -> yourref */
4094 - block[4] = 2; /* DataSaveAck. */
4095 - block[9] = -1; /* Data is unsafe. */
4096 - strcpy( ((char_u *) block) + 44, "<Wimp$Scrap>");
4097 - swi(Wimp_SendMessage, 17, block, block[1]);
4098 -
4099 - /* Wait again for reply. */
4100 - for (;;)
4101 - {
4102 - reason = wimp_poll(0, block);
4103 - if (reason == 0)
4104 - return; /* Other program has given up! */
4105 - if ((reason == 17 || reason == 18) && block[4] == 3 && block[6] == RO_LOAD_CLIPBOARD)
4106 - break; /* Clipboard data saved to <Wimp$Scrap> */
4107 - process_event(reason, block);
4108 - if (ro_return_early)
4109 - return;
4110 - }
4111 -
4112 - /* <Wimp$Scrap> contains clipboard - load it. */
4113 - if (xswi(OS_File, 17, "<Wimp$Scrap>") & v_flag)
4114 - return; /* Error! */
4115 - if (r0 != 1 && r0 != 3)
4116 - return;
4117 - length = r4;
4118 -
4119 - buffer = lalloc(length, TRUE); /* Claim memory (and report errors). */
4120 - if (buffer == NULL)
4121 - return;
4122 -
4123 - if (xswi(OS_File, 16, "<Wimp$Scrap>", buffer, 0) & v_flag)
4124 - return;
4125 -
4126 - clip_yank_selection(MCHAR, buffer, length, cbd);
4127 -
4128 - vim_free(buffer);
4129 -
4130 - swi(OS_FSControl, 27, "<Wimp$Scrap>", 0, 0); /* Delete temp file. */
4131 -
4132 - block[4] = 4; /* Send DataLoadAck. */
4133 - block[3] = block[2]; /* Copy myref -> yourref. */
4134 - swi(Wimp_SendMessage, 17, block, block[1]);
4135 - }
4136 -
4137 - /* Not sure what this means under RISC OS. */
4138 - void
4139 - clip_mch_lose_selection(VimClipboard *cbd)
4140 - {
4141 - }
4142 -
4143 - /* Tell everyone that we now own the clipboard.
4144 - * Return OK if our claim is accepted (always, under RISC OS)
4145 - */
4146 - int
4147 - clip_mch_own_selection(VimClipboard *cbd)
4148 - {
4149 - int block[6];
4150 - block[0] = 24; /* Length of block. */
4151 - block[3] = 0; /* Original message. */
4152 - block[4] = 0xf; /* ClaimEntity. */
4153 - block[5] = 0x4; /* Claim clipboard only. */
4154 - swi(Wimp_SendMessage, 17, block, 0);
4155 - return OK;
4156 - }
4157 -
4158 - /*
4159 - * Send the current selection to the clipboard. Do nothing for X because we
4160 - * will fill in the selection only when requested by another app. Sounds good
4161 - * for RISC OS too.
4162 - */
4163 - void
4164 - clip_mch_set_selection(VimClipboard *cbd)
4165 - {
4166 - clip_get_selection(cbd);
4167 - }
4168 -
4169 - /*
4170 - * Make a menu either grey or not grey.
4171 - */
4172 - void
4173 - gui_mch_menu_grey(vimmenu_T *menu, int grey)
4174 - {
4175 - menu-> greyed_out = grey;
4176 - }
4177 -
4178 - /*
4179 - * Make menu item hidden or not hidden
4180 - */
4181 - void
4182 - gui_mch_menu_hidden(vimmenu_T *menu, int hidden)
4183 - {
4184 - menu-> hidden = hidden;
4185 - }
4186 -
4187 - /*
4188 - * This is called after setting all the menus to grey/hidden or not.
4189 - */
4190 - void
4191 - gui_mch_draw_menubar(void)
4192 - {
4193 - swi(Wimp_CreateMenu, 0, -1);
4194 - if (wimp_menu != (int *) -1)
4195 - {
4196 - ro_remove_menu(wimp_menu);
4197 - wimp_menu = (int *) -1;
4198 - }
4199 - }
4200 -
4201 - /* Add or remove a scrollbar. Note that this is only called when
4202 - * the scrollbar state is changing.
4203 - * The scroll bar window has already been created.
4204 - * We can't do anything except remove the scroll bar
4205 - * until we know what size to use.
4206 - */
4207 - void
4208 - gui_mch_enable_scrollbar(sb, flag)
4209 - scrollbar_T *sb;
4210 - int flag;
4211 - {
4212 - if (!flag)
4213 - swi(Wimp_CloseWindow, 0, & (sb->id) );
4214 - return;
4215 - }
4216 -
4217 - void
4218 - gui_mch_set_blinking(long waittime, long on, long off)
4219 - {
4220 - }
4221 -
4222 - /*
4223 - * Stop the cursor blinking. Show the cursor if it wasn't shown.
4224 - */
4225 - void
4226 - gui_mch_stop_blink(void)
4227 - {
4228 - }
4229 -
4230 - /*
4231 - * Start the cursor blinking. If it was already blinking, this restarts the
4232 - * waiting time and shows the cursor.
4233 - */
4234 - void
4235 - gui_mch_start_blink(void)
4236 - {
4237 - }
4238 -
4239 - /*
4240 - * Return the RGB value of a pixel as a long.
4241 - */
4242 - long_u
4243 - gui_mch_get_rgb(guicolor_T pixel)
4244 - {
4245 - return (long_u)pixel;
4246 - }
4247 -
4248 - void
4249 - gui_mch_set_text_area_pos(int x, int y, int w, int h)
4250 - {
4251 - }
4252 -
4253 - void
4254 - gui_mch_enable_menu(int flag)
4255 - {
4256 - }
4257 -
4258 - void
4259 - gui_mch_set_menu_pos(int x, int y, int w, int h)
4260 - {
4261 - }
4262 -
4263 - void
4264 - gui_mch_add_menu(vimmenu_T *menu, int idx)
4265 - {
4266 - }
4267 -
4268 - void
4269 - gui_mch_add_menu_item(vimmenu_T *menu, int idx)
4270 - {
4271 - }
4272 -
4273 - void
4274 - gui_mch_new_menu_colors(void)
4275 - {
4276 - }
4277 -
4278 - void
4279 - gui_mch_destroy_menu(vimmenu_T *menu)
4280 - {
4281 - }
4282 -
4283 - /* Size of buffer has changed.
4284 - * Add one to max since gui.c subtracts one more than it should!
4285 - */
4286 - void
4287 - gui_mch_set_scrollbar_thumb(sb, val, size, max)
4288 - scrollbar_T *sb;
4289 - long val;
4290 - long size;
4291 - long max;
4292 - {
4293 - int block[10], width, height;
4294 -
4295 - width = (max + 1) * gui.char_width;
4296 - height = (max + 1 + W_STATUS_HEIGHT(sb->wp)) * gui.char_height;
4297 -
4298 - block[0] = block[3] = 0;
4299 - block[1] = -height + (1 << y_eigen_factor);
4300 - block[2] = width;
4301 -
4302 - swi(Wimp_SetExtent, sb -> id, block);
4303 -
4304 - block[0] = sb -> id;
4305 - swi(Wimp_GetWindowState, 0, block);
4306 - block[5] = val * gui.char_width;
4307 - block[6] = -val * gui.char_height;
4308 - swi(Wimp_OpenWindow, 0, block, 0x4b534154,
4309 - gui.window_handle, /* Parent window handle. */
4310 - (CHILD_FIX_TO_RIGHT << CHILD_LEFT ) |
4311 - (CHILD_FIX_TO_RIGHT << CHILD_RIGHT ) |
4312 - (CHILD_FIX_TO_BOTTOM << CHILD_TOP ) |
4313 - (CHILD_FIX_TO_BOTTOM << CHILD_BOTTOM) |
4314 - (CHILD_SELF_SCROLL << CHILD_SCROLL_X) |
4315 - (CHILD_SELF_SCROLL << CHILD_SCROLL_Y)
4316 - );
4317 - }
4318 -
4319 - /* Set the position of the scrollbar within the editor
4320 - * window. Note that, for vertical scrollbars, x and w
4321 - * are ignored. For horizontal bars y and h are ignored.
4322 - */
4323 - void
4324 - gui_mch_set_scrollbar_pos(sb, x, y, w, h)
4325 - scrollbar_T *sb;
4326 - int x; /* Horizontal sb position */
4327 - int y; /* Top of scroll bar */
4328 - int w; /* Width */
4329 - int h; /* Height */
4330 - {
4331 - int block[24];
4332 - int px1, py1; /* Parent window min coords */
4333 - int px2, py2; /* Parent window max coords */
4334 -
4335 - /* Find where the parent window is. */
4336 - block[0] = gui.window_handle;
4337 - swi(Wimp_GetWindowState, 0, block);
4338 - px1 = block[1];
4339 - py1 = block[2];
4340 - px2 = block[3];
4341 - py2 = block[4];
4342 -
4343 - block[0] = sb -> id;
4344 -
4345 - /* Find out how big the scroll window is at the moment. */
4346 - swi(Wimp_GetWindowInfo, 0, ((char_u *)block) + 1);
4347 -
4348 - if (block[13] < w || block[12] > -h)
4349 - {
4350 - /* Current window is too small! */
4351 - if (block[12] > -h)
4352 - block[12] = -h;
4353 - if (block[13] < w)
4354 - block[13] = w;
4355 - swi(Wimp_SetExtent, block[0], block + 11);
4356 - }
4357 -
4358 - /* This works better on the nested_wimp. */
4359 - if (sb-> wp)
4360 - {
4361 - /* This is a vertical scrollbar. */
4362 - block[1] = block[3] = px2 - gui.scrollbar_width + (1 << x_eigen_factor);
4363 - block[2] = 1 + py2 - (y + h) + (1 << y_eigen_factor);
4364 - block[4] = 1 + py2 - y;
4365 - }
4366 - else
4367 - {
4368 - /* This is a horizontal scrollbar. */
4369 - block[2] = block[4] = py1 + gui.scrollbar_height;
4370 - block[1] = px1;
4371 - block[3] = px2 - gui.scrollbar_width;
4372 - }
4373 -
4374 - block[5] = 0;
4375 - block[6] = 0;
4376 - block[7] = -1;
4377 -
4378 - swi(Wimp_OpenWindow, 0, block, 0x4b534154,
4379 - gui.window_handle, /* Parent window handle. */
4380 - (CHILD_FIX_TO_RIGHT << CHILD_LEFT ) |
4381 - (CHILD_FIX_TO_RIGHT << CHILD_RIGHT ) |
4382 - (CHILD_FIX_TO_BOTTOM << CHILD_TOP ) |
4383 - (CHILD_FIX_TO_BOTTOM << CHILD_BOTTOM) |
4384 - (CHILD_SELF_SCROLL << CHILD_SCROLL_X) |
4385 - (CHILD_SELF_SCROLL << CHILD_SCROLL_Y)
4386 - );
4387 - }
4388 -
4389 - /* Create a window with no workarea to place inside editor window.
4390 - * (what happens without the nested wimp?)
4391 - * Data for scrollbar is invalid.
4392 - */
4393 - void
4394 - gui_mch_create_scrollbar(sb, orient)
4395 - scrollbar_T *sb;
4396 - int orient; /* orient is SBAR_HORIZ or SBAR_VERT */
4397 - {
4398 - int bar[] =
4399 - {
4400 - 0, 0, /* Visible area : min X,Y */
4401 - 100, 100, /* max X,Y */
4402 - 0, 0, /* Scroll offsets */
4403 - -1, /* Window in front */
4404 - 0x80800150 | (orient == SBAR_HORIZ ? (1 << 30) : (1 << 28)),
4405 - 0xff070207, /* Colours */
4406 - 0x000c0103, /* More colours */
4407 - 0, -0x4000, /* Workarea extent */
4408 - 0x4000, 0, /* max X,Y */
4409 - 0x00000000, /* No title */
4410 - 0 << 12, /* No workarea button type */
4411 - 1, /* Wimp sprite area */
4412 - 0x00010001, /* Minimum width, height */
4413 - 0, 0, 0, /* Title data (none) */
4414 - 0 /* No icons */
4415 - };
4416 - swi(Wimp_CreateWindow, 0, bar);
4417 - sb -> id = r0;
4418 - }
4419 -
4420 - #if defined(FEAT_WINDOWS) || defined(PROTO)
4421 - void
4422 - gui_mch_destroy_scrollbar(scrollbar_T *sb)
4423 - {
4424 - swi(Wimp_DeleteWindow, 0, & (sb->id));
4425 - sb -> id = -1;
4426 - }
4427 - #endif
4428 -
4429 - void
4430 - gui_mch_set_scrollbar_colors(scrollbar_T *sb)
4431 - {
4432 - /* Always use default RO colour scheme. */
4433 - }
4434 -
4435 - /*
4436 - * Get current mouse coordinates in text window.
4437 - * Note: (0,0) is the bottom left corner, positive y is UP.
4438 - */
4439 - void
4440 - gui_mch_getmouse(x, y)
4441 - int *x;
4442 - int *y;
4443 - {
4444 - int left;
4445 - int top;
4446 - int block[10];
4447 -
4448 - block[0] = gui.window_handle;
4449 - swi(Wimp_GetWindowState, 0, block);
4450 - left = block[1];
4451 - top = block[4];
4452 -
4453 - swi(Wimp_GetPointerInfo, 0, block);
4454 - *x = block[0] - left;
4455 - *y = top - block[1];
4456 - }
4457 -
4458 - /* MouseTo(x, y) */
4459 - void
4460 - gui_mch_setmouse(x, y)
4461 - int x;
4462 - int y;
4463 - {
4464 - }
4465 -
4466 - void
4467 - gui_mch_toggle_tearoffs(enable)
4468 - int enable;
4469 - {
4470 - /* no tearoff menus */
4471 - }
4472 -
4473 - /* Redraw a window's title.
4474 - * For the nested wimp we use the new 'redraw-title-bar' reason code.
4475 - * For older wimps we mark the area of the screen where the title bar
4476 - * is as invalid.
4477 - */
4478 - void
4479 - ro_redraw_title(window)
4480 - int window;
4481 - {
4482 - if (nested_wimp)
4483 - {
4484 - swi(Wimp_ForceRedraw, window, 0x4b534154, 3);
4485 - }
4486 - else
4487 - {
4488 - int block[10];
4489 - int miny;
4490 -
4491 - block[0] = window;
4492 - swi(Wimp_GetWindowState, 0, block);
4493 - miny = block[4];
4494 - swi(Wimp_GetWindowOutline, 0, block);
4495 - swi(Wimp_ForceRedraw, -1,
4496 - block[1], miny,
4497 - block[3], block[4]);
4498 - }
4499 - }
4500 -
4501 - /* Turn a vimmenu_T structure into a wimp menu structure.
4502 - * -1 if resulting menu is empty.
4503 - * Only the children and dname items in the root menu are used.
4504 - */
4505 - int *
4506 - ro_build_menu(menu)
4507 - vimmenu_T *menu;
4508 - {
4509 - int *wimp_menu;
4510 - int width = 4;
4511 - int w;
4512 - int size = 28;
4513 - vimmenu_T *item;
4514 - int *wimp_item;
4515 -
4516 - /* Find out how big the menu is so we can allocate memory for it */
4517 - for (item = menu-> children; item; item = item-> next)
4518 - {
4519 - if (item-> hidden == FALSE && !menu_is_separator(item->name))
4520 - size += 24;
4521 - }
4522 -
4523 - if (size <= 28)
4524 - return (int *) -1; /* No children - shouldn't happen */
4525 -
4526 - wimp_menu = (int *) alloc(size);
4527 -
4528 - wimp_menu[0] = (int) menu-> dname;
4529 - wimp_menu[1] = -1;
4530 - wimp_menu[2] = 0;
4531 - wimp_menu[3] = 0x00070207;
4532 - wimp_menu[5] = 44;
4533 - wimp_menu[6] = 0;
4534 -
4535 - wimp_item = wimp_menu + 7;
4536 -
4537 - for (item = menu-> children; item; item = item-> next)
4538 - {
4539 - if (menu_is_separator(item-> name))
4540 - {
4541 - /* This menu entry is actually a separator. If it is not the first
4542 - * menu entry then mark the previous menu item as needing a dotted
4543 - * line after it.
4544 - */
4545 - if (wimp_item > wimp_menu + 7)
4546 - wimp_item[-6] |= 0x2;
4547 - }
4548 - else if (item-> hidden == FALSE)
4549 - {
4550 - wimp_item[0] = 0;
4551 - wimp_item[1] = item-> children ? (int) ro_build_menu(item) : -1;
4552 - wimp_item[2] = 0x07009131 | (item-> greyed_out << 22);
4553 - wimp_item[3] = (int) item-> dname;
4554 - wimp_item[4] = -1;
4555 - wimp_item[5] = (int) item; /* Stuff the menu address in this unused space */
4556 -
4557 - w = strlen(item-> dname) + 1;
4558 - if (w > width)
4559 - width = w;
4560 - wimp_item += 6;
4561 - }
4562 - }
4563 -
4564 - wimp_menu[4] = (width + 2) * 16;
4565 - wimp_menu[7] |= 0x100; /* Menu title is indirected */
4566 - wimp_item[-6] |= 0x080; /* Last entry in menu */
4567 - return wimp_menu;
4568 - }
4569 -
4570 - static void
4571 - ro_remove_menu(menu)
4572 - int *menu;
4573 - {
4574 - int *item = menu + 7;
4575 -
4576 - if (menu == NULL || menu == (int *) -1)
4577 - return;
4578 -
4579 - for (;;)
4580 - {
4581 - if (item[1] != -1)
4582 - ro_remove_menu((int *) item[1]); /* Remove sub-menu */
4583 - if (item[0] & 0x80)
4584 - break; /* This was the last entry */
4585 - item += 6;
4586 - }
4587 - vim_free(menu);
4588 - }
4589 -
4590 - void
4591 - gui_mch_show_popupmenu(menu)
4592 - vimmenu_T *menu;
4593 - {
4594 - int block[10];
4595 -
4596 - /* Remove the existing menu, if any */
4597 - if (wimp_menu != (int *) -1)
4598 - {
4599 - swi(Wimp_CreateMenu, 0, -1);
4600 - ro_remove_menu(wimp_menu);
4601 - wimp_menu = (int *) -1;
4602 - }
4603 -
4604 - wimp_menu = ro_build_menu(menu);
4605 - if (wimp_menu != (int *) -1)
4606 - {
4607 - swi(Wimp_GetPointerInfo, 0, block);
4608 - swi(Wimp_CreateMenu, 0, wimp_menu, block[0] - 64, block[1] + 64);
4609 - }
4610 - }
4611 -
4612 - /* Run a command using the TaskWindow module.
4613 - * If SHELL_FILTER is set then output is not echoed to the screen,
4614 - * If it is not set, then \r is not sent to the output file.
4615 - */
4616 - int
4617 - gui_mch_call_shell(cmd, options)
4618 - char_u *cmd;
4619 - int options; /* SHELL_FILTER if called by do_filter() */
4620 - /* SHELL_COOKED if term needs cooked mode */
4621 - {
4622 - char_u task_cmd[256]; /* Contains *TaskWindow command. */
4623 - int block[64];
4624 - int reason;
4625 - char_u *out;
4626 - char_u c;
4627 - int old_msg_col;
4628 - char_u *out_redir;
4629 - int length;
4630 - FILE *out_file = NULL;
4631 -
4632 - out_redir = strstr(cmd, " > ");
4633 - if (out_redir == NULL)
4634 - length = strlen(cmd); /* No redirection. */
4635 - else
4636 - {
4637 - length = out_redir - cmd;
4638 - out_file = fopen(out_redir + 3, "wb");
4639 - if (out_file == NULL)
4640 - smsg("WARNING : Can't open file %s for writing\n", out_redir + 3);
4641 - }
4642 -
4643 - if (length > 180)
4644 - {
4645 - if (out_file)
4646 - fclose(out_file);
4647 - return FAIL; /* Command too long. */
4648 - }
4649 -
4650 - strcpy(task_cmd, "TaskWindow \"");
4651 - strncpy(task_cmd + 12, cmd, length);
4652 - sprintf(task_cmd + 12 + length,
4653 - "\" -task &%08x -ctrl -quit -name \"Vim command\"",
4654 - task_handle);
4655 -
4656 - if (options & SHELL_COOKED)
4657 - settmode(TMODE_COOK);
4658 -
4659 - if (xswi(Wimp_StartTask, task_cmd) & v_flag)
4660 - {
4661 - /* Failed to even start a new task (out of memory?) */
4662 - settmode(TMODE_RAW);
4663 - if (out_file)
4664 - fclose(out_file);
4665 - return FAIL;
4666 - }
4667 -
4668 - /* Wait for the child process to initialise. */
4669 - child_handle = 0;
4670 - while (!child_handle)
4671 - {
4672 - reason = wimp_poll(0, block);
4673 - if ((reason == 17 || reason == 18) && block[4] == 0x808c2)
4674 - child_handle = block[1];
4675 - else
4676 - process_event(reason, block);
4677 - }
4678 -
4679 - /* Block until finished */
4680 - while (child_handle)
4681 - {
4682 - reason = wimp_poll(1, block);
4683 - if (reason == 3 || (reason == 8 && block[6] == 3))
4684 - {
4685 - /* Close window request or CTRL-C - kill child task. */
4686 - block[0] = 20;
4687 - block[3] = 0;
4688 - block[4] = 0x808c4; /* Morite */
4689 - swi(Wimp_SendMessage, 17, block, child_handle);
4690 - MSG_PUTS(_("\nSending message to terminate child process.\n"));
4691 - continue;
4692 - }
4693 - else if (reason == 8)
4694 - {
4695 - block[0] = 28;
4696 - block[3] = 0;
4697 - block[4] = 0x808c0; /* Input */
4698 - block[5] = 1;
4699 - /* Block[6] is OK as it is! */
4700 - swi(Wimp_SendMessage, 17, block, child_handle);
4701 - continue;
4702 - }
4703 - else if (reason == 17 || reason == 18)
4704 - {
4705 - if (block[4] == 0x808c1)
4706 - {
4707 - /* Ack message. */
4708 - block[3] = block[2];
4709 - swi(Wimp_SendMessage, 19, block, block[1]);
4710 - out = (char_u *)block + 24;
4711 - old_msg_col = msg_col;
4712 - while (block[5]--)
4713 - {
4714 - c = *out++;
4715 - if (out_file && (c != '\r' || (options & SHELL_FILTER)))
4716 - fputc(c, out_file);
4717 - if ((options & SHELL_FILTER) == 0)
4718 - {
4719 - if (c == 127)
4720 - msg_puts("\b \b");
4721 - else if (c > 31)
4722 - msg_putchar(c);
4723 - else if (c == 10)
4724 - {
4725 - lines_left = 8; /* Don't do More prompt! */
4726 - msg_putchar(10);
4727 - }
4728 - }
4729 - }
4730 - /* Flush output to the screen. */
4731 - windgoto(msg_row, msg_col);
4732 - out_flush();
4733 - continue;
4734 - }
4735 - }
4736 - process_event(reason, block);
4737 - }
4738 - msg_putchar('\n');
4739 - settmode(TMODE_RAW);
4740 - if (out_file)
4741 - fclose(out_file);
4742 - return OK;
4743 - }
4744 -
4745 - /* Like strsave(), but stops at any control char */
4746 - char_u *
4747 - wimp_strsave(str)
4748 - char *str;
4749 - {
4750 - int strlen = 0;
4751 - char_u *retval;
4752 - while (str[strlen] > 31)
4753 - strlen++;
4754 - retval = alloc(strlen + 1);
4755 - if (retval)
4756 - {
4757 - memcpy(retval, str, strlen);
4758 - retval[strlen] = '\0';
4759 - }
4760 - return retval;
4761 - }
4762 -
4763 - /* If we are saving then pop up a standard RISC OS save box.
4764 - * Otherwise, open a directory viewer on the given directory (and return NULL)
4765 - * The string we return will be freed later.
4766 - */
4767 - char_u *
4768 - gui_mch_browse(saving, title, dflt, ext, initdir, filter)
4769 - int saving; /* write action */
4770 - char_u *title; /* title for the window */
4771 - char_u *dflt; /* default file name */
4772 - char_u *ext; /* extension added */
4773 - char_u *initdir; /* initial directory, NULL for current dir */
4774 - char_u *filter; /* file name filter */
4775 - {
4776 - char command[256];
4777 - int length;
4778 -
4779 - if (saving)
4780 - {
4781 - int block[64];
4782 - int reason;
4783 - int done_save = FALSE;
4784 - char_u *retval = NULL;
4785 - char_u *sprname;
4786 - char_u *fname;
4787 - int dragging_icon = FALSE;
4788 - int filetype;
4789 -
4790 - if (!dflt)
4791 - dflt = "TextFile";
4792 -
4793 - block[0] = save_window;
4794 - block[1] = 0;
4795 - swi(Wimp_GetIconState, 0, block);
4796 - sprname = ((char_u *) block[7]);
4797 - block[1] = 1;
4798 - swi(Wimp_GetIconState, 0, block);
4799 - fname = ((char *) block[7]);
4800 - strncpy(fname, dflt, 255);
4801 -
4802 - if (xswi(OS_FSControl, 31, curbuf->b_p_oft) & v_flag)
4803 - {
4804 - filetype = 0xfff;
4805 - strcpy(sprname + 5, "xxx");
4806 - }
4807 - else
4808 - {
4809 - filetype = r2;
4810 - sprintf(sprname + 5, "%03x", filetype);
4811 - }
4812 -
4813 - /* Open the save box */
4814 -
4815 - swi(Wimp_GetPointerInfo, 0, block);
4816 - swi(Wimp_CreateMenu, 0, save_window, block[0] - 64, block[1] + 64);
4817 - swi(Wimp_SetCaretPosition, save_window, 1, 0, 0, -1, -1);
4818 -
4819 - while (!done_save)
4820 - {
4821 - reason = wimp_poll(1, block);
4822 - switch (reason)
4823 - {
4824 - case 1:
4825 - redraw_window(block);
4826 - break;
4827 - case 2:
4828 - if (block[0] == save_window)
4829 - swi(Wimp_OpenWindow, 0, block);
4830 - else
4831 - ro_open_window(block);
4832 - break;
4833 - case 3:
4834 - done_save = TRUE;
4835 - break;
4836 - case 6:
4837 - if (block[3] != save_window)
4838 - done_save = TRUE;
4839 - else
4840 - {
4841 - int drag_box[4];
4842 - int min_x, max_y;
4843 -
4844 - switch (block[4])
4845 - {
4846 - case 0: /* Start drag */
4847 - block[0] = save_window;
4848 - swi(Wimp_GetWindowState, 0, block);
4849 - min_x = block[1];
4850 - max_y = block[4];
4851 - block[1] = 0;
4852 - swi(Wimp_GetIconState, 0, block);
4853 - drag_box[0] = block[2] + min_x;
4854 - drag_box[1] = block[3] + max_y;
4855 - drag_box[2] = block[4] + min_x;
4856 - drag_box[3] = block[5] + max_y;
4857 -
4858 - swi(DragASprite_Start,
4859 - 0x45,
4860 - 1,
4861 - sprname,
4862 - drag_box);
4863 - dragging_icon = TRUE;
4864 - break;
4865 - case 2: /* OK */
4866 - retval = wimp_strsave(fname);
4867 - done_save = TRUE;
4868 - break;
4869 - case 3: /* Cancel */
4870 - done_save = TRUE;
4871 - break;
4872 - }
4873 - }
4874 - break;
4875 - case 7:
4876 - if (dragging_icon)
4877 - {
4878 - int len = 0;
4879 -
4880 - dragging_icon = FALSE;
4881 - swi(Wimp_GetPointerInfo, 0, block);
4882 - block[5] = block[3];
4883 - block[6] = block[4];
4884 - block[7] = block[0];
4885 - block[8] = block[1];
4886 - block[9] = 0; /* Don't know the size */
4887 - block[10] = filetype;
4888 -
4889 - while (fname[len] > 31)
4890 - {
4891 - if (fname[len] == '.')
4892 - {
4893 - fname += len + 1;
4894 - len = 0;
4895 - }
4896 - else
4897 - len++;
4898 - }
4899 - if (len > 211)
4900 - len = 211;
4901 -
4902 - memcpy(((char_u *) block) + 44, fname, len);
4903 - ((char_u *)block)[44 + len] = '\0';
4904 -
4905 - block[0] = (len + 48) & 0xfc;
4906 - block[3] = 0;
4907 - block[4] = 1; /* DataSave */
4908 -
4909 - swi(Wimp_SendMessage, 17, block, block[5], block[6]);
4910 - }
4911 - else
4912 - ro_drag_finished(block);
4913 - break;
4914 - case 8:
4915 - if (block[6] == 13)
4916 - {
4917 - retval = wimp_strsave(fname);
4918 - done_save = TRUE;
4919 - }
4920 - else if (block[6] == 0x1b)
4921 - done_save = TRUE;
4922 - else
4923 - swi(Wimp_ProcessKey, block[6]);
4924 - break;
4925 - case 17:
4926 - case 18:
4927 - if (block[4] == 2 && block[9] != -1)
4928 - {
4929 - /* DataSaveAck from dragging icon. */
4930 - retval = wimp_strsave(((char_u *) block) + 44);
4931 - done_save = TRUE;
4932 - }
4933 - else if (block[4] == 0x400c9)
4934 - {
4935 - /* MenusDeleted */
4936 - done_save = TRUE;
4937 - }
4938 - else
4939 - ro_message(block);
4940 - break;
4941 - }
4942 - }
4943 - block[0] = save_window;
4944 - swi(Wimp_CloseWindow, 0, block);
4945 - swi(Wimp_GetCaretPosition, 0, block);
4946 - if (block[0] == -1)
4947 - swi(Wimp_SetCaretPosition, gui.window_handle, -1, 0, 0, -1, -1);
4948 -
4949 - return retval;
4950 - }
4951 - else if (initdir)
4952 - {
4953 - /* Open a directory viewer */
4954 - length = strlen(initdir);
4955 -
4956 - if (length > 240)
4957 - return NULL; /* Path too long! */
4958 -
4959 - length = sprintf(command, "Filer_OpenDir %s", initdir);
4960 - while (command[length - 1] == '.')
4961 - length--;
4962 - command[length] = '\0';
4963 - swi(OS_CLI, command);
4964 - }
4965 - return NULL;
4966 - }
4967 --- 0 ----
4968 *** ../vim-7.3.186/src/os_riscos.c 2010-08-15 21:57:27.000000000 +0200
4969 --- src/os_riscos.c 1970-01-01 01:00:00.000000000 +0100
4970 ***************
4971 *** 1,1292 ****
4972 - /* vi:set ts=8 sts=4 sw=4:
4973 - *
4974 - * VIM - Vi IMproved by Bram Moolenaar
4975 - *
4976 - * Do ":help uganda" in Vim to read copying and usage conditions.
4977 - * Do ":help credits" in Vim to see a list of people who contributed.
4978 - * See README.txt for an overview of the Vim source code.
4979 - */
4980 -
4981 - #include "vim.h"
4982 -
4983 - /*
4984 - * os_riscos.c
4985 - *
4986 - * Thomas Leonard <tal197@ecs.soton.ac.uk>
4987 - */
4988 -
4989 - const char *__dynamic_da_name = "Vim heap"; /* Enable and name our dynamic area */
4990 - int ro_line_mode = TRUE; /* For Ex mode we much echo chars to the screen ourselves */
4991 - int windowed; /* Flag - are we running inside a text window? */
4992 - int WinLeft, WinTop; /* We might be started inside a text window */
4993 - int ScrollTop; /* Make cursor movements relative to ScrollTop. */
4994 -
4995 - int old_escape_state = -1;
4996 - int old_cursor_state = -1;
4997 -
4998 - #define rgb(r,g,b) ((b<<24) + (g<<16) + (r<<8))
4999 - #define NORMAL_FG 0x00000000
5000 - #define NORMAL_BG 0xffffffff
5001 -
5002 - /* Convert a DOS colour number to an RGB palette entry.
5003 - * Mappings from X11 rgb/txt file.
5004 - */
5005 - static int
5006 - map_colour(dos)
5007 - int dos; /* Standard DOS colour number. */
5008 - {
5009 - switch (dos)
5010 - {
5011 - case 0: return 0; /* Black */
5012 - case 1: return rgb(0,0,139); /* DarkBlue */
5013 - case 2: return rgb(0,100,0); /* DarkGreen */
5014 - case 3: return rgb(0,139,139); /* DarkCyan */
5015 - case 4: return rgb(139,0,0); /* DarkRed */
5016 - case 5: return rgb(139,0,139); /* DarkMagenta */
5017 - case 6: return rgb(165,42,42); /* Brown, DarkYellow */
5018 - case 7: return rgb(211,211,211); /* LightGray, LightGrey, Gray, Grey */
5019 - case 8: return rgb(169,169,169); /* DarkGray, DarkGrey */
5020 - case 9: return rgb(173,216,230); /* Blue, LightBlue */
5021 - case 10: return rgb(144,238,144); /* Green, LightGreen */
5022 - case 11: return rgb(224,255,255); /* Cyan, LightCyan */
5023 - case 12: return rgb(255,0,0); /* Red, LightRed */
5024 - case 13: return rgb(255,0,255); /* Magenta, LightMagenta */
5025 - case 14: return rgb(255,255,0); /* Yellow, LightYellow */
5026 - case 15: return rgb(255,255,255); /* White */
5027 - }
5028 - return rgb(100,100,100);
5029 - }
5030 -
5031 - static void
5032 - text_fg(fg)
5033 - int fg; /* Foregound colour in the form &BBGGRR00 */
5034 - {
5035 - xswi(ColourTrans_SetTextColour, fg, 0, 0, 0);
5036 - }
5037 -
5038 - static void
5039 - text_bg(bg)
5040 - int bg; /* Backgound colour in the form &BBGGRR00 */
5041 - {
5042 - xswi(ColourTrans_SetTextColour, bg, 0, 0, 1 << 7);
5043 - }
5044 -
5045 - #define OUT_NORMAL 0
5046 - #define OUT_NUMBER 1 /* Reading in a number */
5047 -
5048 - void
5049 - mch_write(s, len)
5050 - char_u *s;
5051 - int len;
5052 - {
5053 - static int mode = OUT_NORMAL;
5054 - static int x, y; /* For reading numbers in. */
5055 -
5056 - if (!term_console)
5057 - {
5058 - /* Maybe we are running Vim remotely - don't interpret chars */
5059 - while (len--)
5060 - {
5061 - char_u c = *s++;
5062 - swi(OS_WriteC, c);
5063 - /* We might need to send a CR too. This shouldn't
5064 - * hurt if we don't need it, should it?
5065 - */
5066 - if (c == 10)
5067 - swi(OS_WriteI + 13);
5068 - }
5069 - return;
5070 - }
5071 -
5072 - while (len--)
5073 - {
5074 - char_u c = *s++;
5075 - switch (mode)
5076 - {
5077 - case OUT_NUMBER:
5078 - if (c < '0' || c > '9')
5079 - {
5080 - mode = OUT_NORMAL;
5081 - }
5082 - else
5083 - {
5084 - x = (x * 10) + c - '0';
5085 - continue;
5086 - }
5087 - /* note: no break here! */
5088 -
5089 - case OUT_NORMAL:
5090 - switch (c)
5091 - {
5092 - case 1:
5093 - /* Number (in decimal) follows. */
5094 - mode = OUT_NUMBER;
5095 - y = x;
5096 - x = 0;
5097 - break;
5098 - case 2:
5099 - /* Position cursor. */
5100 - swi(OS_WriteI + 31);
5101 - swi(OS_WriteC, x);
5102 - swi(OS_WriteC, y - ScrollTop);
5103 - break;
5104 - case 3:
5105 - /* Set scroll region. */
5106 - if (x == Rows -1 && y == 0 && !windowed)
5107 - {
5108 - /* Whole screen - remove text window.
5109 - * This is MUCH faster.
5110 - */
5111 - swi(OS_WriteI + 26);
5112 - }
5113 - else
5114 - {
5115 - /* Create a text window. */
5116 - swi(OS_WriteI + 28);
5117 - swi(OS_WriteC, WinLeft);
5118 - swi(OS_WriteC, WinTop + x);
5119 - swi(OS_WriteC, WinLeft + Columns - 1);
5120 - swi(OS_WriteC, WinTop + y);
5121 - }
5122 - ScrollTop = y;
5123 - break;
5124 - case 4:
5125 - /* Normal mode. */
5126 - text_fg(NORMAL_FG);
5127 - text_bg(NORMAL_BG);
5128 - break;
5129 - case 5:
5130 - /* Reverse mode. */
5131 - text_fg(NORMAL_BG);
5132 - text_bg(NORMAL_FG);
5133 - break;
5134 - case 10:
5135 - swi(OS_NewLine);
5136 - break;
5137 - case 14:
5138 - /* Cursor invisible. */
5139 - swi(OS_WriteN,
5140 - "\027\001\000\000\000\000\000\000\000\000",
5141 - 10);
5142 - break;
5143 - case 15:
5144 - /* Cursor visible. */
5145 - swi(OS_WriteN,
5146 - "\027\001\002\000\000\000\000\000\000\000",
5147 - 10);
5148 - break;
5149 - case 16:
5150 - /* Cursor very visible (flash) */
5151 - swi(OS_WriteN,
5152 - "\027\001\003\000\000\000\000\000\000\000",
5153 - 10);
5154 - case 17:
5155 - /* Set foreground colour. */
5156 - text_fg(map_colour(x));
5157 - break;
5158 - case 18:
5159 - /* Set background colour. */
5160 - text_bg(map_colour(x));
5161 - break;
5162 - case 19:
5163 - /* Scroll text down. */
5164 - swi(OS_WriteN,
5165 - "\027\007\000\002\000\000\000\000\000\000",
5166 - 10);
5167 - break;
5168 - default:
5169 - swi(OS_WriteC, c);
5170 - }
5171 - continue;
5172 -
5173 - default:
5174 - printf("[output error]");
5175 - mode = OUT_NORMAL;
5176 - }
5177 - }
5178 - }
5179 -
5180 - /*
5181 - * mch_inchar(): low level input funcion.
5182 - * Get a characters from the keyboard.
5183 - * Return the number of characters that are available.
5184 - * If wtime == 0 do not wait for characters.
5185 - * If wtime == n wait n msecs for characters.
5186 - * If wtime == -1 wait forever for characters.
5187 - *
5188 - * TODO: call convert_input() for 'fileencoding' to 'encoding' conversion.
5189 - */
5190 - int
5191 - mch_inchar(buf, maxlen, wtime, tb_change_cnt)
5192 - char_u *buf;
5193 - int maxlen;
5194 - long wtime;
5195 - int tb_change_cnt;
5196 - {
5197 - int got=0;
5198 - unsigned int start_time = clock();
5199 -
5200 - if (ro_line_mode)
5201 - {
5202 - /* We're probably in Ex mode - get whole lines at a time. */
5203 -
5204 - static char_u line_buffer[256];
5205 - static int remaining_chars = 0;
5206 - static int buf_pos = 0;
5207 -
5208 - /* Do we need to fetch another line? */
5209 - if (remaining_chars == 0)
5210 - {
5211 - int old_esc_state;
5212 - swi(OS_Byte, 200, 1, 0xfe);
5213 - old_esc_state = r1;
5214 -
5215 - buf_pos = 0;
5216 - if (xswi(OS_ReadLine, line_buffer, 255, 0, 255) & (c_flag | v_flag))
5217 - {
5218 - got_int = TRUE; /* ESC pressed */
5219 - r1 = 0;
5220 - }
5221 - line_buffer[r1] = 13;
5222 - remaining_chars = r1 + 1; /* Count CR as part of input */
5223 -
5224 - swi(OS_Byte, 200, old_esc_state, 0);
5225 - }
5226 -
5227 - /* Can we send the rest of the buffer back in one go? */
5228 - if (remaining_chars <= maxlen)
5229 - {
5230 - int got = remaining_chars;
5231 -
5232 - memcpy(buf, line_buffer + buf_pos, got);
5233 - remaining_chars = 0;
5234 - return got;
5235 - }
5236 -
5237 - /* Send as much as we can */
5238 - memcpy(buf, line_buffer + buf_pos, maxlen);
5239 - buf_pos += maxlen;
5240 - remaining_chars -= maxlen;
5241 -
5242 - return maxlen;
5243 - }
5244 -
5245 - if (!term_console)
5246 - {
5247 - /* Use OS_ReadC for all input.
5248 - * Avoids problems with remote access getting interference from
5249 - * the keyboard.
5250 - */
5251 - if (wtime == 0)
5252 - return 0; /* Ignore quick key checks */
5253 -
5254 - if (xswi(OS_ReadC) & c_flag)
5255 - {
5256 - got_int = TRUE; /* ESC pressed - can this happen? */
5257 - swi(OS_Byte, 124); /* Clear Escape state */
5258 - r0 = 0x1b; /* It *might* not have been Escape! */
5259 - }
5260 - buf[0] = r0;
5261 - return 1;
5262 - }
5263 -
5264 - /*
5265 - * OK, here's the plan:
5266 - *
5267 - * 1) Wait until wtime expires or we get a key
5268 - * 2) Get keys until the keyboard buffer is empty or buf is full
5269 - */
5270 -
5271 - while (xswi(OS_Byte,145,0) & c_flag)
5272 - {
5273 - /* Nothing at all in the keyboard buffer.
5274 - * Has our time expired yet?
5275 - */
5276 - if ( (wtime != -1) && (clock() - start_time) >= wtime )
5277 - return 0; /* Nothing read - giving up */
5278 - }
5279 -
5280 - /* We've got one char (in r2) - are there any more? */
5281 -
5282 - while (got < maxlen)
5283 - {
5284 - buf[got++] = r2;
5285 -
5286 - if (xswi(OS_Byte,145,0) & c_flag)
5287 - return got; /* Keyboard buffer empty */
5288 - }
5289 - return got; /* buf is full */
5290 - }
5291 -
5292 - /*
5293 - * return non-zero if a character is available
5294 - */
5295 - int
5296 - mch_char_avail()
5297 - {
5298 - if (!term_console)
5299 - return 0; /* Can't tell */
5300 - if (xswi(OS_Byte, 152, 0) & c_flag)
5301 - return 0;
5302 - return 1;
5303 - }
5304 -
5305 - /* Find out how much free memory we have.
5306 - * I don't know how to work this out exactly but, since we can claim
5307 - * more memory from the OS, let's just report the free pool size.
5308 - * Dynamic area 6 doesn't exist pre 3.6 according to StrongHelp, so
5309 - * we'll use Wimp_SlotSize. If that fails (outside the desktop?)
5310 - * then just return a big number and hope.
5311 - */
5312 - long_u
5313 - mch_avail_mem(special)
5314 - int special;
5315 - {
5316 - if (xswi(Wimp_SlotSize, -1, -1) & v_flag)
5317 - return 0x7fffffff;
5318 - return r2;
5319 - }
5320 -
5321 - void
5322 - mch_delay(msec, ignoreinput)
5323 - long msec;
5324 - int ignoreinput;
5325 - {
5326 - int start_time, time_now;
5327 - int csec = msec / 10;
5328 -
5329 - swi(OS_ReadMonotonicTime);
5330 - start_time = r0;
5331 -
5332 - for (;;)
5333 - {
5334 - swi(OS_ReadMonotonicTime);
5335 - time_now = r0;
5336 - if (time_now - start_time > csec)
5337 - return;
5338 - #ifdef FEAT_GUI
5339 - /* In the GUI, allow other programs to run while waiting. */
5340 - if (gui.in_use)
5341 - gui_mch_wait_for_chars(start_time + csec);
5342 - #endif
5343 - }
5344 - }
5345 -
5346 - /*
5347 - * If the machine has job control, use it to suspend the program,
5348 - * otherwise fake it by starting a new shell.
5349 - */
5350 - void
5351 - mch_suspend()
5352 - {
5353 - suspend_shell();
5354 - }
5355 -
5356 - void
5357 - mch_init()
5358 - {
5359 - /*
5360 - * Read window size first. Calls to mch_get_shellsize() will
5361 - * simply return these values in future so that setting the
5362 - * text window (used for scrolling) won't give strange results.
5363 - */
5364 -
5365 - int buf[7] = {132, 135, 256, 257, 1, 2, -1};
5366 -
5367 - /* Command windows are no longer forced open, since if we are
5368 - * in the desktop then we'll use the GUI version.
5369 - * Opening a command window here messes up the GUI version startup
5370 - */
5371 - #ifndef FEAT_GUI
5372 - swi(OS_WriteI);
5373 - #endif
5374 - swi(OS_ReadVduVariables, buf, buf);
5375 - WinLeft = buf[0];
5376 - WinTop = buf[1];
5377 - Columns = buf[2];
5378 - Rows = buf[3] + 1; /* Seems to be one off (VduVars wrong?) */
5379 - ScrollTop = 0;
5380 -
5381 - /* Are we running in a textwindow? */
5382 - if (Rows == buf[5] + 1 && Columns == buf[4] + 1)
5383 - windowed = 0;
5384 - else
5385 - windowed = 1;
5386 -
5387 - /* Choose a nice colour scheme. */
5388 - text_fg(NORMAL_FG);
5389 - text_bg(NORMAL_BG);
5390 - }
5391 -
5392 - /*
5393 - * Check_win checks whether we have an interactive stdout.
5394 - */
5395 - /* ARGSUSED */
5396 - int
5397 - mch_check_win(argc, argv)
5398 - int argc;
5399 - char **argv;
5400 - {
5401 - return OK;
5402 - }
5403 -
5404 - /*
5405 - * Return TRUE if the input comes from a terminal, FALSE otherwise.
5406 - */
5407 - int
5408 - mch_input_isatty()
5409 - {
5410 - if (xswi(OS_ChangeRedirection, -1, -1) & v_flag)
5411 - return TRUE; /* Error - TRUE is probably correct though */
5412 - if (r0 == 0)
5413 - return TRUE;
5414 - return FALSE;
5415 - }
5416 -
5417 - #ifdef FEAT_TITLE
5418 - int
5419 - mch_can_restore_title()
5420 - {
5421 - return FALSE;
5422 - }
5423 -
5424 - int
5425 - mch_can_restore_icon()
5426 - {
5427 - return FALSE;
5428 - }
5429 -
5430 -
5431 - /*
5432 - * Set the window title and icon.
5433 - */
5434 - void
5435 - mch_settitle(title, icon)
5436 - char_u *title;
5437 - char_u *icon;
5438 - {
5439 - if (title == NULL)
5440 - title = (char_u *) "<untitled>";
5441 - #ifdef FEAT_GUI
5442 - if (gui.in_use && strcmp(title, gui.window_title))
5443 - {
5444 - int length;
5445 - length = strlen(title);
5446 - if (length >= gui.window_title_size)
5447 - length = gui.window_title_size - 1;
5448 - strncpy(gui.window_title, title, length);
5449 - gui.window_title[length] = 0;
5450 - ro_redraw_title(gui.window_handle);
5451 - }
5452 - #endif
5453 - return;
5454 - }
5455 -
5456 - /*
5457 - * Restore the window/icon title.
5458 - * "which" is one of:
5459 - * 1 only restore title
5460 - * 2 only restore icon
5461 - * 3 restore title and icon
5462 - */
5463 - void
5464 - mch_restore_title(which)
5465 - int which;
5466 - {
5467 - return;
5468 - }
5469 - #endif
5470 -
5471 - /*
5472 - * Insert user name in s[len].
5473 - * Return OK if a name found.
5474 - */
5475 - int
5476 - mch_get_user_name(s, len)
5477 - char_u *s;
5478 - int len;
5479 - {
5480 - /* RISC OS doesn't support user names. */
5481 - *s = NUL;
5482 - return FAIL;
5483 - }
5484 -
5485 - /*
5486 - * Insert host name in s[len].
5487 - */
5488 -
5489 - void
5490 - mch_get_host_name(s, len)
5491 - char_u *s;
5492 - int len;
5493 - {
5494 - if (xswi(OS_ReadVarVal, "Machine$Name", s, len, 0, 3) & v_flag)
5495 - {
5496 - /* Variable does not exist (normal operation) */
5497 - vim_strncpy(s, "(unknown)", len - 1);
5498 - }
5499 - }
5500 -
5501 - /*
5502 - * return process ID
5503 - */
5504 - long
5505 - mch_get_pid()
5506 - {
5507 - if (xswi(Wimp_ReadSysInfo, 5) & v_flag)
5508 - return 0;
5509 - return r0;
5510 - }
5511 -
5512 - /*
5513 - * Get name of current directory into buffer 'buf' of length 'len' bytes.
5514 - * Return OK for success, FAIL for failure.
5515 - */
5516 - int
5517 - mch_dirname(buf, len)
5518 - char_u *buf;
5519 - int len;
5520 - {
5521 - if (xswi(OS_FSControl, 37, "@", buf, 0, 0, len) & v_flag)
5522 - return FAIL;
5523 - return OK;
5524 - }
5525 -
5526 - /*
5527 - * Get absolute file name into buffer 'buf' of length 'len' bytes.
5528 - *
5529 - * return FAIL for failure, OK for success
5530 - */
5531 - int
5532 - mch_FullName(fname, buf, len, force)
5533 - char_u *fname, *buf;
5534 - int len;
5535 - int force; /* Also expand when already absolute path name.
5536 - * Not used under RISC OS.
5537 - */
5538 - {
5539 - if (xswi(OS_FSControl, 37, fname, buf, 0, 0, len) & v_flag)
5540 - return FAIL;
5541 - return OK;
5542 - }
5543 -
5544 - /*
5545 - * Return TRUE if "fname" does not depend on the current directory.
5546 - */
5547 - int
5548 - mch_isFullName(fname)
5549 - char_u *fname;
5550 - {
5551 - if (strstr(fname, "::") && strstr(fname,".$."))
5552 - return TRUE;
5553 - return FALSE;
5554 - }
5555 -
5556 - /*
5557 - * Get file permissions for 'name'.
5558 - * Returns -1 when it doesn't exist.
5559 - */
5560 - long
5561 - mch_getperm(name)
5562 - char_u *name;
5563 - {
5564 - struct stat statb;
5565 -
5566 - if (stat((char *)name, &statb))
5567 - return -1;
5568 - return statb.st_mode;
5569 - }
5570 -
5571 - /*
5572 - * set file permission for 'name' to 'perm'
5573 - *
5574 - * return FAIL for failure, OK otherwise
5575 - */
5576 - int
5577 - mch_setperm(name, perm)
5578 - char_u *name;
5579 - long perm;
5580 - {
5581 - return (chmod((char *)name, (mode_t)perm) == 0 ? OK : FAIL);
5582 - }
5583 -
5584 - /*
5585 - * Set hidden flag for "name".
5586 - */
5587 - /* ARGSUSED */
5588 - void
5589 - mch_hide(name)
5590 - char_u *name;
5591 - {
5592 - /* can't hide a file */
5593 - }
5594 -
5595 - /*
5596 - * return TRUE if "name" is a directory
5597 - * return FALSE if "name" is not a directory
5598 - * return FALSE for error
5599 - */
5600 - int
5601 - mch_isdir(name)
5602 - char_u *name;
5603 - {
5604 - if (xswi(OS_File, 17, name) & v_flag)
5605 - return FALSE;
5606 - if (r0 == 2 || r0 == 3)
5607 - return TRUE; /* Count image files as directories. */
5608 - return FALSE;
5609 - }
5610 -
5611 - /*
5612 - * Return 1 if "name" can be executed, 0 if not.
5613 - * Return -1 if unknown. Requires which to work.
5614 - */
5615 - int
5616 - mch_can_exe(name)
5617 - char_u *name;
5618 - {
5619 - char_u *buf;
5620 - char_u *p;
5621 - int retval;
5622 -
5623 - buf = alloc((unsigned)STRLEN(name) + 7);
5624 - if (buf == NULL)
5625 - return -1;
5626 - sprintf((char *)buf, "which %s", name);
5627 - p = get_cmd_output(buf, NULL, SHELL_SILENT);
5628 - vim_free(buf);
5629 - if (p == NULL)
5630 - return -1;
5631 - /* result can be: "name: Command not found" */
5632 - retval = (*p != NUL && strstr((char *)p, "not found") == NULL);
5633 - vim_free(p);
5634 - return retval;
5635 - }
5636 -
5637 - /*
5638 - * Check what "name" is:
5639 - * NODE_NORMAL: file or directory (or doesn't exist)
5640 - * NODE_WRITABLE: writable device, socket, fifo, etc.
5641 - * NODE_OTHER: non-writable things
5642 - */
5643 - int
5644 - mch_nodetype(name)
5645 - char_u *name;
5646 - {
5647 - /* TODO */
5648 - return NODE_NORMAL;
5649 - }
5650 -
5651 - void
5652 - mch_early_init()
5653 - {
5654 - /* Turn off all the horrible filename munging in UnixLib. */
5655 - int __riscosify_control = __RISCOSIFY_NO_PROCESS;
5656 - }
5657 -
5658 - void
5659 - mch_exit(r)
5660 - int r;
5661 - {
5662 - settmode(TMODE_COOK);
5663 - exiting = TRUE;
5664 - out_flush();
5665 - ml_close_all(TRUE); /* remove all memfiles */
5666 -
5667 - #ifdef FEAT_GUI
5668 - if (gui.in_use)
5669 - gui_exit(r);
5670 - #endif
5671 - swi(OS_NewLine);
5672 - if (old_escape_state != -1)
5673 - swi(OS_Byte, 229, old_escape_state, 0);
5674 - if (old_cursor_state != -1)
5675 - swi(OS_Byte, 4, old_cursor_state);
5676 - exit(r);
5677 - }
5678 -
5679 - void
5680 - mch_settmode(tmode)
5681 - int tmode; /* TMODE_RAW or TMODE_COOK */
5682 - {
5683 - if (tmode == TMODE_COOK)
5684 - {
5685 - ro_line_mode = TRUE;
5686 - return;
5687 - }
5688 -
5689 - ro_line_mode = FALSE;
5690 -
5691 - if (term_console)
5692 - {
5693 - /* Block cursor. */
5694 - swi(OS_WriteN,
5695 - "\027\000\012\000\000\000\000\000\000\000",
5696 - 10);
5697 -
5698 - /* Disable the standard cursor key actions. */
5699 - swi(OS_Byte, 4, 1);
5700 - if (old_cursor_state == -1)
5701 - old_cursor_state = r1;
5702 - }
5703 -
5704 - /* Stop Escape from quitting Vim! */
5705 - swi(OS_Byte, 229, 1, 0);
5706 - if (old_escape_state == -1)
5707 - old_escape_state = r1;
5708 - }
5709 -
5710 - /*
5711 - * set mouse clicks on or off (only works for xterms)
5712 - */
5713 - void
5714 - mch_setmouse(on)
5715 - int on;
5716 - {
5717 - }
5718 -
5719 - /*
5720 - * set screen mode, always fails.
5721 - */
5722 - /* ARGSUSED */
5723 - int
5724 - mch_screenmode(arg)
5725 - char_u *arg;
5726 - {
5727 - EMSG(_(e_screenmode));
5728 - return FAIL;
5729 - }
5730 -
5731 - /*
5732 - * Try to get the current window size.
5733 - * Return OK when size could be determined, FAIL otherwise.
5734 - * Simply return results stored by mch_init() if we are the
5735 - * machine's console. If not, we don't know how big the screen is.
5736 - */
5737 - int
5738 - mch_get_shellsize()
5739 - {
5740 - /* if size changed: screenalloc will allocate new screen buffers */
5741 - return term_console ? OK : FAIL;
5742 - }
5743 -
5744 - /*
5745 - * Can't change the size.
5746 - * Assume the user knows what he's doing and use the new values.
5747 - */
5748 - void
5749 - mch_set_shellsize()
5750 - {
5751 - /* Assume the user knows what he's doing and use the new values. */
5752 - }
5753 -
5754 - /*
5755 - * Rows and/or Columns has changed.
5756 - */
5757 - void
5758 - mch_new_shellsize()
5759 - {
5760 - /* Nothing to do. */
5761 - }
5762 -
5763 - int
5764 - mch_call_shell(cmd, options)
5765 - char_u *cmd;
5766 - int options; /* SHELL_*, see vim.h */
5767 - {
5768 - int retval;
5769 - int tmode = cur_tmode;
5770 -
5771 - if (cmd == NULL)
5772 - cmd = (char_u *) "GOS";
5773 -
5774 - #ifdef FEAT_GUI
5775 - if (gui.in_use)
5776 - return gui_mch_call_shell(cmd, options);
5777 - #endif
5778 - if (options & SHELL_COOKED)
5779 - settmode(TMODE_COOK); /* set to normal mode */
5780 - MSG_PUTS("\n");
5781 -
5782 - /* I don't even want to think about what UnixLib must
5783 - * be doing to allow this to work...
5784 - */
5785 - retval = system(cmd);
5786 - if (retval && !(options & SHELL_SILENT))
5787 - EMSG(strerror(EOPSYS)); /* Doesn't seem to set errno? */
5788 -
5789 - swi(OS_Byte, 229, 1, 0); /* Re-disable escape */
5790 - if (tmode == TMODE_RAW)
5791 - settmode(TMODE_RAW); /* set to raw mode */
5792 - return retval ? FAIL : OK;
5793 - }
5794 -
5795 - /*
5796 - * Check for Escape being pressed right now.
5797 - * [ different if !term_console? ]
5798 - */
5799 - void
5800 - mch_breakcheck()
5801 - {
5802 - if (xswi(OS_Byte, 121, 0xf0) & v_flag)
5803 - return;
5804 - if (r1 == 0xff)
5805 - {
5806 - got_int = TRUE;
5807 - swi(OS_Byte, 15, 1); /* Flush input buffer */
5808 - }
5809 - }
5810 -
5811 - /*
5812 - * Recursively expand one path component into all matching files and/or
5813 - * directories.
5814 - * "path" has backslashes before chars that are not to be expanded.
5815 - * Return the number of matches found.
5816 - */
5817 - int
5818 - mch_expandpath(gap, path, flags)
5819 - garray_T *gap; /* Grow array for results. */
5820 - char_u *path;
5821 - int flags; /* EW_* flags */
5822 - {
5823 - int got; /* Number of matches. */
5824 - char_u *pattern;
5825 -
5826 - /* Plan:
5827 - *
5828 - * 1) Get first part of path - no wildcards
5829 - * 2) Get next path element (wildcarded)
5830 - * 3) Get rest of path
5831 - *
5832 - * If (3) is nothing then only the leaf is wildcarded - add to gap
5833 - * Otherwise call recursively for each path in (2), passing (3)
5834 - *
5835 - * This is just the header function.
5836 - */
5837 -
5838 - /* We must be able to modifiy path, so make a copy */
5839 - pattern = vim_strsave(path);
5840 - if (pattern == NULL)
5841 - return 0;
5842 - got = expand_section(gap, (char_u *)"", pattern, flags);
5843 - vim_free(pattern);
5844 - return got;
5845 - }
5846 -
5847 - /*
5848 - * expand_section(gap, "$.Dir1.Dir2", "ABBA*.myleaf##")
5849 - *
5850 - * calls expand_section(gap, "$.Dir1.Dir2.ABBA_Gold", "myleaf##")
5851 - * and expand_section(gap, "$.Dir1.Dir2.ABBA_Live", "myleaf##")
5852 - *
5853 - * If rest is just a leaf then all matches are added to gap.
5854 - *
5855 - * Returns number of items added to gap.
5856 - */
5857 - int
5858 - expand_section(gap, root, rest, flags)
5859 - garray_T *gap;
5860 - char_u *root; /* Non-wildcarded path to search */
5861 - char_u *rest; /* Wildcarded remainder of path */
5862 - int flags; /* Add dirs/files/missing objects. */
5863 - {
5864 - static char_u buf[MAXPATHL]; /* Temporary buffer. */
5865 - char_u dir[MAXPATHL];
5866 - int start_element = -1; /* Start of wildcarded element */
5867 - char_u c;
5868 - int i;
5869 - int got, dir_pos;
5870 - int buflen; /* Chars used in buf[] */
5871 - int colon = 0; /* Dir ends in ':' */
5872 -
5873 - buflen = strlen(root);
5874 - STRNCPY(buf, root, buflen); /* Copy root into buffer. */
5875 -
5876 - /*
5877 - * Find end of nonwildcarded section.
5878 - * Count ':' as a path sep since Vim:Bug* is a valid pathname.
5879 - */
5880 -
5881 - for (i = 0; c = rest[i]; i++)
5882 - {
5883 - if (c == PATHSEP)
5884 - {
5885 - start_element = i;
5886 - colon = 0;
5887 - }
5888 - if (c == ':')
5889 - {
5890 - start_element = i + 1;
5891 - colon = 1;
5892 - }
5893 - if (c == '#' || c == '*')
5894 - break;
5895 - }
5896 - if (c == 0)
5897 - start_element = i;
5898 -
5899 - /*
5900 - * start_element +> terminator for non-wildcarded section.
5901 - * Transfer this bit into buf.
5902 - */
5903 - if (buflen + start_element + 4 >= MAXPATHL)
5904 - return 0; /* Buffer full */
5905 - if (start_element >= 0)
5906 - {
5907 - if (*root && !colon)
5908 - buf[buflen++] = PATHSEP;
5909 - strncpy(buf + buflen, rest, start_element);
5910 - buflen += start_element;
5911 - }
5912 - buf[buflen] = 0;
5913 -
5914 - /*
5915 - * Did we reach the end of the string without hitting any wildcards?
5916 - */
5917 - if (c == 0)
5918 - {
5919 - /* Yes - add combined path to grow array and return. */
5920 - addfile(gap, buf, flags);
5921 - return 1;
5922 - }
5923 -
5924 - if (start_element < 0 || !colon)
5925 - start_element++;
5926 - rest += start_element;
5927 -
5928 - /*
5929 - * rest does contain wildcards if we get here.
5930 - *
5931 - * Now : have we reached the leaf names part yet?
5932 - * If so, add all matches (files and dirs) to gap.
5933 - * If not, get next path element and scan all matching directories.
5934 - */
5935 -
5936 - start_element = -1;
5937 - for (i = 0; rest[i]; i++)
5938 - {
5939 - if (rest[i] == '.')
5940 - {
5941 - start_element = i;
5942 - rest[i] = 0; /* Break string here. */
5943 - break;
5944 - }
5945 - }
5946 -
5947 - /* If start_element is -1 then we are matching leaf names */
5948 -
5949 - r3 = 0; /* Number of objs read. */
5950 - dir_pos = 0; /* Position through directory. */
5951 - got = 0; /* Files added so far. */
5952 - while (dir_pos != -1)
5953 - {
5954 - buf[buflen] = 0;
5955 - if (xswi(OS_GBPB, 9,
5956 - buf, /* Directory to scan. */
5957 - buf + buflen + (1 - colon), /* Buffer for result. */
5958 - 1, /* Number of objects to read. */
5959 - dir_pos, /* Search position. */
5960 - MAXPATHL - 2 - buflen, /* Size of result buffer. */
5961 - rest) /* Wildcarded leafname. */
5962 - & v_flag)
5963 - {
5964 - EMSG(r0 + 4);
5965 - r4 = -1;
5966 - }
5967 - dir_pos = r4; /* r4 corrupted by addfile() */
5968 - if (r3 > 0)
5969 - {
5970 - char_u *path = buf;
5971 - if (buflen == 0)
5972 - path++; /* Don't do '.File' */
5973 - else if (!colon)
5974 - buf[buflen] = '.'; /* Join path and leaf */
5975 -
5976 - /* Path -> full path of object found */
5977 - if (start_element == -1)
5978 - {
5979 - addfile(gap, path, flags);
5980 - got++;
5981 - }
5982 - else
5983 - {
5984 - /* Scan into subdirectories and images; ignore files */
5985 - swi(OS_File, 17, path);
5986 - if (r0 == 2 || r0 == 3)
5987 - got += expand_section(gap,
5988 - path,
5989 - rest + start_element + 1,
5990 - flags);
5991 - }
5992 - }
5993 - }
5994 -
5995 - /* Restore the dot if we removed it. */
5996 - if (start_element >= 0)
5997 - rest[start_element] = '.';
5998 - return got;
5999 - }
6000 -
6001 - /*
6002 - * mch_expand_wildcards() - this code does wild-card pattern matching using
6003 - * the shell. It isn't used under RISC OS.
6004 - *
6005 - * return OK for success, FAIL for error (you may lose some memory) and put
6006 - * an error message in *file.
6007 - *
6008 - * num_pat is number of input patterns
6009 - * pat is array of pointers to input patterns
6010 - * num_file is pointer to number of matched file names
6011 - * file is pointer to array of pointers to matched file names
6012 - */
6013 - int
6014 - mch_expand_wildcards(num_pat, pat, num_file, file, flags)
6015 - int num_pat;
6016 - char_u **pat;
6017 - int *num_file;
6018 - char_u ***file;
6019 - int flags; /* EW_* flags */
6020 - {
6021 - /* This doesn't get called unless SPECIAL_WILDCHAR is defined. */
6022 - return FAIL;
6023 - }
6024 -
6025 - /*
6026 - * Return TRUE if "p" contains wildcards which can be expanded by
6027 - * mch_expandpath().
6028 - */
6029 - int
6030 - mch_has_exp_wildcard(p)
6031 - char_u *p;
6032 - {
6033 - if (vim_strpbrk((char_u *)"*#", p))
6034 - return TRUE;
6035 - return FALSE;
6036 - }
6037 -
6038 - /* Return TRUE if "p" contains wildcards. */
6039 - int
6040 - mch_has_wildcard(p)
6041 - char_u *p;
6042 - {
6043 - if (vim_strpbrk((char_u *)"*#`", p))
6044 - return TRUE;
6045 - return FALSE;
6046 - }
6047 -
6048 - int /* see Unix unlink(2) */
6049 - mch_remove(file)
6050 - char_u *file; /* Name of file to delete. */
6051 - {
6052 - if (xswi(OS_FSControl, 27, file, 0, 0) & v_flag)
6053 - return EXIT_FAILURE;
6054 - return EXIT_SUCCESS;
6055 - }
6056 -
6057 - /* Try to make existing scripts work without modification.
6058 - * Return a pointer to the new string (freed by caller), or NULL
6059 - *
6060 - * Two main cases:
6061 - * - Absolute : $VIM/syntax/help.vim
6062 - * - Relative : Adfs::4.$.!Vim.Resources.Syntax/help.vim
6063 - */
6064 - char_u *
6065 - mch_munge_fname(fname)
6066 - char_u *fname;
6067 - {
6068 - char_u c;
6069 - int len;
6070 - char_u *retval;
6071 -
6072 - retval = fname = vim_strsave(fname);
6073 - if (fname == NULL)
6074 - return NULL;
6075 -
6076 - if (strncmp(fname, "$VIM/", 5) == 0)
6077 - {
6078 - strncpy(fname, "Vim:", 4);
6079 - for (fname += 5; c = *fname; fname++)
6080 - {
6081 - if (c == '.')
6082 - break;
6083 - if (c == '/')
6084 - fname[-1] = '.';
6085 - else
6086 - fname[-1] = c;
6087 - }
6088 - fname[-1] = '\0';
6089 - }
6090 - else
6091 - {
6092 - /* Check to see if the file exists without modification. */
6093 - if (xswi(OS_File, 17, fname) & v_flag)
6094 - r0 == 0; /* Invalid filename? */
6095 - if (r0)
6096 - return retval;
6097 -
6098 - len = strlen(fname);
6099 - if (strcmp(fname + len - 4, ".vim") == 0)
6100 - {
6101 - fname[len - 4] = '\0';
6102 - for (; c = *fname; fname++)
6103 - {
6104 - if (c == '/')
6105 - *fname = '.';
6106 - }
6107 - }
6108 - }
6109 - return retval;
6110 - }
6111 -
6112 - /* QuickFix reads munged names from the error file.
6113 - * Correct them.
6114 - */
6115 - int
6116 - ro_buflist_add(old_name)
6117 - char_u *old_name; /* Name of file found by quickfix */
6118 - {
6119 - char_u *fname;
6120 - char_u *leaf; /* Pointer to start of leaf in old_name */
6121 - char_u *ptr;
6122 - char_u c;
6123 - int retval;
6124 -
6125 - if (old_name == NULL)
6126 - return buflist_add(NULL, 0);
6127 -
6128 - /* Copy the name so we can mess around with it. */
6129 - fname = vim_strsave(old_name);
6130 - if (fname == NULL)
6131 - /* Out of memory - can't modify name */
6132 - return buflist_add(old_name, 0);
6133 -
6134 - /* Change `dir/main.c' into `dir.c.main' */
6135 - leaf = fname;
6136 - for (ptr = fname; c = *ptr; ptr++)
6137 - {
6138 - if (c == '/')
6139 - {
6140 - leaf = ptr + 1;
6141 - *ptr = '.';
6142 - }
6143 - else if (c == '.')
6144 - break;
6145 - }
6146 - if (c == '.')
6147 - {
6148 - /* Change `main.c' into `c.main'
6149 - * | |
6150 - * leaf ptr
6151 - */
6152 - ptr += old_name - fname;
6153 - *ptr = '\0';
6154 - sprintf(leaf,
6155 - "%s.%s",
6156 - ptr + 1,
6157 - leaf - fname + old_name);
6158 - }
6159 -
6160 - retval = buflist_add(fname, 0);
6161 - free(fname);
6162 - return retval;
6163 - }
6164 -
6165 - /* Change the current directory.
6166 - * Strip trailing dots to make it easier to use with filename completion.
6167 - * Return 0 for success, -1 for failure.
6168 - */
6169 - int
6170 - mch_chdir(dir)
6171 - char_u *dir;
6172 - {
6173 - int length;
6174 - int retval;
6175 - char_u *new_dir;
6176 -
6177 - if (p_verbose >= 5)
6178 - {
6179 - verbose_enter();
6180 - smsg((char_u *)"chdir(%s)", dir);
6181 - verbose_leave();
6182 - }
6183 - length = strlen(dir);
6184 - if (dir[length - 1] != '.')
6185 - return chdir(dir); /* No trailing dots - nothing to do. */
6186 - new_dir = vim_strsave(dir);
6187 - if (new_dir == NULL)
6188 - return chdir(dir); /* Can't allocate memory. */
6189 -
6190 - while (new_dir[--length] == '.')
6191 - new_dir[length] = '\0';
6192 -
6193 - retval = chdir(new_dir);
6194 - vim_free(new_dir);
6195 - return retval;
6196 - }
6197 -
6198 - /* Examine the named file, and set the 'osfiletype' option
6199 - * (in curbuf) to the file's type.
6200 - */
6201 - void
6202 - mch_read_filetype(file)
6203 - char_u *file;
6204 - {
6205 - int type;
6206 - char_u type_string[9];
6207 - int i;
6208 -
6209 - if (xswi(OS_File, 23, file) & v_flag)
6210 - type = 0xfff; /* Default to Text */
6211 - else
6212 - type = r6;
6213 -
6214 - /* Type is the numerical value - see if we have a textual equivalent */
6215 - swi(OS_FSControl, 18, 0, type);
6216 - ((int *) type_string)[0] = r2;
6217 - ((int *) type_string)[1] = r3;
6218 - type_string[8] = 0;
6219 - for (i = 0; type_string[i] > ' '; i++)
6220 - ;
6221 - type_string[i] = 0;
6222 -
6223 - set_string_option_direct("osfiletype", -1, type_string, OPT_FREE, 0);
6224 - return;
6225 - }
6226 -
6227 - void
6228 - mch_set_filetype(file, type)
6229 - char_u *file;
6230 - char_u *type;
6231 - {
6232 - if (xswi(OS_FSControl, 31, type) & v_flag)
6233 - {
6234 - EMSG(_("E366: Invalid 'osfiletype' option - using Text"));
6235 - r2 = 0xfff;
6236 - }
6237 -
6238 - swi(OS_File, 18, file, r2);
6239 - }
6240 -
6241 - /* Return TRUE if the file's type matches 'type'
6242 - * RISC OS types always start with '&'
6243 - */
6244 - int
6245 - mch_check_filetype(fname, type)
6246 - char_u *fname;
6247 - char_u *type;
6248 - {
6249 - int value;
6250 - char *end;
6251 -
6252 - if (*type != '&')
6253 - return FALSE;
6254 -
6255 - value = strtol(type + 1, &end, 16);
6256 - if (*end)
6257 - return FALSE; /* Invalid type (report error?) */
6258 -
6259 - if (xswi(OS_File, 23, fname) & v_flag)
6260 - return FALSE; /* Invalid filename? */
6261 -
6262 - return (r0 && r6 == value);
6263 - }
6264 --- 0 ----
6265 *** ../vim-7.3.186/runtime/doc/os_risc.txt 2010-08-15 21:57:16.000000000 +0200
6266 --- runtime/doc/os_risc.txt 2011-05-10 16:19:25.000000000 +0200
6267 ***************
6268 *** 1,322 ****
6269 ! *os_risc.txt* For Vim version 7.3. Last change: 2010 Aug 07
6270
6271
6272 VIM REFERENCE MANUAL by Thomas Leonard
6273
6274
6275 *riscos* *RISCOS* *RISC-OS*
6276 ! This file contains the particularities for the RISC OS version of Vim.
6277
6278 - The RISC OS port is a completely new port and is not based on the old "archi"
6279 - port.
6280
6281 - 1. File locations |riscos-locations|
6282 - 2. Filename munging |riscos-munging|
6283 - 3. Command-line use |riscos-commandline|
6284 - 4. Desktop (GUI) use |riscos-gui|
6285 - 5. Remote use (telnet) |riscos-remote|
6286 - 6. Temporary files |riscos-temp-files|
6287 - 7. Interrupting |riscos-interrupt|
6288 - 8. Memory usage |riscos-memory|
6289 - 9. Filetypes |riscos-filetypes|
6290 - 10. The shell |riscos-shell|
6291 - 11. Porting new releases |riscos-porting|
6292 -
6293 - If I've missed anything, email me and I'll try to fix it. In fact, even if I
6294 - haven't missed anything then email me anyway to give me some confidence that it
6295 - actually works!
6296 -
6297 - Thomas Leonard <tal197@ecs.soton.ac.uk>
6298 -
6299 - [these URLs no longer work...]
6300 - Port homepage: http://www.ecs.soton.ac.uk/~tal197/
6301 - or try: http://www.soton.ac.uk/~tal197/
6302 -
6303 - ==============================================================================
6304 - *riscos-locations*
6305 - 1. File locations
6306 -
6307 - The Vim executable and shared resource files are all stored inside the !Vim
6308 - application directory.
6309 -
6310 - When !Vim is first seen by the filer, it aliases the *vi and *ex commands to
6311 - run the command-line versions of Vim (see |riscos-commandline|).
6312 -
6313 - !Vim.Resources and !Vim.Resources2 contain the files from the standard Vim
6314 - distribution, but modified slightly to work within the limits of ADFS, plus
6315 - some extra files such as the window templates.
6316 -
6317 - User choices are read from "Choices:*" and are saved to "<Choices$Write>.*".
6318 - If you have the new !Boot structure then these should be set up already. If
6319 - not, set Choices$Path to a list of directories to search when looking for
6320 - user configuration files. Set Choices$Write to the directory you want files
6321 - to be saved into (so your search patterns and marks can be remembered between
6322 - sessions).
6323 -
6324 - ==============================================================================
6325 - *riscos-munging*
6326 - 2. Filename munging
6327 -
6328 - All pathname munging is disabled by default, so Vim should behave like a
6329 - normal RISC OS application now. So, if you want to edit "doc/html" then you
6330 - actually type "*vi doc/html".
6331 -
6332 - The only times munging is done is when:
6333 -
6334 - - Searching included files from C programs, since these are always munged.
6335 - See |[I|.
6336 - Note: make sure you are in the right directory when you use this
6337 - command (i.e. the one with subdirectories "c" and "h").
6338 -
6339 - - Sourcing files using |:so|.
6340 - Paths starting "$VIM/" are munged like this:
6341 -
6342 - $VIM/syntax/help.vim -> Vim:syntax.help
6343 -
6344 - Also, files ending in ".vim" have their extensions removed, and slashes
6345 - replaced with dots.
6346 -
6347 - Some tag files and script files may have to be edited to work under this port.
6348 -
6349 - ==============================================================================
6350 - *riscos-commandline*
6351 - 3. Command-line use
6352 -
6353 - To use Vim from the command-line use the "*vi" command (or "*ex" for
6354 - |Ex-mode|).
6355 -
6356 - Type "*vi -h" for a list of options.
6357 -
6358 - Running the command-line version of Vim in a large high-color mode may cause
6359 - the scrolling to be very slow. Either change to a mode with fewer colors or
6360 - use the GUI version.
6361 -
6362 - Also, holding down Ctrl will slow it down even more, and Ctrl-Shift will
6363 - freeze it, as usual for text programs.
6364 -
6365 - ==============================================================================
6366 - *riscos-gui*
6367 - 4. Desktop use
6368 -
6369 - Limitations:
6370 -
6371 - - Left scrollbars don't work properly (right and bottom are fine).
6372 - - Doesn't increase scroll speed if it gets behind.
6373 -
6374 - You can resize the window by dragging the lower-right corner, even though
6375 - there is no icon shown there.
6376 -
6377 - You can use the --rows and --columns arguments to specify the initial size of
6378 - the Vim window, like this: >
6379 -
6380 - *Vi -g --rows 20 --columns 80
6381 -
6382 - The global clipboard is supported, so you can select some text and then
6383 - paste it directly into another application (provided it supports the
6384 - clipboard too).
6385 -
6386 - Clicking Menu now opens a menu like a normal RISC OS program. Hold down Shift
6387 - when clicking Menu to paste (from the global clipboard).
6388 -
6389 - Dragging a file to the window replaces the CURRENT buffer (the one with the
6390 - cursor, NOT the one you dragged to) with the file.
6391 -
6392 - Dragging with Ctrl held down causes a new Vim window to be opened for the
6393 - file (see |:sp|).
6394 -
6395 - Dragging a file in with Shift held down in insert mode inserts the pathname of
6396 - the file.
6397 -
6398 - :browse :w opens a standard RISC OS save box.
6399 - :browse :e opens a directory viewer.
6400 -
6401 - For fonts, you have the choice of the system font, an outline font, the system
6402 - font via ZapRedraw and any of the Zap fonts via ZapRedraw: >
6403 -
6404 - :set guifont=
6405 - < To use the system font via the VDU drivers. Supports
6406 - bold and underline.
6407 - >
6408 - :set guifont=Corpus.Medium
6409 - < Use the named outline font. You can use any font, but
6410 - only monospaced ones like Corpus look right.
6411 - >
6412 - :set guifont=Corpus.Medium:w8:h12:b:i
6413 - < As before, but with size of 8 point by 12 point, and
6414 - in bold italic.
6415 - If only one of width and height is given then that
6416 - value is used for both. If neither is given then 10
6417 - point is used.
6418 -
6419 - Thanks to John Kortink, Vim can use the ZapRedraw module. Start the font name
6420 - with "!" (or "!!" for double height), like this: >
6421 -
6422 - :set guifont=!!
6423 - < Use the system font, but via ZapRedraw. This gives a
6424 - faster redraw on StrongARM processors, but you can't
6425 - get bold or italic text. Double height.
6426 - >
6427 - :set guifont=!script
6428 - < Uses the named Zap font (a directory in VimFont$Path).
6429 - The redraw is the same speed as for "!!", but you get
6430 - a nicer looking font.
6431 - Only the "man+" and "script" fonts are supplied
6432 - currently, but you can use any of the Zap fonts if
6433 - they are in VimFont$Path.
6434 - Vim will try to load font files "0", "B", "I" and "IB"
6435 - from the named directory. Only "0" (normal style) MUST
6436 - be present. Link files are not currently supported.
6437 -
6438 - Note that when using ZapRedraw the edit bar is drawn in front of the character
6439 - you are on rather than behind it. Also redraw is incorrect for screen modes
6440 - with eigen values of 0. If the font includes control characters then you can
6441 - get Vim to display them by changing the 'isprint' option.
6442 -
6443 - If you find the scrolling is too slow on your machine, try experimenting
6444 - with the 'scrolljump' and 'ttyscroll' options.
6445 -
6446 - In particular, StrongARM users may find that: >
6447 -
6448 - :set ttyscroll=0
6449 -
6450 - makes scrolling faster in high-color modes.
6451 -
6452 - =============================================================================
6453 - *riscos-remote*
6454 - 5. Remote use (telnet)
6455 -
6456 - I have included a built-in termcap entry, but you can edit the termcap file to
6457 - allow other codes to be used if you want to use Vim from a remote terminal.
6458 -
6459 - Although I do not have an internet connection to my Acorn, I have managed to
6460 - run Vim in a FreeTerm window using the loopback connection.
6461 -
6462 - It seems to work pretty well now, using "*vi -T ansi".
6463 -
6464 - ==============================================================================
6465 - *riscos-temp-files*
6466 - 6. Temporary files
6467 -
6468 - If Vim crashes then the swap and backup files (if any) will be in the
6469 - directories set with the 'directory' and 'bdir' options. By default the swap
6470 - files are in <Wimp$ScrapDir> (i.e. inside !Scrap) and backups are in the
6471 - directory you were saving to. Vim will allow you to try and recover the file
6472 - when you next try to edit it.
6473 -
6474 - To see a list of swap files, press <F12> and type "*vi -r".
6475 -
6476 - Vim no longer brings up ATTENTION warnings if you try to edit two files with
6477 - the same name in different directories.
6478 -
6479 - However, it also no longer warns if you try to edit the same file twice (with
6480 - two copies of Vim), though you will still be warned when you save that the
6481 - datestamp has changed.
6482 -
6483 - ==============================================================================
6484 - *riscos-interrupt*
6485 - 7. Interrupting
6486 -
6487 - To break out of a looping macro, or similar, hold down Escape in the
6488 - command-line version, or press CTRL-C in the GUI version.
6489 -
6490 - ==============================================================================
6491 - *riscos-memory*
6492 - 8. Memory usage
6493 -
6494 - Vim will use dynamic areas on RISC OS 3.5 or later. If you can use them on
6495 - older machines then edit the !RunTxt and GVim files. I don't know what UnixLib
6496 - does by default on these machines so I'm playing safe.
6497 -
6498 - It doesn't work at all well without dynamic areas, since it can't change its
6499 - memory allocation once running. Hence you should edit "!Vim.GVim" and
6500 - "!Vim.!RunTxt" to choose the best size for you. You probably need at least
6501 - about 1400K.
6502 -
6503 - ==============================================================================
6504 - *riscos-filetypes*
6505 - 9. Filetypes
6506 -
6507 - You can now specify that autocommands are only executed for files of certain
6508 - types. The filetype is given in the form &xxx, when xxx is the filetype.
6509 -
6510 - Filetypes must be specified by number (e.g. &fff for Text).
6511 -
6512 - The system has changed from version 5.3. The new sequence of events is:
6513 -
6514 - - A file is loaded. |'osfiletype'| is set to the RISC OS filetype.
6515 - - Based on the filetype and pathname, Vim will try to set |'filetype'| to the
6516 - Vim-type of the file.
6517 - - Setting this option may load syntax files and perform other actions.
6518 - - Saving the file will give it a filetype of |'osfiletype'|.
6519 -
6520 - Some examples may make this clearer:
6521 -
6522 - Kind of file loaded osfiletype filetype ~
6523 - C code "c.hellow" Text (&fff) C
6524 - LaTeX document LaTeX (&2a8) TeX
6525 - Draw document DrawFile (&aff) (not changed)
6526 -
6527 - ==============================================================================
6528 - *riscos-shell*
6529 - 10. The shell
6530 -
6531 - - Bangs (!s) are only replaced if they are followed by a space or end-of-line,
6532 - since many pathnames contain them.
6533 -
6534 - - You can prefix the command with "~", which stops any output from being
6535 - displayed. This also means that you don't have to press <Enter> afterwards,
6536 - and stops the screen from being redrawn. {only in the GUI version}
6537 -
6538 - ==============================================================================
6539 - *riscos-porting*
6540 - 11. Porting new releases to RISC OS
6541 -
6542 - Downloading everything you need:
6543 -
6544 - - Get the latest source distribution (see www.vim.org)
6545 - - Get the runtime environment files (e.g. these help files)
6546 - - Get the RISC OS binary distribution (if possible)
6547 -
6548 -
6549 - Unarchiving:
6550 -
6551 - - Create a raFS disk and put the archives on it
6552 - - Un-gzip them
6553 - - Un-tar them (*tar xELf 50 archive/tar)
6554 -
6555 -
6556 - Recompiling the sources:
6557 -
6558 - - Create c, s, and h directories.
6559 - - Put all the header files in "h". \
6560 - - Put all the C files in "c". | And lose the extensions
6561 - - Put the assembler file ("swis/s") in "s". /
6562 - - Rename all the files in "proto" to "h", like this:
6563 - raFS::VimSrc.source.proto.file/pro
6564 - becomes
6565 - raFS::VimSrc.source.h.file_pro
6566 - - In the files "h.proto" and "c.termlib", search and replace
6567 - .pro"
6568 - with
6569 - _pro.h"
6570 - - Create a simple Makefile if desired and do "*make -k".
6571 - Use "CC = gcc -DRISCOS -DUSE_GUI -O2 -x c" in the Makefile.
6572 - - Save the binary as !Vim.Vim in the binary distribution.
6573 -
6574 -
6575 - Updating the run-time environment:
6576 -
6577 - - Replace old or missing files inside !Vim.Resources with the
6578 - new files.
6579 - - Remove files in "doc" not ending in "/txt", except for "tags".
6580 - - Lose the extensions from the files in "doc".
6581 - - Edit the "doc.tags" file. Remove extensions from the second column: >
6582 - :%s/^\(.[^\t]*\t.*\)\.txt\t/\1\t/
6583 - - Remove extensions from the syntax files. Split them into two directories
6584 - to avoid the 77 entry limit on old ADFS filesystems.
6585 - - Edit "Vim:FileType" to match "*.c.*" as well as "*/c" and so on.
6586 - Add filetype checking too.
6587 - - Edit "Vim:Menu" and remove all the keys from the menus: >
6588 - :%s/<Tab>[^ \t]*//
6589 - <
6590 vim:tw=78:ts=8:ft=help:norl:
6591 --- 1,12 ----
6592 ! *os_risc.txt* For Vim version 7.3. Last change: 2011 May 10
6593
6594
6595 VIM REFERENCE MANUAL by Thomas Leonard
6596
6597
6598 *riscos* *RISCOS* *RISC-OS*
6599 ! The RISC OS support has been removed from Vim with patch 7.3.187.
6600 ! If you would like to use Vim on RISC OS get the files from before that patch.
6601
6602
6603 vim:tw=78:ts=8:ft=help:norl:
6604 *** ../vim-7.3.186/src/version.c 2011-05-10 16:12:40.000000000 +0200
6605 --- src/version.c 2011-05-10 16:37:20.000000000 +0200
6606 ***************
6607 *** 716,717 ****
6608 --- 716,719 ----
6609 { /* Add new patch number below this line */
6610 + /**/
6611 + 187,
6612 /**/
6613
6614 --
6615 hundred-and-one symptoms of being an internet addict:
6616 81. At social functions you introduce your husband as "my domain server."
6617
6618 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
6619 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
6620 \\\ an exciting new programming language -- http://www.Zimbu.org ///
6621 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///