1 To: vim_dev@googlegroups.com
4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
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
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
26 # define PATHSEP psepc
27 # define PATHSEPSTR pseps
30 ! # define PATHSEP '.'
31 ! # define PATHSEPSTR "."
33 ! # define PATHSEP '/'
34 ! # define PATHSEPSTR "/"
38 # define PATHSEP psepc
39 # define PATHSEPSTR pseps
41 ! # define PATHSEP '/'
42 ! # define PATHSEPSTR "/"
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
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
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.
66 - * RISCOS: Bangs only replaced when followed by a space, since many
67 - * pathnames contain one.
70 do_bang(addr_count, eap, forceit, do_in, do_out)
79 ! && (p[1] == ' ' || p[1] == NUL)
83 if (p > newcmd && p[-1] == '\\')
91 if (p > newcmd && p[-1] == '\\')
99 - STRCAT(buf, " { < "); /* Use RISC OS notation for input. */
101 - STRCAT(buf, " } ");
103 STRCAT(buf, " <"); /* " < " causes problems on Amiga */
108 p = vim_strchr(cmd, '|');
113 vim_snprintf((char *)end, (size_t)(buflen - (end - buf)),
116 - opt != p_sp ? " %s%s" :
121 " %s%s", /* " > %s" causes problems on Amiga */
123 - " %s %s", /* But is needed for 'shellpipe' and RISC OS */
126 (char *)opt, (char *)fname);
141 if (tempname == NULL) /* out of memory */
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
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
151 - q = mch_munge_fname(p);
153 q = expand_env_save(p);
158 - p = mch_munge_fname(q);
160 p = expand_env_save(q);
168 proftime_T wait_start;
172 - p = mch_munge_fname(fname);
174 p = expand_env_save(fname);
178 fname_exp = fix_fname(p);
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
184 valid = 0; /* Must have ":p:h" to be valid */
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;
193 result = curbuf->b_fname;
197 case SPEC_HASH: /* '#' or "#99": alternate file */
201 if (src[*usedlen] == '<') /* remove the file name extension */
205 - if ((s = vim_strrchr(result, '/')) != NULL && s >= gettail(result))
207 if ((s = vim_strrchr(result, '.')) != NULL && s >= gettail(result))
209 resultlen = (int)(s - result);
211 #ifdef FEAT_MODIFY_FNAME
215 else if (vim_ispathsep(*p))
218 ! #if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA) || defined(RISCOS) \
224 else if (vim_ispathsep(*p))
227 ! #if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA) || defined(VMS)
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
236 if (newfile && !read_stdin && !read_buffer)
238 ! /* Remember time of file.
239 ! * For RISCOS, also remember the filetype.
241 if (mch_stat((char *)fname, &st) >= 0)
243 buf_store_time(curbuf, &st, fname);
244 curbuf->b_mtime_read = curbuf->b_mtime;
246 - #if defined(RISCOS) && defined(FEAT_OSFILETYPE)
247 - /* Read the filetype into the buffer local filetype option. */
248 - mch_read_filetype(fname);
252 * Use the protection bits of the original file for the swap file.
255 if (newfile && !read_stdin && !read_buffer)
257 ! /* Remember time of file. */
258 if (mch_stat((char *)fname, &st) >= 0)
260 buf_store_time(curbuf, &st, fname);
261 curbuf->b_mtime_read = curbuf->b_mtime;
264 * Use the protection bits of the original file for the swap file.
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
273 file_readonly = FALSE;
278 /* make sure we have a valid backup extension to use */
282 - backup_ext = (char_u *)"/bak";
284 backup_ext = (char_u *)".bak";
294 if (perm >= 0) /* set perm. of new file same as old file */
295 (void)mch_setperm(wfname, perm);
297 - if (!append && !filtering)
298 - /* Set the filetype after writing the file. */
299 - mch_set_filetype(wfname, buf->b_p_oft);
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). */
308 for (ptr = retval + fnamelen; ptr > retval; mb_ptr_back(retval, ptr))
312 ! # ifdef USE_LONG_FNAME
313 && (!USE_LONG_FNAME || shortname)
315 ! # ifndef SHORT_FNAME
320 if (*ptr == '.') /* replace '.' by '_' */
323 if (vim_ispathsep(*ptr))
328 for (ptr = retval + fnamelen; ptr > retval; mb_ptr_back(retval, ptr))
331 ! #ifdef USE_LONG_FNAME
332 && (!USE_LONG_FNAME || shortname)
334 ! # ifndef SHORT_FNAME
339 if (*ptr == '.') /* replace '.' by '_' */
341 if (vim_ispathsep(*ptr))
346 if (fname == NULL || *fname == NUL
347 || vim_ispathsep(fname[STRLEN(fname) - 1]))
357 * If the extension starts with '.', truncate the base name at 8
361 - /* We normally use '/', but swap files are '_' */
362 - else if (*ext == '/' || *ext == '_')
364 else if (*ext == '.')
367 if ((size_t)(s - ptr) > (size_t)8)
372 * If the extension doesn't start with '.', and the file name
373 * doesn't have an extension yet, append a '.'
376 - else if ((e = vim_strchr(ptr, '/')) == NULL)
379 else if ((e = vim_strchr(ptr, '.')) == NULL)
383 * If the extension doesn't start with '.', and there already is an
384 * extension, it may need to be truncated
391 ! if (prepend_dot && !shortname && *(e = gettail(retval)) !=
397 #ifdef USE_LONG_FNAME
415 ! if (prepend_dot && !shortname && *(e = gettail(retval)) != '.'
416 #ifdef USE_LONG_FNAME
432 - if (allow_dirs != NULL)
433 - *allow_dirs = TRUE;
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
452 EXTERN char_u e_sandbox[] INIT(= N_("E48: Not allowed in sandbox"));
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"));
460 EXTERN char_u e_sandbox[] INIT(= N_("E48: Not allowed in sandbox"));
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"));
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
472 if (highlight_mask & (HL_INVERSE | HL_STANDOUT))
474 ! #if defined(AMIGA) || defined(RISCOS)
475 gui_mch_set_colors(bg_color, fg_color);
477 gui_mch_set_fg_color(bg_color);
480 if (highlight_mask & (HL_INVERSE | HL_STANDOUT))
483 gui_mch_set_colors(bg_color, fg_color);
485 gui_mch_set_fg_color(bg_color);
491 ! #if defined(AMIGA) || defined(RISCOS)
492 gui_mch_set_colors(fg_color, bg_color);
494 gui_mch_set_fg_color(fg_color);
500 gui_mch_set_colors(fg_color, bg_color);
502 gui_mch_set_fg_color(fg_color);
505 if (back != 0 && ((draw_flags & DRAW_BOLD) || (highlight_mask & HL_ITALIC)))
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)
513 if (back != 0 && ((draw_flags & DRAW_BOLD) || (highlight_mask & HL_ITALIC)))
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)
524 /* Allow the left button to start the selection */
527 - /* Only start a drag on a drag event. Otherwise
528 - * we don't get a release event. */
535 - clip_start_selection(X_2_COL(x), Y_2_ROW(y), repeated_click);
539 else if (button == MOUSE_LEFT)
541 ! clip_clear_selection();
546 /* Always allow pasting */
547 if (button != MOUSE_MIDDLE)
551 /* Allow the left button to start the selection */
552 else if (button == MOUSE_LEFT)
554 ! clip_start_selection(X_2_COL(x), Y_2_ROW(y), repeated_click);
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
564 # include <SegLoad.h>*/
568 - # include "gui_riscos.h"
571 #ifdef FEAT_GUI_PHOTON
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 */
583 #define DRAW_CURSOR 0x20 /* drawing block cursor (win32) */
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 */
591 #define DRAW_CURSOR 0x20 /* drawing block cursor (win32) */
595 ControlHandle id; /* A handle to the scrollbar */
598 - int id; /* Window handle of scrollbar window */
600 #ifdef FEAT_GUI_PHOTON
606 int visibility; /* Is window partially/fully obscured? */
611 - char_u *window_title;
612 - int window_title_size;
613 - int fg_colour; /* in 0xBBGGRR format */
617 #ifdef FEAT_GUI_PHOTON
618 PtWidget_t *vimWindow; /* PtWindow */
619 PtWidget_t *vimTextArea; /* PtRaw */
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
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"));
634 mch_msg(_("\nArguments recognised by gvim (GTK+ version):\n"));
635 main_msg(_("-font <font>\t\tUse <font> for normal text (also: -fn)"));
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
641 * fname cannot be NameBuff, because it must have been allocated.
644 ! #if defined(MSDOS) || defined(MSWIN) || defined(RISCOS)
646 * A ":!cd e:xxx" may change the directory without us knowning, use the
647 * full pathname always. Careful: This frees fname!
649 * fname cannot be NameBuff, because it must have been allocated.
652 ! #if defined(MSDOS) || defined(MSWIN)
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
661 if (mf_open_file(mfp, fname) == OK) /* consumes fname! */
663 ! #if defined(MSDOS) || defined(MSWIN) || defined(RISCOS)
665 * set full pathname for swap file now, because a ":!cd dir" may
666 * change directory without us knowing it.
669 if (mf_open_file(mfp, fname) == OK) /* consumes fname! */
671 ! #if defined(MSDOS) || defined(MSWIN)
673 * set full pathname for swap file now, because a ":!cd dir" may
674 * change directory without us knowing it.
677 b0p->b0_fname[0] = NUL;
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
685 b0p->b0_fname[0] = NUL;
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
694 fname = (char_u *)"";
695 len = (int)STRLEN(fname);
697 ! #if defined(VMS) || defined(RISCOS)
698 STRNICMP(fname + len - 4, "_s" , 2)
700 STRNICMP(fname + len - 4, ".s" , 2)
702 fname = (char_u *)"";
703 len = (int)STRLEN(fname);
706 STRNICMP(fname + len - 4, "_s" , 2)
708 STRNICMP(fname + len - 4, ".s" , 2)
712 names[0] = vim_strsave((char_u *)"*_sw%");
715 - names[0] = vim_strsave((char_u *)"*_sw#");
717 names[0] = vim_strsave((char_u *)"*.sw?");
720 #if defined(UNIX) || defined(WIN3264)
721 /* For Unix names starting with a dot are special. MS-Windows
726 names[0] = concat_fnames(dir_name, (char_u *)"*_sw%", TRUE);
729 - names[0] = concat_fnames(dir_name, (char_u *)"*_sw#", TRUE);
731 names[0] = concat_fnames(dir_name, (char_u *)"*.sw?", TRUE);
734 #if defined(UNIX) || defined(WIN3264)
735 /* For Unix names starting with a dot are special. MS-Windows
741 swapname = modname(fname_res,
742 ! #if defined(VMS) || defined(RISCOS)
743 (char_u *)"_swp", FALSE
745 (char_u *)".swp", TRUE
749 swapname = modname(fname_res,
751 (char_u *)"_swp", FALSE
753 (char_u *)".swp", TRUE
757 names[num_names] = concat_fnames(path, (char_u *)"_sw%", FALSE);
760 - names[num_names] = concat_fnames(path, (char_u *)"_sw#", FALSE);
762 names[num_names] = concat_fnames(path, (char_u *)".sw?", FALSE);
765 if (names[num_names] == NULL)
771 names[num_names] = modname(path, (char_u *)"_sw%", FALSE);
774 - names[num_names] = modname(path, (char_u *)"_sw#", FALSE);
776 names[num_names] = modname(path, (char_u *)".sw?", FALSE);
779 if (names[num_names] == NULL)
784 mf_free(mfp, hp); /* free the data block */
785 buf->b_ml.ml_locked = NULL;
787 ! for (stack_idx = buf->b_ml.ml_stack_top - 1; stack_idx >= 0; --stack_idx)
789 buf->b_ml.ml_stack_top = 0; /* stack is invalid when failing */
790 ip = &(buf->b_ml.ml_stack[stack_idx]);
792 mf_free(mfp, hp); /* free the data block */
793 buf->b_ml.ml_locked = NULL;
795 ! for (stack_idx = buf->b_ml.ml_stack_top - 1; stack_idx >= 0;
798 buf->b_ml.ml_stack_top = 0; /* stack is invalid when failing */
799 ip = &(buf->b_ml.ml_stack[stack_idx]);
803 (buf->b_p_sn || buf->b_shortname),
806 - /* Avoid problems if fname has special chars, eg <Wimp$Scrap> */
812 ! #if defined(VMS) || defined(RISCOS)
818 (buf->b_p_sn || buf->b_shortname),
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.
840 /* give the ATTENTION message when there is an old swap file
841 * for the current file, and the buffer was not recovered. */
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
851 ! return (c == '.' || c == ':');
854 return (c == '/'); /* UNIX has ':' inside file names */
856 ! # ifdef BACKSLASH_IN_FILENAME
857 return (c == ':' || c == '/' || c == '\\');
860 /* server"user passwd"::device:[full.path.name]fname.extension;version" */
861 return (c == ':' || c == '[' || c == ']' || c == '/'
862 || c == '<' || c == '>' || c == '"' );
864 return (c == ':' || c == '/');
868 ! #endif /* RISC OS */
871 #if defined(FEAT_SEARCHPATH) || defined(PROTO)
877 return (c == '/'); /* UNIX has ':' inside file names */
879 ! # ifdef BACKSLASH_IN_FILENAME
880 return (c == ':' || c == '/' || c == '\\');
883 /* server"user passwd"::device:[full.path.name]fname.extension;version" */
884 return (c == ':' || c == '[' || c == ']' || c == '/'
885 || c == '<' || c == '>' || c == '"' );
887 return (c == ':' || c == '/');
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
899 # include "os_beos.pro"
902 - # include "os_riscos.pro"
905 # include "os_qnx.pro"
911 # include "gui_x11.pro"
914 - # include "gui_riscos.pro"
916 # ifdef FEAT_GUI_PHOTON
917 # include "gui_photon.pro"
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
924 if (fname == NULL || *fname == NUL) /* no file name */
928 - /* Name is reported as `main.c', but file is `c.main' */
929 - return ro_buflist_add(fname);
935 vms_remove_version(fname);
937 ! # ifdef BACKSLASH_IN_FILENAME
938 if (directory != NULL)
939 slash_adjust(directory);
942 if (directory != NULL && !vim_isAbsName(fname)
943 && (ptr = concat_fnames(directory, fname, TRUE)) != NULL)
946 if (fname == NULL || *fname == NUL) /* no file name */
953 vms_remove_version(fname);
955 ! #ifdef BACKSLASH_IN_FILENAME
956 if (directory != NULL)
957 slash_adjust(directory);
960 if (directory != NULL && !vim_isAbsName(fname)
961 && (ptr = concat_fnames(directory, fname, TRUE)) != NULL)
967 return buflist_add(fname, 0);
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
977 char_u *already = NULL;
978 char_u *startp = NULL;
979 char_u *inc_opt = NULL;
981 - int previous_munging = __riscosify_control;
983 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
984 win_T *curwin_save = NULL;
989 if (file_line == NULL)
993 - /* UnixLib knows best how to munge c file names - turn munging back on. */
994 - int __riscosify_control = 0;
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
1003 vim_free(regmatch.regprog);
1004 vim_free(incl_regmatch.regprog);
1005 vim_free(def_regmatch.regprog);
1008 - /* Restore previous file munging state. */
1009 - __riscosify_control = previous_munging;
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
1019 MenuHandle menu_handle;
1020 MenuHandle submenu_handle;
1023 - int *id; /* Not used, but gui.c needs it */
1024 - int greyed_out; /* Flag */
1027 #ifdef FEAT_GUI_PHOTON
1029 PtWidget_t *submenu_id;
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
1037 * Here are the builtin termcap entries. They are not stored as complete
1038 ! * Tcarr structures, as such a structure is too big.
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
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.
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
1054 #ifndef NO_BUILTIN_TCAPS
1055 - # if defined(RISCOS) || defined(ALL_BUILTIN_TCAPS)
1057 - * Default for the Acorn.
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 */
1063 - {(int)KS_CCO, "16"}, /* Allow 16 colors */
1065 - {(int)KS_CAF, "\001%d\021"}, /* Set foreground colour */
1066 - {(int)KS_CAB, "\001%d\022"}, /* Set background colour */
1069 - {(int)KS_ME, "\004"}, /* Normal mode */
1070 - {(int)KS_MR, "\005"}, /* Reverse */
1072 - {(int)KS_VI, "\016"}, /* Cursor invisible */
1073 - {(int)KS_VE, "\017"}, /* Cursor visible */
1074 - {(int)KS_VS, "\020"}, /* Cursor very visible */
1076 - {(int)KS_CS, "\001%d\001%d\003"}, /* Set scroll region */
1077 - {(int)KS_SR, "\023"}, /* Scroll text down */
1081 - {K_RIGHT, "\215"},
1083 - {K_S_DOWN, "\236"},
1084 - {K_S_LEFT, "\234"},
1085 - {K_S_RIGHT, "\235"},
1108 - {K_S_F10, "\332"},
1109 - {K_S_F11, "\333"},
1110 - {K_S_F12, "\334"},
1116 - {K_PAGEUP, "\237"},
1117 - {K_PAGEDOWN, "\236"},
1118 - # endif /* Acorn terminal */
1121 # if defined(AMIGA) || defined(ALL_BUILTIN_TCAPS)
1127 * DEFAULT_TERM is used, when no terminal is specified with -T option or $TERM.
1130 - # define DEFAULT_TERM (char_u *)"riscos"
1134 # define DEFAULT_TERM (char_u *)"amiga"
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
1142 #include "termlib.pro"
1144 ! #if !defined(AMIGA) && !defined(VMS) && !defined(MACOS) && !defined(RISCOS)
1150 #include "termlib.pro"
1152 ! #if !defined(AMIGA) && !defined(VMS) && !defined(MACOS)
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
1164 - MSG_PUTS(_("\nRISC OS version"));
1167 MSG_PUTS(_("\nOpenVMS version"));
1168 # ifdef HAVE_PATHDEF
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
1174 # define SIZEOF_INT 2
1178 - # define SIZEOF_INT 4
1182 #include "feature.h" /* #defines for optionals and features */
1186 # include "os_mac.h"
1190 - # include "os_riscos.h"
1194 # include "os_qnx.h"
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
1201 - /* vi:set ts=8 sts=4 sw=4:
1203 - * VIM - Vi IMproved by Bram Moolenaar
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.
1209 - #define FEAT_BROWSE
1211 - #define TASK 0x4b534154
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
1220 - #define CHILD_SELF_SCROLL 0
1221 - #define CHILD_PARENT_SCROLL 1
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
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);
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
1238 - /* vi:set ts=8 sts=4 sw=4:
1240 - * VIM - Vi IMproved by Bram Moolenaar
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.
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>
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
1262 - /* Longer filenames now accessible to all */
1263 - #ifndef BASENAMELEN
1264 - # define BASENAMELEN 64 /* Same length as unzip */
1268 - # define TEMPNAME "<Wimp$ScrapDir>.v?XXXXXX"
1269 - # define TEMPNAMELEN 25
1272 - #ifndef DFLT_HELPFILE
1273 - # define DFLT_HELPFILE "Vim:doc.help"
1277 - # define DFLT_BDIR ".,<Wimp$ScrapDir>." /* default for 'backupdir' */
1280 - /* Paths to try putting swap file in. */
1282 - # define DFLT_DIR "<Wimp$ScrapDir>.,." /* default for 'directory' */
1286 - # define DFLT_VDIR "Choices:Vim.view" /* default for 'viewdir' */
1289 - #ifndef TERMCAPFILE
1290 - # define TERMCAPFILE "Vim:TermCap"
1292 - #define HAVE_TGETENT
1294 - #ifndef SYNTAX_FNAME
1295 - # define SYNTAX_FNAME "Vim:Syntax.%s"
1299 - # define EVIM_FILE "Vim:Evim"
1302 - #define FEAT_VIMINFO
1304 - #ifndef VIMINFO_FILE
1305 - # define VIMINFO_FILE "<Choices$Write>.Vim.VimInfo"
1307 - #ifndef VIMINFO_FILE2
1308 - # define VIMINFO_FILE2 "Choices:Vim.VimInfo"
1311 - #ifndef VIMRC_FILE
1312 - # define VIMRC_FILE "/vimrc"
1315 - # define EXRC_FILE "/exrc"
1317 - #ifndef GVIMRC_FILE
1318 - # define GVIMRC_FILE "/gvimrc"
1320 - #ifndef USR_VIMRC_FILE
1321 - # define USR_VIMRC_FILE "Vim:Evim"
1323 - #ifndef SESSION_FILE
1324 - # define SESSION_FILE "/Session.vim"
1326 - #ifndef USR_VIMRC_FILE
1327 - # define USR_VIMRC_FILE "Choices:Vim.VimRC"
1329 - #ifndef USR_GVIMRC_FILE
1330 - # define USR_GVIMRC_FILE "Choices:Vim.GVimRC"
1332 - #ifndef USR_EXRC_FILE
1333 - # define USR_EXRC_FILE "Choices:Vim.ExRC"
1335 - #ifndef SYS_VIMRC_FILE
1336 - # define SYS_VIMRC_FILE "Vim:VimRC"
1338 - #ifndef SYS_GVIMRC_FILE
1339 - # define SYS_GVIMRC_FILE "Vim:GVimRC"
1341 - #ifndef SYS_MENU_FILE
1342 - # define SYS_MENU_FILE "Vim:Menu"
1344 - #ifndef SYS_OPTWIN_FILE
1345 - # define SYS_OPTWIN_FILE "Vim:Optwin"
1347 - #ifndef FILETYPE_FILE
1348 - # define FILETYPE_FILE "Vim:Filetype"
1350 - #ifndef FTPLUGIN_FILE
1351 - # define FTPLUGIN_FILE "Vim:Ftplugin/vim"
1353 - #ifndef INDENT_FILE
1354 - # define INDENT_FILE "Vim:Indent/vim"
1356 - #ifndef FTOFF_FILE
1357 - # define FTOFF_FILE "Vim:Ftoff"
1359 - #ifndef FTPLUGOF_FILE
1360 - # define FTPLUGOF_FILE "Vim:Ftplugof"
1362 - #ifndef INDOFF_FILE
1363 - # define INDOFF_FILE "Vim:Indoff"
1366 - #define DFLT_ERRORFILE "errors/vim"
1367 - #define DFLT_RUNTIMEPATH "Choices:Vim,Vim:,Choices:Vim.after"
1370 - * RISC PCs have plenty of memory, use large buffers
1372 - #define CMDBUFFSIZE 1024 /* size of the command processing buffer */
1373 - #define MAXPATHL 256 /* paths are always quite short though */
1375 - #ifndef DFLT_MAXMEM
1376 - # define DFLT_MAXMEM (5*1024) /* use up to 5 Mbyte for a buffer */
1379 - #ifndef DFLT_MAXMEMTOT
1380 - # define DFLT_MAXMEMTOT (10*1024) /* use up to 10 Mbyte for Vim */
1383 - #ifdef HAVE_SIGSET
1384 - # define signal sigset
1387 - #define n_flag (1<<31)
1388 - #define z_flag (1<<30)
1389 - #define c_flag (1<<29)
1390 - #define v_flag (1<<28)
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 */
1397 - #include <kernel.h>
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)
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
1409 - /* vi:set ts=8 sts=4 sw=4:
1411 - * VIM - Vi IMproved by Bram Moolenaar
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.
1419 - #include <string.h>
1424 - * Thomas Leonard <tal197@ecs.soton.ac.uk>
1425 - * Updated by Andy Wingate <andy@sparse.net>
1428 - extern int time_of_last_poll;
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 */
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() */
1438 - int leaf_ref = 0; /* Wimp message number - send via Wimp$Scrap */
1439 - char_u *leaf_name = NULL; /* Leaf name from DataSave */
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. */
1444 - #define DRAG_FALSE 0
1445 - #define DRAG_SELECTION 1
1446 - #define DRAG_RESIZE_WINDOW 2
1447 - int ro_dragging = DRAG_FALSE;
1449 - int drag_modifiers;
1450 - int drag_x_offset;
1451 - int drag_y_offset;
1453 - int nested_wimp = FALSE; /* Bool - can we use the new wimp? */
1455 - int changed_mode = FALSE;
1456 - int x_eigen_factor;
1457 - int y_eigen_factor;
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
1463 - * If zap_redraw is TRUE then zap_file[] contains valid Zap font file
1464 - * pointers (or NULLs).
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;
1470 - int zap_redraw = FALSE;
1471 - int double_height = FALSE; /* Plot each line twice? */
1473 - #define grgb(r,g,b) ((b<<16) + (g<<8) + (r))
1474 - #define UNUSED_COLOUR (gui.back_pixel)
1476 - #define RO_LOAD_CLIPBOARD -2 /* Internal handle for DataSave message. */
1478 - /* Changes by John Kortink, 22-23 July 1998
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
1490 - /* The ZapRedraw structure */
1523 - /* Other globals */
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];
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.
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
1542 - /* Zap font file format data */
1543 - static char *zap_file[ZAP_STYLES] = {NULL, NULL, NULL, NULL};
1545 - /* r_caddr format for current mode */
1546 - static char *zap_caddr[ZAP_STYLES] = {NULL, NULL, NULL, NULL};
1548 - static void ro_remove_menu(int *menu);
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).
1556 - * Return FAIL to revert to system font (if we can't use ZapRedraw).
1559 - ro_zap_redraw_initialise()
1561 - int bytes_per_bitmap_char;
1565 - /* Can't have initialisers for struct members :-(, ok, this way then ... */
1566 - if (!zap_redraw_initialised)
1568 - zap_redraw_block.r_workarea = NULL;
1569 - zap_redraw_initialised = TRUE;
1572 - /* We redraw in DSA mode */
1573 - zap_redraw_block.r_flags = 0x0;
1575 - /* Let ZapRedraw get the screen address for us */
1576 - zap_redraw_block.r_screen = 0;
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.
1582 - zap_redraw_block.r_charw = ((int *) zap_file[ZAP_NORMAL])[2];
1583 - zap_redraw_block.r_charh = ((int *) zap_file[ZAP_NORMAL])[3];
1585 - /* We have no linespacing */
1586 - zap_redraw_block.r_linesp = 0;
1588 - /* Fix foreground = colour 1 */
1589 - zap_redraw_block.r_for = 1;
1591 - /* Fix background = colour 0 */
1592 - zap_redraw_block.r_bac = 0;
1594 - /* Colour mask buffer */
1595 - zap_redraw_block.r_palette = zap_redraw_palette;
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 */
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 */
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;
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 */
1621 - /* Now convert the 1 bpp character data ready for the current mode */
1623 - bytes_per_bitmap_char = (zap_redraw_block.r_charw * zap_redraw_block.r_charh + 7) / 8;
1625 - /* Convert the fonts from 1bpp to a format suitable for the
1628 - for (i = 0; i < ZAP_STYLES; i++)
1630 - first = ((int *) zap_file[i])[4];
1631 - last = ((int *) zap_file[i])[5];
1634 - last = 255; /* Don't convert cursors (overwrites memory!) */
1636 - /* Allocate the font cache */
1637 - vim_free(zap_caddr[i]);
1639 - zap_caddr[i] = (char*) malloc(zap_redraw_block.r_cbpc * 256);
1641 - zap_caddr[i] = NULL; /* No file for this style */
1645 - zap_redraw_block.r_caddr = zap_caddr[i];
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);
1654 - if (!zap_caddr[ZAP_NORMAL])
1656 - zap_redraw = FALSE; /* Out of memory */
1660 - /* Next time we need them, we have to update the colour masks */
1661 - zap_redraw_update_colours = TRUE;
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.
1672 - ro_zap_redraw_draw_string(x, y, string, length, flags, clip)
1677 - int flags; /* DRAW_TRANSP, DRAW_BOLD, DRAW_UNDERL, DRAW_ITALIC */
1680 - char redraw_data[1024];
1685 - int os_xshift = zap_redraw_block.r_magx;
1686 - int os_yshift = zap_redraw_block.r_magy;
1688 - if (flags & DRAW_TRANSP)
1689 - return flags; /* We don't do transparent plotting yet. */
1691 - if (flags & DRAW_BOLD)
1693 - if (flags & DRAW_ITALIC && zap_caddr[ZAP_BITALIC])
1694 - zap_redraw_block.r_caddr = zap_caddr[ZAP_BITALIC];
1696 - zap_redraw_block.r_caddr = zap_caddr[ZAP_BOLD];
1700 - if (flags & DRAW_ITALIC)
1701 - zap_redraw_block.r_caddr = zap_caddr[ZAP_ITALIC];
1703 - zap_redraw_block.r_caddr = zap_caddr[ZAP_NORMAL];
1705 - if (!zap_redraw_block.r_caddr)
1707 - zap_redraw_block.r_caddr = zap_caddr[ZAP_NORMAL];
1708 - flags |= DRAW_UNDERL; /* Style missing - we can always underline */
1711 - /* Set the vertical scaling flag */
1712 - if (double_height)
1713 - zap_redraw_block.r_flags = 1 << 1;
1715 - zap_redraw_block.r_flags = 0;
1717 - /* Update the colour masks (if needed) */
1718 - if (zap_redraw_update_colours)
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;
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);
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 */
1740 - /* Clip target rectangle against the current graphics window */
1741 - if (zap_redraw_block.r_minx < clip_minx)
1743 - zap_redraw_block.r_scrollx = clip_minx - zap_redraw_block.r_minx;
1744 - zap_redraw_block.r_minx = clip_minx;
1747 - zap_redraw_block.r_scrollx = 0;
1748 - if (zap_redraw_block.r_miny < clip_miny)
1750 - zap_redraw_block.r_scrolly = clip_miny - zap_redraw_block.r_miny;
1751 - zap_redraw_block.r_miny = clip_miny;
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;
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;
1770 - /* Perform the draw */
1771 - swi(ZapRedraw_RedrawArea, 0, &zap_redraw_block);
1777 - * Okay that was it from me, back to Thomas ...
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.
1786 - gui_mch_prepare(int *argc, char **argv)
1790 - while (arg < *argc - 1)
1792 - if (strcmp(argv[arg], "--rows") == 0 || strcmp(argv[arg], "--columns") == 0)
1796 - value = atoi(argv[arg + 1]);
1798 - if (argv[arg][2] == 'r')
1799 - default_rows = value;
1801 - default_columns = value;
1803 - /* Delete argument from argv[]. (hope this is read/write!) */
1807 - mch_memmove(&argv[arg], &argv[arg + 2], (*argc - arg)
1808 - * sizeof(char *));
1815 - /* Fatal error on initialisation - report it and die. */
1818 - char_u *error; /* RISC OS error block */
1820 - swi(Wimp_ReportError, error, 5, "GVim");
1821 - exit(EXIT_FAILURE);
1824 - /* Find the sizes of the window tools:
1826 - * Create a test window.
1827 - * Find inner and outer sizes.
1828 - * Find the difference.
1831 - * While we're here, find the eigen values too.
1834 - ro_measure_tools()
1837 - int vdu[] = { 4, 5, -1};
1838 - int test_window[] =
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) */
1856 - int inner_max_x, inner_min_y;
1858 - swi(Wimp_CreateWindow, 0, test_window);
1861 - /* Open the window (and read state).
1862 - * GetWindowOutline needs it too if the wimp isn't nested.
1864 - swi(Wimp_OpenWindow, 0, block);
1865 - inner_max_x = block[3];
1866 - inner_min_y = block[2];
1868 - swi(Wimp_GetWindowOutline, 0, block);
1870 - gui.scrollbar_width = block[3] - inner_max_x;
1871 - gui.scrollbar_height = inner_min_y - block[2];
1873 - swi(Wimp_DeleteWindow, 0, block);
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];
1881 - /* Load a template from the current templates file.
1882 - * Create the window and return its handle.
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 */
1894 - strcpy( (char *) name, str_name);
1896 - /* Find how big we must make the buffers */
1898 - if (xswi(Wimp_LoadTemplate, 0, 0, 0, 0, -1, name, 0) & v_flag)
1899 - ro_die( (char *) r0);
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");
1906 - /* Load the template into the buffers */
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 */
1915 - ro_die("\0\0\0\0Can't find window in Templates file");
1917 - /* Create the window */
1919 - if (xswi(Wimp_CreateWindow, 0, window) & v_flag)
1920 - ro_die( (char *) r0);
1923 - *title = (char_u *) window[18];
1925 - *title_size = window[20];
1927 - free(window); /* Free temp block */
1928 - return r0; /* Return the window handle */
1932 - * Check if the GUI can be started. Called before gvimrc is sourced.
1933 - * Return OK or FAIL.
1936 - gui_mch_init_check()
1938 - return OK; /* TODO: GUI can always be started? */
1942 - * Initialise the RISC OS GUI.
1943 - * Create all the windows.
1944 - * Returns OK for success, FAIL when the GUI can't be started.
1949 - int messages[] = {
1950 - 1, 2, 3, 4, /* DataSave, DataSaveAck, DataLoad, DataLoadAck */
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. */
1964 - /* There may have been some errors reported in the
1965 - * command window before we get here. Wait if so.
1967 - swi(Wimp_ReadSysInfo, 3);
1969 - swi(Wimp_CommandWindow, 0); /* Window opened - close with prompt */
1971 - if (xswi(Wimp_Initialise, 310, 0x4b534154, "GVim", messages) & v_flag)
1973 - nested_wimp = r0 >= 397;
1976 - /* Load the templates. */
1978 - if (xswi(Wimp_OpenTemplate, 0, "Vim:Templates") & v_flag)
1979 - ro_die( (char *) r0);
1981 - gui.window_handle = ro_load_template("editor",
1982 - &gui.window_title,
1983 - &gui.window_title_size);
1985 - save_window = ro_load_template("save", NULL, NULL);
1987 - swi(Wimp_CloseTemplate);
1989 - /* Set default foreground and background colours. */
1991 - gui.norm_pixel = gui.def_norm_pixel;
1992 - gui.back_pixel = gui.def_back_pixel;
1994 - /* Get the colours from the "Normal" and "Menu" group (set in syntax.c or
1995 - * in a vimrc file) */
1997 - set_normal_colors();
2000 - * Check that none of the colors are the same as the background color
2003 - gui_check_colors();
2005 - /* Get the colours for the highlight groups (gui_check_colors() might have
2006 - * changed them) */
2008 - highlight_gui_started(); /* re-init colours and fonts */
2010 - /* Set geometry based on values read on initialisation. */
2012 - gui.num_cols = Columns = default_columns;
2013 - gui.num_rows = Rows = default_rows;
2015 - /* Get some information about our environment. */
2017 - ro_measure_tools();
2023 - * Called when the foreground or background colour has been changed.
2026 - gui_mch_new_colors()
2031 - * Open the GUI window which was created by a call to gui_mch_init().
2034 - gui_mch_open(void)
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);
2043 - /* Give the new window the input focus */
2044 - swi(Wimp_SetCaretPosition, gui.window_handle, -1, 0, 0, -1, -1);
2046 - if (gui_win_x != -1 && gui_win_y != -1)
2047 - gui_mch_set_winpos(gui_win_x, gui_win_y);
2053 - gui_mch_exit(int rc)
2057 - /* Close window. Stops us from getting troublesome events
2058 - * if we take a while to die.
2060 - block[0] = gui.window_handle;
2061 - swi(Wimp_CloseWindow, 0, block);
2065 - /* We still have a sub-task running - kill it */
2068 - block[4] = 0; /* Quit */
2069 - if ((xswi(Wimp_SendMessage, 17, block, child_handle) & v_flag) == 0)
2071 - /* Idle until child dies. */
2072 - while (child_handle)
2074 - process_event(wimp_poll(1, block), block);
2083 - * Get the position of the top left corner of the window.
2086 - gui_mch_get_winpos(int *x, int *y)
2093 - * Set the position of the top left corner of the window to the given
2097 - gui_mch_set_winpos(int x, int y)
2103 - gui_mch_set_shellsize(width, height, min_width, min_height, base_width, base_height, direction)
2104 - int width; /* In OS units */
2106 - int min_width; /* Smallest permissible window size (ignored) */
2108 - int base_width; /* Space for scroll bars, etc */
2112 - int s_width, s_height;
2114 - gui.window_handle,
2120 - gui_mch_get_screen_dimensions(&s_width, &s_height);
2121 - s_width -= base_width;
2122 - s_height -= base_height; /* Underestimate - ignores titlebar */
2124 - swi(Wimp_GetWindowState, 0, block);
2125 - block[3] = block[1] + width;
2126 - block[2] = block[4] - height;
2127 - if (block[3] > s_width)
2129 - block[3] = s_width;
2130 - block[1] = block[3] - width;
2132 - if (block[2] < gui.scrollbar_height)
2134 - block[2] = gui.scrollbar_height;
2135 - block[4] = block[2] + height;
2137 - swi(Wimp_OpenWindow, 0, block);
2138 - swi(Wimp_ForceRedraw, gui.window_handle, 0, -height, width, 0);
2142 - gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
2144 - int block[] = {4, 5, 11, 12, -1};
2146 - swi(OS_ReadVduVariables, block, block);
2147 - *screen_w = (block[2] + 1) << block[0];
2148 - *screen_h = (block[3] + 1) << block[1];
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.
2156 - ro_get_font(fullname, weight)
2158 - int weight; /* Initial weights:
2172 - for (i = 0; i < 39;)
2175 - if (c == ':' || c == NUL || c == '.')
2180 - /* find the first modifier, NULL if none */
2181 - arg = strchr(fullname + i, ':');
2188 - height = strtol(arg + 1, (char **) &arg, 10);
2191 - width = strtol(arg + 1, (char **) &arg, 10);
2202 - arg = strchr(arg, ':');
2205 - if ((weight & 1) && i < 35)
2207 - /* Bold goes instead of given suffix */
2208 - strncpy(font + i, ".Bold", 5);
2213 - /* Copy rest of name unless we are using Bold */
2217 - if (c == ':' || c == NUL)
2222 - if ((weight & 2) && i < 32)
2224 - strncpy(font + i, ".Oblique", 8);
2230 - if (height < 1 && width < 1)
2231 - height = width = 10; /* Default to 10pt */
2232 - else if (height < 1)
2234 - else if (width < 1)
2237 - if (xswi(Font_FindFont, 0, font, width << 4, height << 4, 0, 0) & v_flag)
2238 - return NOFONT; /* Can't find font */
2243 - /* Load a file into allocated memory and check it is valid.
2244 - * Return a pointer to the allocated block on success.
2247 - zap_load_file(name, style)
2248 - char_u *name; /* Name of directory containing styles */
2249 - char_u *style; /* Name of style within directory */
2251 - char_u fname[256];
2254 - if (strlen(name) + strlen(style) > 254)
2255 - return NULL; /* Names too long */
2257 - sprintf(fname, "%s.%s", name, style);
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 */
2263 - /* Allocate enough memory to load the whole file */
2264 - file = (char *) alloc(r4);
2266 - return NULL; /* Out of memory */
2268 - if (xswi(OS_File, 12, fname, file, 0, "VimFonts:") & v_flag)
2269 - return NULL; /* Unable to load file */
2271 - if (strncmp(file, "ZapFont\015", 8) == 0)
2272 - return file; /* Loaded OK! */
2275 - return NULL; /* Not a valid font file */
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.
2282 - * 'name' is the name of a directory.
2283 - * Tries to load 'name.0', 'name.B', 'name.I' and 'name.IB'.
2286 - zap_load_font(name)
2291 - /* Free the existing font files, if any */
2292 - for (i = 0; i < ZAP_STYLES; i++)
2294 - vim_free(zap_file[i]);
2295 - zap_file[i] = NULL;
2298 - if (name && *name == '!')
2301 - double_height = TRUE;
2304 - double_height = FALSE;
2306 - if (name && *name)
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 */
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");
2319 - char workarea[16];
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)
2326 - zap_file[ZAP_NORMAL] = (char *) header;
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 */
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;
2342 - return ro_zap_redraw_initialise();
2346 - * Initialise vim to use the font with the given name.
2347 - * Return FAIL if the font could not be loaded, OK otherwise.
2350 - gui_mch_init_font(char_u *font_name, int fontset)
2352 - int new_handle = 0; /* Use the system font by default */
2354 - if (font_name[0] == '!')
2356 - /* Select a ZapRedraw font */
2357 - if (zap_load_font(font_name + 1))
2358 - zap_redraw = TRUE;
2361 - EMSG2(_("E610: Can't load Zap font '%s'"), font_name);
2362 - font_name = "System"; /* Error - use system font */
2363 - zap_redraw = FALSE;
2368 - zap_redraw = FALSE;
2372 - /* Extract any extra details about the font */
2373 - new_handle = ro_get_font(font_name, 0);
2378 - font_name = "System";
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;
2388 - /* Read details about the chosen font */
2389 - swi(Font_ReadInfo, new_handle);
2391 - gui.char_width = r3 - r1;
2392 - gui.char_height = r4 - r2;
2394 - font_x_offset = -r1; /* Where to position each char in its box */
2395 - font_y_offset = -r4;
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);
2407 - /* Use the system font or ZapRedraw. */
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;
2417 - gui.char_width = 16;
2418 - gui.char_height = 32;
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;
2428 - hl_set_font_name(font_name);
2430 - must_redraw = CLEAR;
2435 - * Adjust gui.char_height (after 'linespace' was changed).
2438 - gui_mch_adjust_charheight()
2444 - * Get a font structure for highlighting.
2447 - gui_mch_get_font(name, giveErrorIfMissing)
2449 - int giveErrorIfMissing;
2454 - return NOFONT; /* System font if no name */
2456 - handle = ro_get_font(name, 0);
2459 - if (giveErrorIfMissing)
2460 - EMSG2(_("E611: Can't use font %s"), name);
2467 - #if defined(FEAT_EVAL) || defined(PROTO)
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.
2473 - gui_mch_get_fontname(font, name)
2479 - return vim_strsave(name);
2484 - * Set the current text font.
2487 - gui_mch_set_font(GuiFont font)
2489 - ro_current_font = font;
2493 - /* Not the system font or ZapRedraw font - select it */
2494 - swi(Font_SetFont, font);
2499 - * If a font is not going to be used, free its structure.
2502 - gui_mch_free_font(GuiFont font)
2505 - swi(Font_LoseFont, font);
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
2514 - gui_mch_get_color(char_u *name)
2523 - { "Red", grgb(255, 0, 0) },
2524 - { "LightRed", grgb(255, 0, 0) },
2525 - { "DarkRed", grgb(139, 0, 0) },
2527 - { "Green", grgb(50, 200, 50) },
2528 - { "LightGreen", grgb(144, 238, 144) },
2529 - { "DarkGreen", grgb(0, 100, 0) },
2530 - { "SeaGreen", grgb(46, 139, 87) },
2532 - { "Blue", grgb(0, 0, 255) },
2533 - { "LightBlue", grgb(173, 216, 230) },
2534 - { "DarkBlue", grgb(0, 0, 139) },
2535 - { "SlateBlue", grgb(160, 90, 205) },
2537 - { "Cyan", grgb(0, 255, 255) },
2538 - { "LightCyan", grgb(224, 255, 255) },
2539 - { "DarkCyan", grgb(0, 139, 139) },
2541 - { "Magenta", grgb(255, 0, 255) },
2542 - { "LightMagenta", grgb(255, 224, 255) },
2543 - { "DarkMagenta", grgb(139, 0, 139) },
2545 - { "Yellow", grgb(255, 255, 0) },
2546 - { "LightYellow", grgb(255, 255, 224) },
2547 - { "DarkYellow", grgb(139, 139, 0) },
2548 - { "Brown", grgb(165, 42, 42) },
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) },
2575 - { "Black", grgb(0, 0, 0) },
2576 - { "White", grgb(255, 255, 255) },
2578 - { "Orange", grgb(255, 165, 0) },
2579 - { "Purple", grgb(160, 32, 240) },
2580 - { "Violet", grgb(238, 130, 238) },
2584 - if (name[0] == '#')
2589 - c = strtol(name + 1, &end, 16);
2590 - return (guicolor_T) ((c >> 16) & 0xff) | (c & 0xff00) | ((c & 0xff) << 16);
2593 - for (i = 0; colours[i].name != NULL; i++)
2595 - if (STRICMP(name, colours[i].name) == 0)
2596 - return colours[i].value;
2598 - if (strnicmp(name, "grey", 4) == 0 || strnicmp(name, "gray", 4) == 0)
2600 - int level = (255 * atoi(name + 4)) / 100;
2601 - return (guicolor_T) grgb(level, level, level);
2603 - return INVALCOLOR;
2607 - * Set the current text colours.
2608 - * If we are using fonts then set the antialiasing colours too.
2611 - gui_mch_set_colors(guicolor_T fg, guicolor_T bg)
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 */
2617 - swi(ColourTrans_ReturnGCOL, fg << 8);
2618 - gui.fg_colour = r0;
2619 - swi(ColourTrans_ReturnGCOL, bg << 8);
2620 - gui.bg_colour = r0;
2622 - if (ro_current_font)
2623 - swi(ColourTrans_SetFontColours, 0, bg << 8, fg << 8, 14);
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 */
2635 - if (ro_current_font)
2638 - int flen = len; /* Preserve for underline */
2640 - /* Use the Font manager to paint the string.
2641 - * Must do one char at a time to get monospacing.
2644 - if (flags & DRAW_ITALIC && !gui.ital_font)
2645 - flags |= DRAW_UNDERL; /* No italic - underline instead */
2647 - if ((flags & DRAW_TRANSP) == 0)
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);
2654 - fx = x + font_x_offset;
2657 - swi(Font_Paint, 0, s++, 0x90, fx, y + font_y_offset, 0, 0, 1);
2658 - fx += gui.char_width;
2665 - /* Using fast Zap redraw. */
2666 - flags = ro_zap_redraw_draw_string(x, y, s, len, flags, clip);
2670 - /* Using the system font */
2671 - if (flags & DRAW_ITALIC)
2672 - flags |= DRAW_UNDERL;
2674 - if ((flags & DRAW_TRANSP) == 0)
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);
2680 - swi(OS_Plot, 4, /* Move the drawing cursor */
2683 - swi(ColourTrans_SetColour, gui.fg_colour, 0, 0, 0, 0);
2684 - swi(OS_WriteN, s, len);
2686 - if (flags & DRAW_BOLD)
2688 - swi(OS_Plot, 4, x + (1 << x_eigen_factor), y - 1);
2689 - swi(OS_WriteN, s, len);
2694 - if (flags & DRAW_UNDERL)
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);
2705 - gui_mch_draw_string(int row, int col, char_u *s, int len, int flags)
2707 - int x, y; /* Workarea x,y */
2708 - x = col * gui.char_width;
2709 - y = -row * gui.char_height;
2713 - ro_draw_string(x + redraw_block[1], y + redraw_block[4],
2714 - s, len, flags, &redraw_block[7]); /* JK230798, added clip window */
2719 - block[0] = gui.window_handle;
2721 - block[2] = y - gui.char_height;
2722 - block[3] = (col + len) * gui.char_width;
2724 - swi(Wimp_UpdateWindow, 0, block);
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);
2735 - * Return OK if the key with the termcap name "name" is supported.
2738 - gui_mch_haskey(char_u *name)
2744 - gui_mch_beep(void)
2746 - swi(OS_WriteI + 7);
2753 - gui_mch_flash(int msec)
2760 - * Plot a solid rectangle using the given plot action and colour.
2761 - * Coordinates are inclusive and window-relative.
2764 - plot_rectangle(plot, colour, minx, miny, maxx, maxy)
2765 - int plot; /* OS_Plot action */
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]);
2781 - block[0] = gui.window_handle;
2784 - block[3] = maxx + 1;
2785 - block[4] = maxy + 1;
2786 - swi(Wimp_UpdateWindow, 0, block);
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);
2798 - * Invert a rectangle from row r, column c, for nr rows and nc columns.
2801 - gui_mch_invert_rectangle(int r, int c, int nr, int nc)
2803 - plot_rectangle(96 + 6, 0, FILL_X(c), -FILL_Y(r + nr), FILL_X(c + nc), -FILL_Y(r));
2807 - * Iconify the GUI window.
2810 - gui_mch_iconify(void)
2814 - #if defined(FEAT_EVAL) || defined(PROTO)
2816 - * Bring the Vim window to the foreground.
2819 - gui_mch_set_foreground()
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.
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);
2841 - * Draw a cursor without focus.
2844 - gui_mch_draw_hollow_cursor(guicolor_T colour)
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)
2852 - block[0] = gui.window_handle;
2854 - block[2] = y - gui.char_height;
2855 - block[3] = x + gui.char_width;
2857 - swi(Wimp_UpdateWindow, 0, block);
2860 - swi(ColourTrans_SetGCOL, colour << 8, 0, 0, 0, 0);
2862 - swi(OS_Plot, 4, x + block[1], y + block[4] - 1);
2863 - draw_hollow(gui.char_width, gui.char_height);
2865 - swi(Wimp_GetRectangle, 0, block);
2870 - swi(ColourTrans_SetGCOL, colour << 8, 0, 0, 0, 0);
2872 - swi(OS_Plot, 4, x + redraw_block[1], y + redraw_block[4] - 1);
2873 - draw_hollow(gui.char_width, gui.char_height);
2878 - * Draw part of a cursor, "w" pixels wide, and "h" pixels high, using
2882 - gui_mch_draw_part_cursor(w, h, colour)
2885 - guicolor_T colour;
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);
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).
2900 - gui_mch_update(void)
2905 - swi(OS_ReadMonotonicTime);
2906 - if ((r0 - time_of_last_poll) < 50)
2907 - return; /* Don't return too often */
2909 - reason = wimp_poll(0, block);
2911 - process_event(reason, block);
2912 - ro_return_early = FALSE; /* We're returning anyway. */
2916 - redraw_window(block)
2919 - int x, y; /* Vim workarea coords */
2920 - int width, height;
2923 - swi(ColourTrans_ReturnGCOL, UNUSED_COLOUR << 8, 0, 0, 1<<7, 0);
2926 - swi(Wimp_RedrawWindow, 0, block);
2927 - redraw_block = block;
2930 - x = block[7] - block[1];
2931 - y = block[4] - block[10];
2932 - width = block[9] - block[7];
2933 - height = block[10] - block[8];
2935 - if (height + y > Rows * gui.char_height)
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;
2943 - if (width + x> Columns * gui.char_width)
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;
2951 - gui_redraw(x , y, width, height);
2952 - swi(Wimp_GetRectangle, 0, block);
2954 - redraw_block = NULL;
2957 - /* Check if we have modified data.
2958 - * If we do then ack the message to stop the shutdown.
2959 - * Otherwise, ignore the message.
2965 - if (!ro_ok_to_quit())
2967 - /* Not OK to quit - stop shutdown */
2968 - block[3] = block[2];
2969 - swi(Wimp_SendMessage, 19, block, block[1]);
2971 - /* Do nothing. We may get a Message_Quit later. */
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
2981 - int old_confirm = cmdmod.confirm;
2983 - cmdmod.confirm = FALSE; /* Use our own, single tasking, box */
2985 - if (check_changed_any(FALSE))
2987 - swi(Wimp_ReportError,
2988 - "\0\0\0\0Vim contains unsaved data - quit anyway?",
2991 - cmdmod.confirm = old_confirm;
2995 - cmdmod.confirm = old_confirm;
2999 - /* Quit without checking for unsaved data. */
3006 - exiting = FALSE; /* probably can't get here */
3007 - setcursor(); /* position cursor */
3011 - /* Insent the given vim special code into the input buffer */
3013 - ro_press(a, b, modifier)
3016 - int modifier; /* %<Ctrl><Shift> 0000 0000 */
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);
3029 - buf[4] = KEY2TERMCAP0(key);
3030 - buf[5] = KEY2TERMCAP1(key);
3034 - buf[1] = KS_MODIFIER;
3036 - add_to_input_buf(buf, 6);
3039 - add_to_input_buf(buf + 3, 3);
3042 - /* Take a wimp key code and insert the vim equivalent
3043 - * into vim's input buffer.
3044 - * CTRL-C also sets got_int.
3047 - ro_insert_key(code)
3048 - char_u *code; /* Wimp_ProcessKey code (4 bytes) */
3052 - int base, modifier;
3054 - if (a == 3 && ctrl_c_interrupts)
3057 - /* Is it a normal key? */
3058 - if (a > 31 && a < 127)
3060 - add_to_input_buf(code, 1);
3064 - /* We should pass any unrecognised keys on, but
3065 - * for now just pass on F12 combinations.
3070 - /* Home and Delete are the only special cases */
3074 - ro_press('k','h', 0); /* Home */
3077 - ro_press('k','D', 0); /* Delete */
3081 - /* Turn CSI into K_CSI. Untested! */
3082 - char_u string[3] = {CSI, KS_EXTRA, KE_CSI};
3084 - add_to_input_buf(string, 3);
3088 - add_to_input_buf(code, 1);
3092 - if ((a & 0xcf) == 0xcc)
3094 - /* F12 pressed - pass it on (quick hack) */
3095 - swi(Wimp_ProcessKey, a | 0x100);
3099 - modifier = a & 0x30;
3102 - case 0x8a: /* Tab */
3103 - add_to_input_buf("\011", 1);
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);
3115 - return ro_press('k', 'd', modifier);
3116 - case 0x8f: /* Up */
3117 - if (modifier & 0x10)
3118 - return ro_press('k', 'P', modifier ^ 0x10);
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);
3128 - if (base > 0x80 && base < 0x18a)
3130 - /* One of the other function keys */
3131 - return ro_press('k', '0' + (base & 15), modifier);
3137 - /* Process a mouse event. */
3142 - int x, y, button, vim_button;
3143 - int modifiers = 0;
3144 - int min_x, min_y; /* Visible area of editor window */
3147 - if (block[3] != gui.window_handle || ro_dragging)
3148 - return; /* Not our window or ignoring clicks*/
3150 - x = block[0]; /* Click position - screen coords */
3152 - button = block[2];
3154 - block[0] = gui.window_handle;
3155 - swi(Wimp_GetWindowState, 0, block);
3161 - if (block[3] - x < gui.scrollbar_width)
3163 - /* Click in that blank area under the scrollbars */
3165 - if (button & 0x444)
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);
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;
3183 - block[6] = min_x +
3184 - gui.scrollbar_width * 2 +
3185 - MIN_COLUMNS * gui.char_width;
3187 - gui_mch_get_screen_dimensions(&block[8], &block[9]);
3188 - block[9] = max_y -
3189 - 4 * gui.char_height -
3190 - gui.scrollbar_height;
3192 - swi(Wimp_DragBox, 0, block);
3193 - ro_dragging = DRAG_RESIZE_WINDOW;
3194 - drag_button = vim_button;
3195 - drag_modifiers = modifiers;
3199 - if (button & 0x111)
3200 - vim_button = MOUSE_RIGHT;
3201 - else if (button & 0x222)
3202 - vim_button = MOUSE_MIDDLE;
3204 - vim_button = MOUSE_LEFT;
3206 - swi(OS_Byte, 121, 0x80);
3208 - modifiers |= MOUSE_SHIFT;
3209 - swi(OS_Byte, 121, 0x81);
3211 - modifiers |= MOUSE_CTRL;
3212 - swi(OS_Byte, 121, 0x82);
3214 - modifiers |= MOUSE_ALT;
3219 - * If shift was pressed then do the paste action.
3220 - * If not, then open the pop-up menu.
3222 - modifiers ^= MOUSE_SHIFT;
3223 - if (modifiers && MOUSE_SHIFT)
3226 - /* Shift was NOT pressed - show menu */
3227 - main.dname = (char_u *) "Vim";
3228 - main.children = root_menu;
3229 - gui_mch_show_popupmenu(&main);
3234 - /* Gain the input focus */
3235 - swi(Wimp_SetCaretPosition, gui.window_handle, -1, 0, 0, -1, -1);
3237 - if (button & 0xf0)
3239 - /* Drag operation:
3241 - * Tell the Wimp to start a drag.
3242 - * Monitor null events.
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. */
3249 - gui_mch_get_screen_dimensions(&block[8], &block[9]);
3251 - drag_x_offset = drag_y_offset = 0;
3253 - swi(Wimp_DragBox, 0, block);
3254 - ro_dragging = DRAG_SELECTION;
3255 - drag_button = vim_button;
3256 - drag_modifiers = modifiers;
3258 - vim_button |= MOUSE_DRAG;
3261 - gui_send_mouse_event(
3265 - button & 0xf ? TRUE : FALSE, /* dclick */
3270 - ro_continue_drag(block)
3271 - int *block; /* Just used as scrap. */
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;
3280 - block[0] = gui.window_handle;
3281 - swi(Wimp_GetWindowState, 0, block);
3283 - if (ro_dragging == DRAG_RESIZE_WINDOW)
3285 - /* Resizing the main window. */
3288 - ro_open_main(block);
3292 - /* Selecting some text. */
3293 - gui_send_mouse_event(
3294 - drag_button | MOUSE_DRAG, /* Always report the same button */
3297 - FALSE, /* Not a double click. */
3302 - /* User has released all mouse buttons, marking the end of a drag. */
3304 - ro_drag_finished(block)
3309 - int width, height;
3311 - /* I don't trust the box returned by Wimp_Poll; look at the pointer
3314 - swi(Wimp_GetPointerInfo, 0, block);
3315 - x = block[0] + drag_x_offset;
3316 - y = block[1] + drag_y_offset;
3318 - if (ro_dragging == DRAG_RESIZE_WINDOW)
3320 - block[0] = gui.window_handle;
3321 - swi(Wimp_GetWindowState, 0, block);
3324 - ro_open_main(block);
3326 - width = (block[3] - block[1]);
3327 - height = (block[4] - block[2]);
3329 - swi(Wimp_ForceRedraw, gui.window_handle, 0, -height, width, 0);
3330 - gui_resize_shell(width, height);
3334 - block[0] = gui.window_handle;
3335 - swi(Wimp_GetWindowState, 0, block);
3336 - gui_send_mouse_event(
3340 - FALSE, /* not a double click */
3343 - ro_dragging = DRAG_FALSE;
3346 - /* Load the file/pathname given in block into a [new] buffer.
3350 - * None :confirm e <file>
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.
3358 - * NB: Doesn't send DataLoadAck (other app might delete temp file?).
3361 - ro_dataload(block)
3364 - char_u new_path[MAXPATHL];
3365 - char_u *path = ((char_u *) block) + 44;
3366 - int scrap = FALSE;
3368 - if (block[3] == leaf_ref && leaf_name)
3371 - switch (get_real_state() & 0xff)
3375 - case CMDLINE+LANGMAP:
3376 - /* For insert mode we can only insert the pathname (currently)
3377 - * Make sure Shift is pressed.
3379 - swi(OS_Byte, 121, 0x80); /* Is Shift pressed? */
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. */
3387 - swi(Wimp_ReportError,
3388 - "\0\0\0\0Sorry, you can only load text in normal mode", 5, "Vim");
3392 - ro_return_early = TRUE; /* Return even though nothing was typed. */
3394 - if (scrap) /* Remove <Wimp$Scrap>. Later. */
3395 - ins_typebuf(":!~remove <Wimp$Scrap>\r", REMAP_NONE, 0, TRUE, FALSE);
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);
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);
3408 - vim_free(leaf_name);
3412 - swi(OS_Byte, 121, 0x81); /* Is Ctrl pressed? */
3414 - /* Yes, split window */
3415 - ins_typebuf(":sp", REMAP_NONE, 0, TRUE, FALSE);
3417 - ins_typebuf(":confirm e", REMAP_NONE, 0, TRUE, FALSE);
3421 - swi(Wimp_ReportError, "\0\0\0\0You can only load text in normal mode.", 5, "Vim");
3423 - /* Send DataSaveAck so other program doesn't think we died
3424 - * and delete <Wimp$Scrap>.
3426 - block[3] = block[2];
3428 - swi(Wimp_SendMessage, 17, block, block[1]);
3432 - ro_datasave(block)
3435 - char_u *path = ((char_u *) block) + 44;
3437 - /* Preserve the name given so we can use it, not <Wimp$Scrap> */
3439 - vim_free(leaf_name);
3440 - leaf_name = vim_strsave(path);
3442 - block[9] = -1; /* File is unsafe. */
3443 - strcpy(path, "<Wimp$Scrap>");
3445 - block[3] = block[2];
3447 - swi(Wimp_SendMessage, 17, block, block[1]);
3449 - leaf_ref = block[2];
3459 - if (block[1] == task_handle)
3460 - return; /* Don't talk to ourself! */
3463 - case 0: /* Quit. */
3464 - if (block[4] == 0)
3467 - case 1: /* DataSave */
3468 - ro_datasave(block);
3470 - case 2: /* DataSaveAck. */
3471 - if (clip_convert_selection(&buffer, &len, &clip_star) == -1)
3474 - /* Save the clipboard contents to a file. */
3475 - swi(OS_File, 10, ((char_u *) block) + 44, 0xfff, 0, buffer, buffer + len);
3477 - /* Ack with DataLoad message. */
3478 - block[3] = block[2];
3481 - swi(Wimp_SendMessage, 17, block, block[1]);
3485 - case 3: /* DataLoad */
3486 - ro_dataload(block);
3488 - case 8: /* PreQuit */
3489 - ro_prequit(block);
3491 - case 0xf: /* Lose clipboard. */
3494 - clip_free_selection(&clip_star);
3495 - clip_star.owned = FALSE;
3498 - case 0x10: /* DataRequest (clip_star) */
3499 - if (clip_star.owned)
3503 - /* Tell other program that we have the clipboard. */
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
3509 - rows = clip_star.end.lnum - clip_star.start.lnum;
3512 - block[9] = (rows + 1) * Columns + 1; /* Add one for possible
3514 - block[10] = 0xfff; /* Clipboard is text. */
3515 - strcpy( ((char_u *) block) + 44, "VimClip");
3516 - swi(Wimp_SendMessage, 17, block, block[1]);
3519 - case 0x400c1: /* Mode change */
3520 - changed_mode = TRUE; /* Flag - update on next OpenWindow */
3523 - /* JK230798, re-initialise ZapRedraw stuff */
3524 - if (ro_zap_redraw_initialise() == FAIL)
3525 - zap_redraw = FALSE;
3528 - case 0x400c3: /* TaskCloseDown */
3529 - if (block[1] == child_handle)
3536 - * Converts a scrollbar's window handle into a scrollbar pointer.
3537 - * NULL on failure.
3545 - if (gui.bottom_sbar.id == id)
3546 - return &gui.bottom_sbar;
3547 - FOR_ALL_WINDOWS(wp)
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];
3558 - scroll_to(line, sb)
3559 - int sb; /* Scrollbar number */
3564 - /* Don't put events in the input queue now. */
3565 - if (hold_gui_events)
3568 - /* Send a scroll event:
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.
3576 - code[1] = KS_VER_SCROLLBAR;
3577 - code[2] = KE_FILLER;
3579 - code[4] = line >> 24;
3580 - code[5] = line >> 16;
3581 - code[6] = line >> 8;
3583 - add_to_input_buf(code, 8);
3592 - /* Don't put events in the input queue now. */
3593 - if (hold_gui_events)
3596 - /* Send a scroll event:
3598 - * A scrollbar event is CSI (NOT K_SPECIAL)
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.
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;
3611 - add_to_input_buf(code, 8);
3622 - /* Block is ready for Wimp_OpenWindow, and also contains:
3624 - * +32 = scroll X direction (-2 .. +2)
3625 - * +36 = scroll Y direction (-2 .. +2)
3628 - sb = ro_find_sbar(block[0]);
3630 - return; /* Window not found (error). */
3636 - /* Horizontal bar. */
3637 - offset = block[8];
3639 - offset = (block[1] - block[3]) / gui.char_width;
3640 - else if (offset == 2)
3641 - offset = (block[3] - block[1]) / gui.char_width;
3643 - block[5] += offset * gui.char_width;
3645 - gui_drag_scrollbar(sb, block[5] / gui.char_width, FALSE);
3647 - swi(Wimp_OpenWindow, 0, block);
3651 - offset = -block[9];
3653 - offset = -(wp -> w_height - 1);
3654 - else if (offset == 2)
3655 - offset = wp -> w_height - 1;
3657 - /* Possibly we should reposition the scrollbar?
3658 - * Vim seems to update the bar anyway...
3660 - gui_drag_scrollbar(sb, offset - (block[6] / gui.char_height), FALSE);
3664 - /* Move a window by a given offset. Used to simulate the function of the
3668 - ro_move_child(window, x, y, pos_wanted, pos_got)
3670 - int x,y; /* offset to move by */
3671 - int pos_wanted, pos_got;
3675 - block[0] = window;
3676 - swi(Wimp_GetWindowState, 0, block);
3681 - if (pos_wanted == -1)
3683 - else if (pos_wanted == -2)
3684 - block[7] = pos_got;
3685 - swi(Wimp_OpenWindow, 0, block);
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.
3693 - ro_open_main(block)
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);
3705 - swi(Wimp_OpenWindow, 0, block);
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];
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.
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];
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)
3734 - /* If parent has moved, re-open all the child windows. */
3735 - FOR_ALL_WINDOWS(wp)
3737 - /* Reopen scrollbars for this window. */
3739 - ro_move_child(wp -> w_scrollbars[SBAR_LEFT].id,
3740 - x_offset, y_offset,
3741 - pos_wanted, pos_got);
3743 - ro_move_child(wp -> w_scrollbars[SBAR_RIGHT].id,
3744 - x_offset, y_offset,
3745 - pos_wanted, pos_got);
3749 - if (changed_mode || toggle_size)
3751 - int width, height;
3754 - ro_measure_tools();
3755 - block[0] = gui.window_handle;
3756 - swi(Wimp_GetWindowState, 0, block);
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;
3767 - ro_open_window(block)
3773 - if (block[0] == gui.window_handle)
3774 - ro_open_main(block);
3777 - swi(Wimp_OpenWindow, 0, block);
3778 - if (block[0] != gui.window_handle)
3780 - sb = ro_find_sbar(block[0]);
3783 - if (sb-> wp != NULL)
3784 - gui_drag_scrollbar(sb, -block[6] / gui.char_height, FALSE);
3786 - gui_drag_scrollbar(sb, block[5] / gui.char_width, FALSE);
3793 - ro_menu_selection(block)
3796 - int *item = wimp_menu + 7;
3798 - /* wimp_menu points to a wimp menu structure */
3802 - while (block[0]--)
3804 - if (block[1] == -1)
3806 - item = ((int *) item[1]) + 7;
3809 - /* item points to the wimp menu item structure chosen */
3810 - menu = (vimmenu_T *) item[5];
3812 - swi(Wimp_GetPointerInfo, 0, block);
3813 - if (block[2] == 1)
3814 - /* Adjust used - keep menu open */
3815 - swi(Wimp_CreateMenu, 0, wimp_menu);
3825 - char_u *i = curbuf-> b_ffname;
3826 - char_u buffer[256];
3832 - head = i - curbuf-> b_ffname;
3835 - /* Append head chars to buffer */
3836 - if (head < 240 && curbuf-> b_ffname && head)
3838 - strcpy(buffer, "%filer_opendir ");
3839 - strncpy(buffer + 15, curbuf-> b_ffname, head);
3840 - buffer[15 + head] = '\0';
3841 - swi(OS_CLI, buffer);
3846 - process_event(event, block)
3852 - case 0: /* Nothing - update drag state. */
3854 - ro_continue_drag(block);
3856 - case 1: /* Redraw window. */
3857 - redraw_window(block);
3859 - case 2: /* Open window. */
3860 - ro_open_window(block);
3862 - case 3: /* Close window. */
3863 - swi(Wimp_GetPointerInfo, 0, block + 1);
3864 - if (block[3] == 1)
3867 - if (ro_ok_to_quit())
3870 - case 6: /* Mouse click. */
3873 - case 7: /* Finished drag. */
3874 - ro_drag_finished(block);
3876 - case 8: /* Key pressed. */
3877 - ro_insert_key((char_u *) &block[6]);
3880 - ro_menu_selection(block);
3882 - case 10: /* Scroll request. */
3885 - case 11: /* Lose caret. */
3886 - if (block[0] == gui.window_handle)
3887 - gui_focus_change(FALSE);
3889 - case 12: /* Gain caret. */
3890 - if (block[0] == gui.window_handle)
3891 - gui_focus_change(TRUE);
3893 - case 17: /* User message. */
3894 - case 18: /* User message recorded. */
3895 - ro_message(block);
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.
3910 - gui_mch_wait_for_chars(long wtime)
3914 - int start_time = -1;
3915 - int ctime = wtime / 10; /* delay in cs */
3919 - swi(OS_ReadMonotonicTime);
3926 - reason = wimp_poll(0, block); /* Always return immediately */
3927 - else if (wtime == -1)
3928 - reason = wimp_poll(1, block);
3930 - reason = wimp_pollidle(0, block, start_time + ctime);
3932 - process_event(reason, block);
3934 - if (input_available() || ro_return_early)
3936 - ro_return_early = FALSE;
3937 - return OK; /* There is something to process (key / menu event) */
3942 - swi(OS_ReadMonotonicTime);
3943 - if (r0 - start_time > ctime)
3944 - return FAIL; /* We've been waiting too long - return failure */
3949 - /* Flush any output to the screen */
3951 - gui_mch_flush(void)
3956 - * Clear a rectangular region of the screen from text pos(row1, col1) to
3957 - * (row2, col2) inclusive.
3960 - gui_mch_clear_block(int row1, int col1, int row2, int col2)
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));
3969 - gui_mch_clear_all(void)
3973 - swi(ColourTrans_SetGCOL, gui.back_pixel << 8, 0, 0, 1<<7, 0);
3974 - swi(OS_WriteI + 16);
3979 - block[0] = gui.window_handle;
3981 - block[2] = -gui.num_rows * gui.char_height;
3982 - block[3] = gui.num_cols * gui.char_width;
3984 - swi(Wimp_UpdateWindow, 0, block);
3987 - swi(ColourTrans_SetGCOL, gui.back_pixel << 8, 0, 0, 1<<7, 0);
3988 - swi(OS_WriteI + 16);
3989 - swi(Wimp_GetRectangle, 0, block);
3995 - * Delete the given number of lines from the given row, scrolling up any
3996 - * text further down within the scroll region.
3999 - gui_mch_delete_lines(int row, int num_lines)
4001 - int top_from = -row - num_lines;
4002 - int bot_from = -gui.scroll_region_bot - 1;
4003 - int bot_to = bot_from + num_lines;
4005 - swi(ColourTrans_SetGCOL, gui.back_pixel << 8, 0, 0, 0x80, 0);
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,
4015 - gui.scroll_region_left * gui.char_width,
4016 - bot_to * gui.char_height);
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);
4024 - * Insert the given number of lines before the given row, scrolling down any
4025 - * following text within the scroll region.
4028 - gui_mch_insert_lines(int row, int num_lines)
4030 - int top_from = -row;
4031 - int bot_to = -gui.scroll_region_bot - 1;
4032 - int bot_from = bot_to + num_lines;
4034 - swi(ColourTrans_SetGCOL, gui.back_pixel << 8, 0, 0, 0x80, 0);
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,
4043 - gui.scroll_region_left * gui.char_width,
4044 - bot_to * gui.char_height);
4046 - gui_clear_block(row, gui.scroll_region_left,
4047 - row + num_lines - 1, gui.scroll_region_right);
4050 - /* Put selection in clipboard buffer.
4051 - * Should we become the new owner?
4054 - clip_mch_request_selection(VimClipboard *cbd)
4056 - int block[64]; /* Will be used in Wimp_Poll. */
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. */
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. */
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!).
4081 - reason = wimp_poll(0, block);
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)
4091 - /* Tell owner to save data in <Wimp$Scrap>. */
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]);
4099 - /* Wait again for reply. */
4102 - reason = wimp_poll(0, block);
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)
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)
4119 - buffer = lalloc(length, TRUE); /* Claim memory (and report errors). */
4120 - if (buffer == NULL)
4123 - if (xswi(OS_File, 16, "<Wimp$Scrap>", buffer, 0) & v_flag)
4126 - clip_yank_selection(MCHAR, buffer, length, cbd);
4130 - swi(OS_FSControl, 27, "<Wimp$Scrap>", 0, 0); /* Delete temp file. */
4132 - block[4] = 4; /* Send DataLoadAck. */
4133 - block[3] = block[2]; /* Copy myref -> yourref. */
4134 - swi(Wimp_SendMessage, 17, block, block[1]);
4137 - /* Not sure what this means under RISC OS. */
4139 - clip_mch_lose_selection(VimClipboard *cbd)
4143 - /* Tell everyone that we now own the clipboard.
4144 - * Return OK if our claim is accepted (always, under RISC OS)
4147 - clip_mch_own_selection(VimClipboard *cbd)
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);
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.
4164 - clip_mch_set_selection(VimClipboard *cbd)
4166 - clip_get_selection(cbd);
4170 - * Make a menu either grey or not grey.
4173 - gui_mch_menu_grey(vimmenu_T *menu, int grey)
4175 - menu-> greyed_out = grey;
4179 - * Make menu item hidden or not hidden
4182 - gui_mch_menu_hidden(vimmenu_T *menu, int hidden)
4184 - menu-> hidden = hidden;
4188 - * This is called after setting all the menus to grey/hidden or not.
4191 - gui_mch_draw_menubar(void)
4193 - swi(Wimp_CreateMenu, 0, -1);
4194 - if (wimp_menu != (int *) -1)
4196 - ro_remove_menu(wimp_menu);
4197 - wimp_menu = (int *) -1;
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.
4208 - gui_mch_enable_scrollbar(sb, flag)
4213 - swi(Wimp_CloseWindow, 0, & (sb->id) );
4218 - gui_mch_set_blinking(long waittime, long on, long off)
4223 - * Stop the cursor blinking. Show the cursor if it wasn't shown.
4226 - gui_mch_stop_blink(void)
4231 - * Start the cursor blinking. If it was already blinking, this restarts the
4232 - * waiting time and shows the cursor.
4235 - gui_mch_start_blink(void)
4240 - * Return the RGB value of a pixel as a long.
4243 - gui_mch_get_rgb(guicolor_T pixel)
4245 - return (long_u)pixel;
4249 - gui_mch_set_text_area_pos(int x, int y, int w, int h)
4254 - gui_mch_enable_menu(int flag)
4259 - gui_mch_set_menu_pos(int x, int y, int w, int h)
4264 - gui_mch_add_menu(vimmenu_T *menu, int idx)
4269 - gui_mch_add_menu_item(vimmenu_T *menu, int idx)
4274 - gui_mch_new_menu_colors(void)
4279 - gui_mch_destroy_menu(vimmenu_T *menu)
4283 - /* Size of buffer has changed.
4284 - * Add one to max since gui.c subtracts one more than it should!
4287 - gui_mch_set_scrollbar_thumb(sb, val, size, max)
4293 - int block[10], width, height;
4295 - width = (max + 1) * gui.char_width;
4296 - height = (max + 1 + W_STATUS_HEIGHT(sb->wp)) * gui.char_height;
4298 - block[0] = block[3] = 0;
4299 - block[1] = -height + (1 << y_eigen_factor);
4302 - swi(Wimp_SetExtent, sb -> id, block);
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)
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.
4324 - gui_mch_set_scrollbar_pos(sb, x, y, w, h)
4326 - int x; /* Horizontal sb position */
4327 - int y; /* Top of scroll bar */
4328 - int w; /* Width */
4329 - int h; /* Height */
4332 - int px1, py1; /* Parent window min coords */
4333 - int px2, py2; /* Parent window max coords */
4335 - /* Find where the parent window is. */
4336 - block[0] = gui.window_handle;
4337 - swi(Wimp_GetWindowState, 0, block);
4343 - block[0] = sb -> id;
4345 - /* Find out how big the scroll window is at the moment. */
4346 - swi(Wimp_GetWindowInfo, 0, ((char_u *)block) + 1);
4348 - if (block[13] < w || block[12] > -h)
4350 - /* Current window is too small! */
4351 - if (block[12] > -h)
4353 - if (block[13] < w)
4355 - swi(Wimp_SetExtent, block[0], block + 11);
4358 - /* This works better on the nested_wimp. */
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;
4368 - /* This is a horizontal scrollbar. */
4369 - block[2] = block[4] = py1 + gui.scrollbar_height;
4371 - block[3] = px2 - gui.scrollbar_width;
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)
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.
4394 - gui_mch_create_scrollbar(sb, orient)
4396 - int orient; /* orient is SBAR_HORIZ or SBAR_VERT */
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) */
4416 - swi(Wimp_CreateWindow, 0, bar);
4420 - #if defined(FEAT_WINDOWS) || defined(PROTO)
4422 - gui_mch_destroy_scrollbar(scrollbar_T *sb)
4424 - swi(Wimp_DeleteWindow, 0, & (sb->id));
4430 - gui_mch_set_scrollbar_colors(scrollbar_T *sb)
4432 - /* Always use default RO colour scheme. */
4436 - * Get current mouse coordinates in text window.
4437 - * Note: (0,0) is the bottom left corner, positive y is UP.
4440 - gui_mch_getmouse(x, y)
4448 - block[0] = gui.window_handle;
4449 - swi(Wimp_GetWindowState, 0, block);
4453 - swi(Wimp_GetPointerInfo, 0, block);
4454 - *x = block[0] - left;
4455 - *y = top - block[1];
4458 - /* MouseTo(x, y) */
4460 - gui_mch_setmouse(x, y)
4467 - gui_mch_toggle_tearoffs(enable)
4470 - /* no tearoff menus */
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
4479 - ro_redraw_title(window)
4484 - swi(Wimp_ForceRedraw, window, 0x4b534154, 3);
4491 - block[0] = window;
4492 - swi(Wimp_GetWindowState, 0, block);
4494 - swi(Wimp_GetWindowOutline, 0, block);
4495 - swi(Wimp_ForceRedraw, -1,
4497 - block[3], block[4]);
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.
4506 - ro_build_menu(menu)
4516 - /* Find out how big the menu is so we can allocate memory for it */
4517 - for (item = menu-> children; item; item = item-> next)
4519 - if (item-> hidden == FALSE && !menu_is_separator(item->name))
4524 - return (int *) -1; /* No children - shouldn't happen */
4526 - wimp_menu = (int *) alloc(size);
4528 - wimp_menu[0] = (int) menu-> dname;
4529 - wimp_menu[1] = -1;
4531 - wimp_menu[3] = 0x00070207;
4532 - wimp_menu[5] = 44;
4535 - wimp_item = wimp_menu + 7;
4537 - for (item = menu-> children; item; item = item-> next)
4539 - if (menu_is_separator(item-> name))
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
4545 - if (wimp_item > wimp_menu + 7)
4546 - wimp_item[-6] |= 0x2;
4548 - else if (item-> hidden == FALSE)
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 */
4557 - w = strlen(item-> dname) + 1;
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 */
4571 - ro_remove_menu(menu)
4574 - int *item = menu + 7;
4576 - if (menu == NULL || menu == (int *) -1)
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 */
4591 - gui_mch_show_popupmenu(menu)
4596 - /* Remove the existing menu, if any */
4597 - if (wimp_menu != (int *) -1)
4599 - swi(Wimp_CreateMenu, 0, -1);
4600 - ro_remove_menu(wimp_menu);
4601 - wimp_menu = (int *) -1;
4604 - wimp_menu = ro_build_menu(menu);
4605 - if (wimp_menu != (int *) -1)
4607 - swi(Wimp_GetPointerInfo, 0, block);
4608 - swi(Wimp_CreateMenu, 0, wimp_menu, block[0] - 64, block[1] + 64);
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.
4617 - gui_mch_call_shell(cmd, options)
4619 - int options; /* SHELL_FILTER if called by do_filter() */
4620 - /* SHELL_COOKED if term needs cooked mode */
4622 - char_u task_cmd[256]; /* Contains *TaskWindow command. */
4628 - char_u *out_redir;
4630 - FILE *out_file = NULL;
4632 - out_redir = strstr(cmd, " > ");
4633 - if (out_redir == NULL)
4634 - length = strlen(cmd); /* No redirection. */
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);
4647 - return FAIL; /* Command too long. */
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\"",
4656 - if (options & SHELL_COOKED)
4657 - settmode(TMODE_COOK);
4659 - if (xswi(Wimp_StartTask, task_cmd) & v_flag)
4661 - /* Failed to even start a new task (out of memory?) */
4662 - settmode(TMODE_RAW);
4668 - /* Wait for the child process to initialise. */
4670 - while (!child_handle)
4672 - reason = wimp_poll(0, block);
4673 - if ((reason == 17 || reason == 18) && block[4] == 0x808c2)
4674 - child_handle = block[1];
4676 - process_event(reason, block);
4679 - /* Block until finished */
4680 - while (child_handle)
4682 - reason = wimp_poll(1, block);
4683 - if (reason == 3 || (reason == 8 && block[6] == 3))
4685 - /* Close window request or CTRL-C - kill child task. */
4688 - block[4] = 0x808c4; /* Morite */
4689 - swi(Wimp_SendMessage, 17, block, child_handle);
4690 - MSG_PUTS(_("\nSending message to terminate child process.\n"));
4693 - else if (reason == 8)
4697 - block[4] = 0x808c0; /* Input */
4699 - /* Block[6] is OK as it is! */
4700 - swi(Wimp_SendMessage, 17, block, child_handle);
4703 - else if (reason == 17 || reason == 18)
4705 - if (block[4] == 0x808c1)
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]--)
4715 - if (out_file && (c != '\r' || (options & SHELL_FILTER)))
4716 - fputc(c, out_file);
4717 - if ((options & SHELL_FILTER) == 0)
4720 - msg_puts("\b \b");
4725 - lines_left = 8; /* Don't do More prompt! */
4730 - /* Flush output to the screen. */
4731 - windgoto(msg_row, msg_col);
4736 - process_event(reason, block);
4738 - msg_putchar('\n');
4739 - settmode(TMODE_RAW);
4745 - /* Like strsave(), but stops at any control char */
4752 - while (str[strlen] > 31)
4754 - retval = alloc(strlen + 1);
4757 - memcpy(retval, str, strlen);
4758 - retval[strlen] = '\0';
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.
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 */
4776 - char command[256];
4783 - int done_save = FALSE;
4784 - char_u *retval = NULL;
4787 - int dragging_icon = FALSE;
4791 - dflt = "TextFile";
4793 - block[0] = save_window;
4795 - swi(Wimp_GetIconState, 0, block);
4796 - sprname = ((char_u *) block[7]);
4798 - swi(Wimp_GetIconState, 0, block);
4799 - fname = ((char *) block[7]);
4800 - strncpy(fname, dflt, 255);
4802 - if (xswi(OS_FSControl, 31, curbuf->b_p_oft) & v_flag)
4805 - strcpy(sprname + 5, "xxx");
4810 - sprintf(sprname + 5, "%03x", filetype);
4813 - /* Open the save box */
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);
4819 - while (!done_save)
4821 - reason = wimp_poll(1, block);
4825 - redraw_window(block);
4828 - if (block[0] == save_window)
4829 - swi(Wimp_OpenWindow, 0, block);
4831 - ro_open_window(block);
4837 - if (block[3] != save_window)
4846 - case 0: /* Start drag */
4847 - block[0] = save_window;
4848 - swi(Wimp_GetWindowState, 0, block);
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;
4858 - swi(DragASprite_Start,
4863 - dragging_icon = TRUE;
4866 - retval = wimp_strsave(fname);
4869 - case 3: /* Cancel */
4876 - if (dragging_icon)
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;
4889 - while (fname[len] > 31)
4891 - if (fname[len] == '.')
4902 - memcpy(((char_u *) block) + 44, fname, len);
4903 - ((char_u *)block)[44 + len] = '\0';
4905 - block[0] = (len + 48) & 0xfc;
4907 - block[4] = 1; /* DataSave */
4909 - swi(Wimp_SendMessage, 17, block, block[5], block[6]);
4912 - ro_drag_finished(block);
4915 - if (block[6] == 13)
4917 - retval = wimp_strsave(fname);
4920 - else if (block[6] == 0x1b)
4923 - swi(Wimp_ProcessKey, block[6]);
4927 - if (block[4] == 2 && block[9] != -1)
4929 - /* DataSaveAck from dragging icon. */
4930 - retval = wimp_strsave(((char_u *) block) + 44);
4933 - else if (block[4] == 0x400c9)
4935 - /* MenusDeleted */
4939 - ro_message(block);
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);
4953 - /* Open a directory viewer */
4954 - length = strlen(initdir);
4957 - return NULL; /* Path too long! */
4959 - length = sprintf(command, "Filer_OpenDir %s", initdir);
4960 - while (command[length - 1] == '.')
4962 - command[length] = '\0';
4963 - swi(OS_CLI, command);
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
4972 - /* vi:set ts=8 sts=4 sw=4:
4974 - * VIM - Vi IMproved by Bram Moolenaar
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.
4986 - * Thomas Leonard <tal197@ecs.soton.ac.uk>
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. */
4995 - int old_escape_state = -1;
4996 - int old_cursor_state = -1;
4998 - #define rgb(r,g,b) ((b<<24) + (g<<16) + (r<<8))
4999 - #define NORMAL_FG 0x00000000
5000 - #define NORMAL_BG 0xffffffff
5002 - /* Convert a DOS colour number to an RGB palette entry.
5003 - * Mappings from X11 rgb/txt file.
5007 - int dos; /* Standard DOS colour number. */
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 */
5028 - return rgb(100,100,100);
5033 - int fg; /* Foregound colour in the form &BBGGRR00 */
5035 - xswi(ColourTrans_SetTextColour, fg, 0, 0, 0);
5040 - int bg; /* Backgound colour in the form &BBGGRR00 */
5042 - xswi(ColourTrans_SetTextColour, bg, 0, 0, 1 << 7);
5045 - #define OUT_NORMAL 0
5046 - #define OUT_NUMBER 1 /* Reading in a number */
5053 - static int mode = OUT_NORMAL;
5054 - static int x, y; /* For reading numbers in. */
5056 - if (!term_console)
5058 - /* Maybe we are running Vim remotely - don't interpret chars */
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?
5067 - swi(OS_WriteI + 13);
5078 - if (c < '0' || c > '9')
5080 - mode = OUT_NORMAL;
5084 - x = (x * 10) + c - '0';
5087 - /* note: no break here! */
5093 - /* Number (in decimal) follows. */
5094 - mode = OUT_NUMBER;
5099 - /* Position cursor. */
5100 - swi(OS_WriteI + 31);
5101 - swi(OS_WriteC, x);
5102 - swi(OS_WriteC, y - ScrollTop);
5105 - /* Set scroll region. */
5106 - if (x == Rows -1 && y == 0 && !windowed)
5108 - /* Whole screen - remove text window.
5109 - * This is MUCH faster.
5111 - swi(OS_WriteI + 26);
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);
5125 - /* Normal mode. */
5126 - text_fg(NORMAL_FG);
5127 - text_bg(NORMAL_BG);
5130 - /* Reverse mode. */
5131 - text_fg(NORMAL_BG);
5132 - text_bg(NORMAL_FG);
5138 - /* Cursor invisible. */
5140 - "\027\001\000\000\000\000\000\000\000\000",
5144 - /* Cursor visible. */
5146 - "\027\001\002\000\000\000\000\000\000\000",
5150 - /* Cursor very visible (flash) */
5152 - "\027\001\003\000\000\000\000\000\000\000",
5155 - /* Set foreground colour. */
5156 - text_fg(map_colour(x));
5159 - /* Set background colour. */
5160 - text_bg(map_colour(x));
5163 - /* Scroll text down. */
5165 - "\027\007\000\002\000\000\000\000\000\000",
5169 - swi(OS_WriteC, c);
5174 - printf("[output error]");
5175 - mode = OUT_NORMAL;
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.
5188 - * TODO: call convert_input() for 'fileencoding' to 'encoding' conversion.
5191 - mch_inchar(buf, maxlen, wtime, tb_change_cnt)
5195 - int tb_change_cnt;
5198 - unsigned int start_time = clock();
5202 - /* We're probably in Ex mode - get whole lines at a time. */
5204 - static char_u line_buffer[256];
5205 - static int remaining_chars = 0;
5206 - static int buf_pos = 0;
5208 - /* Do we need to fetch another line? */
5209 - if (remaining_chars == 0)
5211 - int old_esc_state;
5212 - swi(OS_Byte, 200, 1, 0xfe);
5213 - old_esc_state = r1;
5216 - if (xswi(OS_ReadLine, line_buffer, 255, 0, 255) & (c_flag | v_flag))
5218 - got_int = TRUE; /* ESC pressed */
5221 - line_buffer[r1] = 13;
5222 - remaining_chars = r1 + 1; /* Count CR as part of input */
5224 - swi(OS_Byte, 200, old_esc_state, 0);
5227 - /* Can we send the rest of the buffer back in one go? */
5228 - if (remaining_chars <= maxlen)
5230 - int got = remaining_chars;
5232 - memcpy(buf, line_buffer + buf_pos, got);
5233 - remaining_chars = 0;
5237 - /* Send as much as we can */
5238 - memcpy(buf, line_buffer + buf_pos, maxlen);
5239 - buf_pos += maxlen;
5240 - remaining_chars -= maxlen;
5245 - if (!term_console)
5247 - /* Use OS_ReadC for all input.
5248 - * Avoids problems with remote access getting interference from
5252 - return 0; /* Ignore quick key checks */
5254 - if (xswi(OS_ReadC) & c_flag)
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! */
5265 - * OK, here's the plan:
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
5271 - while (xswi(OS_Byte,145,0) & c_flag)
5273 - /* Nothing at all in the keyboard buffer.
5274 - * Has our time expired yet?
5276 - if ( (wtime != -1) && (clock() - start_time) >= wtime )
5277 - return 0; /* Nothing read - giving up */
5280 - /* We've got one char (in r2) - are there any more? */
5282 - while (got < maxlen)
5286 - if (xswi(OS_Byte,145,0) & c_flag)
5287 - return got; /* Keyboard buffer empty */
5289 - return got; /* buf is full */
5293 - * return non-zero if a character is available
5298 - if (!term_console)
5299 - return 0; /* Can't tell */
5300 - if (xswi(OS_Byte, 152, 0) & c_flag)
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.
5313 - mch_avail_mem(special)
5316 - if (xswi(Wimp_SlotSize, -1, -1) & v_flag)
5317 - return 0x7fffffff;
5322 - mch_delay(msec, ignoreinput)
5326 - int start_time, time_now;
5327 - int csec = msec / 10;
5329 - swi(OS_ReadMonotonicTime);
5334 - swi(OS_ReadMonotonicTime);
5336 - if (time_now - start_time > csec)
5339 - /* In the GUI, allow other programs to run while waiting. */
5341 - gui_mch_wait_for_chars(start_time + csec);
5347 - * If the machine has job control, use it to suspend the program,
5348 - * otherwise fake it by starting a new shell.
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.
5365 - int buf[7] = {132, 135, 256, 257, 1, 2, -1};
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
5374 - swi(OS_ReadVduVariables, buf, buf);
5378 - Rows = buf[3] + 1; /* Seems to be one off (VduVars wrong?) */
5381 - /* Are we running in a textwindow? */
5382 - if (Rows == buf[5] + 1 && Columns == buf[4] + 1)
5387 - /* Choose a nice colour scheme. */
5388 - text_fg(NORMAL_FG);
5389 - text_bg(NORMAL_BG);
5393 - * Check_win checks whether we have an interactive stdout.
5397 - mch_check_win(argc, argv)
5405 - * Return TRUE if the input comes from a terminal, FALSE otherwise.
5408 - mch_input_isatty()
5410 - if (xswi(OS_ChangeRedirection, -1, -1) & v_flag)
5411 - return TRUE; /* Error - TRUE is probably correct though */
5419 - mch_can_restore_title()
5425 - mch_can_restore_icon()
5432 - * Set the window title and icon.
5435 - mch_settitle(title, icon)
5439 - if (title == NULL)
5440 - title = (char_u *) "<untitled>";
5442 - if (gui.in_use && strcmp(title, gui.window_title))
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);
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
5464 - mch_restore_title(which)
5472 - * Insert user name in s[len].
5473 - * Return OK if a name found.
5476 - mch_get_user_name(s, len)
5480 - /* RISC OS doesn't support user names. */
5486 - * Insert host name in s[len].
5490 - mch_get_host_name(s, len)
5494 - if (xswi(OS_ReadVarVal, "Machine$Name", s, len, 0, 3) & v_flag)
5496 - /* Variable does not exist (normal operation) */
5497 - vim_strncpy(s, "(unknown)", len - 1);
5502 - * return process ID
5507 - if (xswi(Wimp_ReadSysInfo, 5) & v_flag)
5513 - * Get name of current directory into buffer 'buf' of length 'len' bytes.
5514 - * Return OK for success, FAIL for failure.
5517 - mch_dirname(buf, len)
5521 - if (xswi(OS_FSControl, 37, "@", buf, 0, 0, len) & v_flag)
5527 - * Get absolute file name into buffer 'buf' of length 'len' bytes.
5529 - * return FAIL for failure, OK for success
5532 - mch_FullName(fname, buf, len, force)
5533 - char_u *fname, *buf;
5535 - int force; /* Also expand when already absolute path name.
5536 - * Not used under RISC OS.
5539 - if (xswi(OS_FSControl, 37, fname, buf, 0, 0, len) & v_flag)
5545 - * Return TRUE if "fname" does not depend on the current directory.
5548 - mch_isFullName(fname)
5551 - if (strstr(fname, "::") && strstr(fname,".$."))
5557 - * Get file permissions for 'name'.
5558 - * Returns -1 when it doesn't exist.
5564 - struct stat statb;
5566 - if (stat((char *)name, &statb))
5568 - return statb.st_mode;
5572 - * set file permission for 'name' to 'perm'
5574 - * return FAIL for failure, OK otherwise
5577 - mch_setperm(name, perm)
5581 - return (chmod((char *)name, (mode_t)perm) == 0 ? OK : FAIL);
5585 - * Set hidden flag for "name".
5592 - /* can't hide a file */
5596 - * return TRUE if "name" is a directory
5597 - * return FALSE if "name" is not a directory
5598 - * return FALSE for error
5604 - if (xswi(OS_File, 17, name) & v_flag)
5606 - if (r0 == 2 || r0 == 3)
5607 - return TRUE; /* Count image files as directories. */
5612 - * Return 1 if "name" can be executed, 0 if not.
5613 - * Return -1 if unknown. Requires which to work.
5623 - buf = alloc((unsigned)STRLEN(name) + 7);
5626 - sprintf((char *)buf, "which %s", name);
5627 - p = get_cmd_output(buf, NULL, SHELL_SILENT);
5631 - /* result can be: "name: Command not found" */
5632 - retval = (*p != NUL && strstr((char *)p, "not found") == NULL);
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
5644 - mch_nodetype(name)
5648 - return NODE_NORMAL;
5654 - /* Turn off all the horrible filename munging in UnixLib. */
5655 - int __riscosify_control = __RISCOSIFY_NO_PROCESS;
5662 - settmode(TMODE_COOK);
5665 - ml_close_all(TRUE); /* remove all memfiles */
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);
5680 - mch_settmode(tmode)
5681 - int tmode; /* TMODE_RAW or TMODE_COOK */
5683 - if (tmode == TMODE_COOK)
5685 - ro_line_mode = TRUE;
5689 - ro_line_mode = FALSE;
5693 - /* Block cursor. */
5695 - "\027\000\012\000\000\000\000\000\000\000",
5698 - /* Disable the standard cursor key actions. */
5699 - swi(OS_Byte, 4, 1);
5700 - if (old_cursor_state == -1)
5701 - old_cursor_state = r1;
5704 - /* Stop Escape from quitting Vim! */
5705 - swi(OS_Byte, 229, 1, 0);
5706 - if (old_escape_state == -1)
5707 - old_escape_state = r1;
5711 - * set mouse clicks on or off (only works for xterms)
5720 - * set screen mode, always fails.
5724 - mch_screenmode(arg)
5727 - EMSG(_(e_screenmode));
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.
5738 - mch_get_shellsize()
5740 - /* if size changed: screenalloc will allocate new screen buffers */
5741 - return term_console ? OK : FAIL;
5745 - * Can't change the size.
5746 - * Assume the user knows what he's doing and use the new values.
5749 - mch_set_shellsize()
5751 - /* Assume the user knows what he's doing and use the new values. */
5755 - * Rows and/or Columns has changed.
5758 - mch_new_shellsize()
5760 - /* Nothing to do. */
5764 - mch_call_shell(cmd, options)
5766 - int options; /* SHELL_*, see vim.h */
5769 - int tmode = cur_tmode;
5772 - cmd = (char_u *) "GOS";
5776 - return gui_mch_call_shell(cmd, options);
5778 - if (options & SHELL_COOKED)
5779 - settmode(TMODE_COOK); /* set to normal mode */
5782 - /* I don't even want to think about what UnixLib must
5783 - * be doing to allow this to work...
5785 - retval = system(cmd);
5786 - if (retval && !(options & SHELL_SILENT))
5787 - EMSG(strerror(EOPSYS)); /* Doesn't seem to set errno? */
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;
5796 - * Check for Escape being pressed right now.
5797 - * [ different if !term_console? ]
5802 - if (xswi(OS_Byte, 121, 0xf0) & v_flag)
5807 - swi(OS_Byte, 15, 1); /* Flush input buffer */
5812 - * Recursively expand one path component into all matching files and/or
5814 - * "path" has backslashes before chars that are not to be expanded.
5815 - * Return the number of matches found.
5818 - mch_expandpath(gap, path, flags)
5819 - garray_T *gap; /* Grow array for results. */
5821 - int flags; /* EW_* flags */
5823 - int got; /* Number of matches. */
5828 - * 1) Get first part of path - no wildcards
5829 - * 2) Get next path element (wildcarded)
5830 - * 3) Get rest of path
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)
5835 - * This is just the header function.
5838 - /* We must be able to modifiy path, so make a copy */
5839 - pattern = vim_strsave(path);
5840 - if (pattern == NULL)
5842 - got = expand_section(gap, (char_u *)"", pattern, flags);
5843 - vim_free(pattern);
5848 - * expand_section(gap, "$.Dir1.Dir2", "ABBA*.myleaf##")
5850 - * calls expand_section(gap, "$.Dir1.Dir2.ABBA_Gold", "myleaf##")
5851 - * and expand_section(gap, "$.Dir1.Dir2.ABBA_Live", "myleaf##")
5853 - * If rest is just a leaf then all matches are added to gap.
5855 - * Returns number of items added to gap.
5858 - expand_section(gap, root, rest, flags)
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. */
5864 - static char_u buf[MAXPATHL]; /* Temporary buffer. */
5865 - char_u dir[MAXPATHL];
5866 - int start_element = -1; /* Start of wildcarded element */
5870 - int buflen; /* Chars used in buf[] */
5871 - int colon = 0; /* Dir ends in ':' */
5873 - buflen = strlen(root);
5874 - STRNCPY(buf, root, buflen); /* Copy root into buffer. */
5877 - * Find end of nonwildcarded section.
5878 - * Count ':' as a path sep since Vim:Bug* is a valid pathname.
5881 - for (i = 0; c = rest[i]; i++)
5885 - start_element = i;
5890 - start_element = i + 1;
5893 - if (c == '#' || c == '*')
5897 - start_element = i;
5900 - * start_element +> terminator for non-wildcarded section.
5901 - * Transfer this bit into buf.
5903 - if (buflen + start_element + 4 >= MAXPATHL)
5904 - return 0; /* Buffer full */
5905 - if (start_element >= 0)
5907 - if (*root && !colon)
5908 - buf[buflen++] = PATHSEP;
5909 - strncpy(buf + buflen, rest, start_element);
5910 - buflen += start_element;
5915 - * Did we reach the end of the string without hitting any wildcards?
5919 - /* Yes - add combined path to grow array and return. */
5920 - addfile(gap, buf, flags);
5924 - if (start_element < 0 || !colon)
5926 - rest += start_element;
5929 - * rest does contain wildcards if we get here.
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.
5936 - start_element = -1;
5937 - for (i = 0; rest[i]; i++)
5939 - if (rest[i] == '.')
5941 - start_element = i;
5942 - rest[i] = 0; /* Break string here. */
5947 - /* If start_element is -1 then we are matching leaf names */
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)
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. */
5967 - dir_pos = r4; /* r4 corrupted by addfile() */
5970 - char_u *path = buf;
5972 - path++; /* Don't do '.File' */
5974 - buf[buflen] = '.'; /* Join path and leaf */
5976 - /* Path -> full path of object found */
5977 - if (start_element == -1)
5979 - addfile(gap, path, flags);
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,
5989 - rest + start_element + 1,
5995 - /* Restore the dot if we removed it. */
5996 - if (start_element >= 0)
5997 - rest[start_element] = '.';
6002 - * mch_expand_wildcards() - this code does wild-card pattern matching using
6003 - * the shell. It isn't used under RISC OS.
6005 - * return OK for success, FAIL for error (you may lose some memory) and put
6006 - * an error message in *file.
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
6014 - mch_expand_wildcards(num_pat, pat, num_file, file, flags)
6019 - int flags; /* EW_* flags */
6021 - /* This doesn't get called unless SPECIAL_WILDCHAR is defined. */
6026 - * Return TRUE if "p" contains wildcards which can be expanded by
6027 - * mch_expandpath().
6030 - mch_has_exp_wildcard(p)
6033 - if (vim_strpbrk((char_u *)"*#", p))
6038 - /* Return TRUE if "p" contains wildcards. */
6040 - mch_has_wildcard(p)
6043 - if (vim_strpbrk((char_u *)"*#`", p))
6048 - int /* see Unix unlink(2) */
6050 - char_u *file; /* Name of file to delete. */
6052 - if (xswi(OS_FSControl, 27, file, 0, 0) & v_flag)
6053 - return EXIT_FAILURE;
6054 - return EXIT_SUCCESS;
6057 - /* Try to make existing scripts work without modification.
6058 - * Return a pointer to the new string (freed by caller), or NULL
6061 - * - Absolute : $VIM/syntax/help.vim
6062 - * - Relative : Adfs::4.$.!Vim.Resources.Syntax/help.vim
6065 - mch_munge_fname(fname)
6072 - retval = fname = vim_strsave(fname);
6073 - if (fname == NULL)
6076 - if (strncmp(fname, "$VIM/", 5) == 0)
6078 - strncpy(fname, "Vim:", 4);
6079 - for (fname += 5; c = *fname; fname++)
6092 - /* Check to see if the file exists without modification. */
6093 - if (xswi(OS_File, 17, fname) & v_flag)
6094 - r0 == 0; /* Invalid filename? */
6098 - len = strlen(fname);
6099 - if (strcmp(fname + len - 4, ".vim") == 0)
6101 - fname[len - 4] = '\0';
6102 - for (; c = *fname; fname++)
6112 - /* QuickFix reads munged names from the error file.
6116 - ro_buflist_add(old_name)
6117 - char_u *old_name; /* Name of file found by quickfix */
6120 - char_u *leaf; /* Pointer to start of leaf in old_name */
6125 - if (old_name == NULL)
6126 - return buflist_add(NULL, 0);
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);
6134 - /* Change `dir/main.c' into `dir.c.main' */
6136 - for (ptr = fname; c = *ptr; ptr++)
6143 - else if (c == '.')
6148 - /* Change `main.c' into `c.main'
6152 - ptr += old_name - fname;
6157 - leaf - fname + old_name);
6160 - retval = buflist_add(fname, 0);
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.
6177 - if (p_verbose >= 5)
6180 - smsg((char_u *)"chdir(%s)", dir);
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. */
6190 - while (new_dir[--length] == '.')
6191 - new_dir[length] = '\0';
6193 - retval = chdir(new_dir);
6194 - vim_free(new_dir);
6198 - /* Examine the named file, and set the 'osfiletype' option
6199 - * (in curbuf) to the file's type.
6202 - mch_read_filetype(file)
6206 - char_u type_string[9];
6209 - if (xswi(OS_File, 23, file) & v_flag)
6210 - type = 0xfff; /* Default to Text */
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++)
6221 - type_string[i] = 0;
6223 - set_string_option_direct("osfiletype", -1, type_string, OPT_FREE, 0);
6228 - mch_set_filetype(file, type)
6232 - if (xswi(OS_FSControl, 31, type) & v_flag)
6234 - EMSG(_("E366: Invalid 'osfiletype' option - using Text"));
6238 - swi(OS_File, 18, file, r2);
6241 - /* Return TRUE if the file's type matches 'type'
6242 - * RISC OS types always start with '&'
6245 - mch_check_filetype(fname, type)
6255 - value = strtol(type + 1, &end, 16);
6257 - return FALSE; /* Invalid type (report error?) */
6259 - if (xswi(OS_File, 23, fname) & v_flag)
6260 - return FALSE; /* Invalid filename? */
6262 - return (r0 && r6 == value);
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
6269 ! *os_risc.txt* For Vim version 7.3. Last change: 2010 Aug 07
6272 VIM REFERENCE MANUAL by Thomas Leonard
6275 *riscos* *RISCOS* *RISC-OS*
6276 ! This file contains the particularities for the RISC OS version of Vim.
6278 - The RISC OS port is a completely new port and is not based on the old "archi"
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|
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
6297 - Thomas Leonard <tal197@ecs.soton.ac.uk>
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/
6303 - ==============================================================================
6304 - *riscos-locations*
6307 - The Vim executable and shared resource files are all stored inside the !Vim
6308 - application directory.
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|).
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.
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
6324 - ==============================================================================
6326 - 2. Filename munging
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".
6332 - The only times munging is done is when:
6334 - - Searching included files from C programs, since these are always munged.
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").
6339 - - Sourcing files using |:so|.
6340 - Paths starting "$VIM/" are munged like this:
6342 - $VIM/syntax/help.vim -> Vim:syntax.help
6344 - Also, files ending in ".vim" have their extensions removed, and slashes
6345 - replaced with dots.
6347 - Some tag files and script files may have to be edited to work under this port.
6349 - ==============================================================================
6350 - *riscos-commandline*
6351 - 3. Command-line use
6353 - To use Vim from the command-line use the "*vi" command (or "*ex" for
6356 - Type "*vi -h" for a list of options.
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.
6362 - Also, holding down Ctrl will slow it down even more, and Ctrl-Shift will
6363 - freeze it, as usual for text programs.
6365 - ==============================================================================
6371 - - Left scrollbars don't work properly (right and bottom are fine).
6372 - - Doesn't increase scroll speed if it gets behind.
6374 - You can resize the window by dragging the lower-right corner, even though
6375 - there is no icon shown there.
6377 - You can use the --rows and --columns arguments to specify the initial size of
6378 - the Vim window, like this: >
6380 - *Vi -g --rows 20 --columns 80
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
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).
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.
6392 - Dragging with Ctrl held down causes a new Vim window to be opened for the
6395 - Dragging a file in with Shift held down in insert mode inserts the pathname of
6398 - :browse :w opens a standard RISC OS save box.
6399 - :browse :e opens a directory viewer.
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: >
6405 - < To use the system font via the VDU drivers. Supports
6406 - bold and underline.
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.
6412 - :set guifont=Corpus.Medium:w8:h12:b:i
6413 - < As before, but with size of 8 point by 12 point, and
6415 - If only one of width and height is given then that
6416 - value is used for both. If neither is given then 10
6419 - Thanks to John Kortink, Vim can use the ZapRedraw module. Start the font name
6420 - with "!" (or "!!" for double height), like this: >
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.
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.
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.
6443 - If you find the scrolling is too slow on your machine, try experimenting
6444 - with the 'scrolljump' and 'ttyscroll' options.
6446 - In particular, StrongARM users may find that: >
6450 - makes scrolling faster in high-color modes.
6452 - =============================================================================
6454 - 5. Remote use (telnet)
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.
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.
6462 - It seems to work pretty well now, using "*vi -T ansi".
6464 - ==============================================================================
6465 - *riscos-temp-files*
6466 - 6. Temporary files
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.
6474 - To see a list of swap files, press <F12> and type "*vi -r".
6476 - Vim no longer brings up ATTENTION warnings if you try to edit two files with
6477 - the same name in different directories.
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.
6483 - ==============================================================================
6484 - *riscos-interrupt*
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.
6490 - ==============================================================================
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.
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
6503 - ==============================================================================
6504 - *riscos-filetypes*
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.
6510 - Filetypes must be specified by number (e.g. &fff for Text).
6512 - The system has changed from version 5.3. The new sequence of events is:
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'|.
6520 - Some examples may make this clearer:
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)
6527 - ==============================================================================
6531 - - Bangs (!s) are only replaced if they are followed by a space or end-of-line,
6532 - since many pathnames contain them.
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}
6538 - ==============================================================================
6540 - 11. Porting new releases to RISC OS
6542 - Downloading everything you need:
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)
6551 - - Create a raFS disk and put the archives on it
6553 - - Un-tar them (*tar xELf 50 archive/tar)
6556 - Recompiling the sources:
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
6565 - raFS::VimSrc.source.h.file_pro
6566 - - In the files "h.proto" and "c.termlib", search and replace
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.
6575 - Updating the run-time environment:
6577 - - Replace old or missing files inside !Vim.Resources with the
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]*//
6590 vim:tw=78:ts=8:ft=help:norl:
6592 ! *os_risc.txt* For Vim version 7.3. Last change: 2011 May 10
6595 VIM REFERENCE MANUAL by Thomas Leonard
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.
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
6609 { /* Add new patch number below this line */
6615 hundred-and-one symptoms of being an internet addict:
6616 81. At social functions you introduce your husband as "my domain server."
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 ///