home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 7.3 / 7.3.187 < prev    next >
Encoding:
Internet Message Format  |  2012-11-20  |  169.8 KB

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