To: [email protected]
Subject: Patch 6.3a.020 (extra)
Fcc: outbox
From: Bram Moolenaar <[email protected]>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
------------

Patch 6.3a.020 (extra)
Problem:    Missing support for AROS (AmigaOS reimplementation).  Amiga GUI
           doesn't work.
Solution:   Add AROS support.  (Adam Chodorowski)
           Fix Amiga GUI problems. (Georg Steger, Ali Akcaagac)
Files:      Makefile, src/Make_aros.mak, src/gui_amiga.c, src/gui_amiga.h,
           src/memfile.c, src/os_amiga.c, src/term.c


*** ../vim-6.3a.019/Makefile    Fri May  7 10:59:42 2004
--- Makefile    Thu May 13 15:05:21 2004
***************
*** 494,501 ****
--- 494,503 ----
               src.info \
               src/INSTALLami.txt \
               src/Make_agui.mak \
+               src/Make_aros.mak \
               src/Make_dice.mak \
               src/Make_manx.mak \
+               src/Make_morph.mak \
               src/Make_sas.mak \
               src/gui_amiga.c \
               src/gui_amiga.h \
***************
*** 563,569 ****
               $(SRC_VMS) \
               README_os390.txt \
               src/Make_mint.mak \
-               src/Make_morph.mak \
               src/Make_ro.mak \
               src/gui_beos.cc \
               src/gui_beos.h \
--- 565,570 ----
*** ../vim-6.3a.019/src/Make_aros.mak   Thu May 13 15:12:14 2004
--- src/Make_aros.mak   Thu May 13 15:00:27 2004
***************
*** 0 ****
--- 1,29 ----
+ # Makefile for AROS
+
+ CFLAGS = -pipe -O2 -Wall -Iproto \
+          -DNO_ARP -DUSE_TMPNAM -DFEAT_GUI_AMIGA
+
+ PRG    = VIM
+ LIBS   =
+ CC     = i386-linux-aros-gcc
+ LD     = i386-linux-aros-gcc
+ RM     = rm
+
+ SRCS   = buffer.c charset.c diff.c digraph.c edit.c eval.c ex_cmds.c          \
+          ex_cmds2.c ex_docmd.c ex_eval.c ex_getln.c fileio.c fold.c getchar.c \
+          main.c mark.c mbyte.c memfile.c memline.c menu.c message.c misc1.c   \
+          misc2.c move.c normal.c ops.c option.c os_amiga.c quickfix.c         \
+          regexp.c screen.c search.c syntax.c tag.c term.c ui.c undo.c         \
+          version.c window.c gui_amiga.c gui.c
+
+ OBJS   = $(SRCS:.c=.o)
+
+
+ $(PRG): $(OBJS)
+       ${LD} -o $(PRG) $(OBJS) $(LIBS)
+
+ .c.o:
+       ${CC} -c ${CFLAGS} $< -o $@
+
+ clean:
+       $(RM) -fv $(OBJS) $(PRG)
*** ../vim-6.3a.019/src/gui_amiga.c     Fri May  7 10:59:37 2004
--- src/gui_amiga.c     Thu May 13 15:04:21 2004
***************
*** 19,57 ****
 #include <proto/intuition.h>
 #include <proto/graphics.h>
 #include <proto/layers.h>
 #include <assert.h>
 #include "vim.h"
 #include "gui_amiga.h"
 #include <math.h>
 #include <limits.h>

 #include "version.h"

 #if defined(FEAT_GUI_AMIGA) || defined(PROTO)

! #define KEYUP 76
! #define KEYDOWN 77
! #define KEYRIGHT 78
! #define KEYLEFT 79

 /* When generating prototypes on Unix, these need to be defined */
 #ifdef PROTO
 # define STRPTR char *
 #endif

! static struct PropInfo Gadget2SInfo = { AUTOKNOB+PROPBORDERLESS, (unsigned short)-1, (unsigned short)-1, 6553, 6553, };
! static struct Image Image1 = { 0, 0, 10, 397, 0, NULL, 0x0000, 0x0000, NULL };
 static struct Gadget propGadget = { NULL, -12, 15, 10, -28,
       GFLG_RELRIGHT+GFLG_RELHEIGHT,
       GACT_RELVERIFY+GACT_RIGHTBORDER+GACT_IMMEDIATE,
       GTYP_PROPGADGET+GTYP_GZZGADGET,
!       (APTR)&Image1, NULL,
       NULL, NULL, (APTR)&Gadget2SInfo, NULL, NULL };

 struct GFXBase                *gfxBase;
 struct ExecBase               *execBase;
 struct LayersBase     *layersBase;

 struct TagItem tags[] =
 {
     {WA_Left, 0},
--- 19,81 ----
 #include <proto/intuition.h>
 #include <proto/graphics.h>
 #include <proto/layers.h>
+ #include <devices/timer.h>
 #include <assert.h>
 #include "vim.h"
 #include "gui_amiga.h"
 #include <math.h>
 #include <limits.h>

+ #ifdef __AROS__
+ #include <aros/debug.h>
+ #endif
+
 #include "version.h"

 #if defined(FEAT_GUI_AMIGA) || defined(PROTO)

! #define KEYUP                 76
! #define KEYDOWN       77
! #define KEYRIGHT      78
! #define KEYLEFT       79
! #define KEYBACKSPACE  0x41
! #define KEYDELETE     0x46
! #define KEYINSERT     0x47
! #define KEYHOME       0x70
! #define KEYEND                0x71
! #define KEYWHEELUP    0x7A
! #define KEYWHEELDOWN  0x7B

 /* When generating prototypes on Unix, these need to be defined */
 #ifdef PROTO
 # define STRPTR char *
 #endif

! static struct PropInfo Gadget2SInfo = { AUTOKNOB+PROPBORDERLESS+FREEVERT+PROPNEWLOOK, 0, 0, MAXBODY, MAXBODY, };
! //static struct Image Image1 = { 0, 0, 10, 397,       0, NULL, 0x0000, 0x0000, NULL };
 static struct Gadget propGadget = { NULL, -12, 15, 10, -28,
       GFLG_RELRIGHT+GFLG_RELHEIGHT,
       GACT_RELVERIFY+GACT_RIGHTBORDER+GACT_IMMEDIATE,
       GTYP_PROPGADGET+GTYP_GZZGADGET,
!       NULL, NULL,
       NULL, NULL, (APTR)&Gadget2SInfo, NULL, NULL };

+ static struct timerequest *TimerIO;
+ static struct MsgPort   *TimerMP;
+ static BOOL              TimerSent;
+
 struct GFXBase                *gfxBase;
 struct ExecBase               *execBase;
 struct LayersBase     *layersBase;

+ struct MyColor
+ {
+     WORD pen;
+     BOOL alloced;
+ };
+
+ struct MyColor MyColorTable[256];
+
 struct TagItem tags[] =
 {
     {WA_Left, 0},
***************
*** 103,112 ****
--- 127,138 ----
 /*#define D(_msg) fprintf(stderr, "%s\n", _msg)*/

 #define D(_A)
+ #define kprintf(s, ...)

 static void AmigaError(const char *string);

 void HandleEvent(unsigned long * object);
+ static UBYTE getrealcolor(guicolor_T i);

 static struct NewWindow vimNewWindow =
 {
***************
*** 200,218 ****
     static int
 posHeightCharToPoint(int height)
 {
!     return (int)(height+1)*characterHeight;
 }

     static int
 posWidthPointToChar(int width)
 {
!     return (int)floor((float)width/(float)characterWidth)-1;
 }

     static int
 posHeightPointToChar(int height)
 {
!     return (int)floor((float)height/(float)characterHeight)-2;
 }

     static int
--- 226,246 ----
     static int
 posHeightCharToPoint(int height)
 {
!     return (int)(height)*characterHeight;
 }

     static int
 posWidthPointToChar(int width)
 {
!     //return (int)floor((float)width/(float)characterWidth)-1;
!     return width /characterWidth;
 }

     static int
 posHeightPointToChar(int height)
 {
!     //return (int)floor((float)height/(float)characterHeight)-2;
!     return height / characterHeight;
 }

     static int
***************
*** 230,242 ****
     static int
 widthPointToChar(int width)
 {
!     return width/characterWidth+13;
 }

     static int
 heightPointToChar(int height)
 {
!     return height/characterHeight - 3;
 }

     static void
--- 258,270 ----
     static int
 widthPointToChar(int width)
 {
!     return (width)/characterWidth;
 }

     static int
 heightPointToChar(int height)
 {
!     return (height)/characterHeight;
 }

     static void
***************
*** 247,273 ****
 }

     static void
! drawBox(enum DrawBoxMode mode, unsigned short col, unsigned short row, guicolor_T color)
! {
!     /*
!        SetDrMd(gui.window->RPort, COMPLEMENT);
!        SetAPen(gui.window->RPort, -1);
!        SetBPen(gui.window->RPort, -1);
!        Move(gui.window->RPort, posWidthCharToPoint(col), posHeightCharToPoint(row));
!        Text(gui.window->RPort, " ", 1);
!        SetDrMd(gui.window->RPort, JAM2);
!      */
 }

     static enum event
 EventHandler(void)
 {
     struct IntuiMessage *msg;
!     enum event                returnEvent;
     int                       class, code;
     static int                dragging = 0;
     static int                mouseX, mouseY;
     char_u            string[40];

     msg = (struct IntuiMessage *)GetMsg(gui.window->UserPort);

--- 275,323 ----
 }

     static void
! drawBox(enum DrawBoxMode mode, unsigned short col, unsigned short row, int w, int h, guicolor_T color)
! {
!     LONG apen = GetAPen(gui.window->RPort);
!     LONG x1, y1, x2, y2;
!
! kprintf(" drawbox %d,%d color %d\n", col, row, color);
!
!     SetAPen(gui.window->RPort, getrealcolor(color));
!
!     x1 = posWidthCharToPoint(col);
!     y1 = posHeightCharToPoint(row + 1) - h;
!     x2 = x1 + w - 1;
!     y2 = posHeightCharToPoint(row + 1) - 1;
!
!     switch(mode)
!     {
!       case DB_Filled:
!           RectFill(gui.window->RPort, x1, y1, x2, y2);
!           break;
!
!       case DB_NotFilled:
!           Move(gui.window->RPort, x1, y1);
!           Draw(gui.window->RPort, x2, y1);
!           Draw(gui.window->RPort, x2, y2);
!           Draw(gui.window->RPort, x1, y2);
!           Draw(gui.window->RPort, x1, y1);
!           break;
!     }
!
!     SetAPen(gui.window->RPort, apen);
!
 }

     static enum event
 EventHandler(void)
 {
     struct IntuiMessage *msg;
!     enum event                returnEvent = ev_Ignore;
     int                       class, code;
     static int                dragging = 0;
     static int                mouseX, mouseY;
     char_u            string[40];
+     BOOL              quit_request = FALSE;

     msg = (struct IntuiMessage *)GetMsg(gui.window->UserPort);

***************
*** 323,338 ****
                  }
                  returnEvent = ev_IntuiTicks;
                  */
!                      break;
           case IDCMP_MOUSEBUTTONS:
                  {
                      int vim_modifiers=0;
                      D("Mouse button event detected");
                      switch (msg->Qualifier )
                      {
                          case IEQUALIFIER_LSHIFT:
                          case IEQUALIFIER_RSHIFT:
!                              D("detected a shift key");
                              vim_modifiers|=MOUSE_SHIFT;
                              break;
                          case IEQUALIFIER_CONTROL:
--- 373,395 ----
                  }
                  returnEvent = ev_IntuiTicks;
                  */
!                  break;
!
           case IDCMP_MOUSEBUTTONS:
                  {
                      int vim_modifiers=0;
                      D("Mouse button event detected");
                      switch (msg->Qualifier )
                      {
+                          case IEQUALIFIER_LALT:
+                          case IEQUALIFIER_RALT:
+                              D("detected a Alt key");
+                              vim_modifiers|=MOUSE_ALT;
+                              break;
+
                          case IEQUALIFIER_LSHIFT:
                          case IEQUALIFIER_RSHIFT:
!                              D("detected a Shift key");
                              vim_modifiers|=MOUSE_SHIFT;
                              break;
                          case IEQUALIFIER_CONTROL:
***************
*** 345,352 ****
                          D("Select Down detected\n");
                          dragging = 1;
                          gui_send_mouse_event(MOUSE_LEFT,
!                                  posWidthPointToChar(mouseX = msg->MouseX),
!                                  posHeightPointToChar(mouseY = msg->MouseY),
                                  FALSE,
                                  vim_modifiers);
                          /*gui_start_highlight(HL_ALL);*/
--- 402,409 ----
                          D("Select Down detected\n");
                          dragging = 1;
                          gui_send_mouse_event(MOUSE_LEFT,
!                                  mouseX = msg->MouseX - gui.window->BorderLeft,
!                                  mouseY = msg->MouseY - gui.window->BorderTop,
                                  FALSE,
                                  vim_modifiers);
                          /*gui_start_highlight(HL_ALL);*/
***************
*** 356,363 ****
                          D("Select UP detected\n");
                          dragging = 0;
                          gui_send_mouse_event(MOUSE_RELEASE,
!                                  posWidthPointToChar(msg->MouseX),
!                                  posHeightPointToChar(msg->MouseY),
                                  FALSE, vim_modifiers);
                          /*gui_stop_highlight(mask);*/
                      }
--- 413,420 ----
                          D("Select UP detected\n");
                          dragging = 0;
                          gui_send_mouse_event(MOUSE_RELEASE,
!                                  msg->MouseX - gui.window->BorderLeft,
!                                  msg->MouseY - gui.window->BorderTop,
                                  FALSE, vim_modifiers);
                          /*gui_stop_highlight(mask);*/
                      }
***************
*** 365,388 ****
                      break;
                  }
           case IDCMP_MOUSEMOVE:
!                  if ((abs(mouseX-msg->MouseX) > characterWidth) || (abs(mouseY-msg->MouseY)>characterHeight))
                  {
!                      mouseX = msg->MouseX;
!                      mouseY = msg->MouseY;
                      if (!dragging)
                      {
!                          gui_send_mouse_event(MOUSE_SETPOS, posWidthPointToChar(msg->MouseX), posHeightPointToChar(msg->MouseY), FALSE, 0);
                          break;
                      }
                      else
                      {
                          D("dragging\n");
!                          gui_send_mouse_event(MOUSE_DRAG, posWidthPointToChar(msg->MouseX), posHeightPointToChar(msg->MouseY), FALSE, 0);
                      }
                  }
                  returnEvent = ev_MouseMove;
                  break;
           case IDCMP_VANILLAKEY:
                  {
                      string[0] = (char_u)code;
                      if (code == CSI)
--- 422,468 ----
                      break;
                  }
           case IDCMP_MOUSEMOVE:
!                  if ((abs(mouseX-(msg->MouseX - gui.window->BorderLeft)) > characterWidth) ||
!                      (abs(mouseY-(msg->MouseY - gui.window->BorderTop))>characterHeight))
                  {
!                      int vim_modifiers=0;
!
!                      switch (msg->Qualifier )
!                      {
!                          case IEQUALIFIER_LALT:
!                          case IEQUALIFIER_RALT:
!                              D("detected a Alt key");
!                              vim_modifiers|=MOUSE_ALT;
!                              break;
!
!                          case IEQUALIFIER_LSHIFT:
!                          case IEQUALIFIER_RSHIFT:
!                              D("detected a Shift key");
!                              vim_modifiers|=MOUSE_SHIFT;
!                              break;
!                          case IEQUALIFIER_CONTROL:
!                              D("detected a Control key");
!                              vim_modifiers |= MOUSE_CTRL;
!                              break;
!                      }
!
!                      mouseX = msg->MouseX - gui.window->BorderLeft;
!                      mouseY = msg->MouseY - gui.window->BorderTop;
                      if (!dragging)
                      {
!                          gui_send_mouse_event(MOUSE_SETPOS, mouseX, mouseY, FALSE, vim_modifiers);
                          break;
                      }
                      else
                      {
                          D("dragging\n");
!                          gui_send_mouse_event(MOUSE_DRAG, mouseX, mouseY, FALSE, vim_modifiers);
                      }
                  }
                  returnEvent = ev_MouseMove;
                  break;
           case IDCMP_VANILLAKEY:
+ kprintf("===vanillakey %d\n", code);
                  {
                      string[0] = (char_u)code;
                      if (code == CSI)
***************
*** 392,397 ****
--- 472,491 ----
                          string[2] = (int)KE_CSI;
                          add_to_input_buf(string, 3);
                      }
+                      else if (code == 8)
+                      {
+                           string[0] = CSI;
+                           string[1] = 'k';
+                           string[2] = 'b';
+                           add_to_input_buf(string, 3);
+                      }
+                      else if (code == 127)
+                      {
+                           string[0] = CSI;
+                           string[1] = 'k';
+                           string[2] = 'D';
+                           add_to_input_buf(string, 3);
+                      }
                      else
                      {
                          int  len = 1;
***************
*** 402,408 ****
                      }
                      returnEvent = ev_KeyStroke;
                      break;
!                      case IDCMP_RAWKEY:
                      if (msg->Qualifier & IEQUALIFIER_LSHIFT)
                      {
                      }
--- 496,503 ----
                      }
                      returnEvent = ev_KeyStroke;
                      break;
!
!               case IDCMP_RAWKEY:
                      if (msg->Qualifier & IEQUALIFIER_LSHIFT)
                      {
                      }
***************
*** 428,449 ****
                          string[0] = CSI;
                          string[1] = 'k';
                          string[2] = 'l';
!                          add_to_input_buf(string, 1);
                      }
                      else if (msg->Code == KEYRIGHT)
                      {
                          string[0] = CSI;
                          string[1] = 'k';
                          string[2] = 'r';
!                          add_to_input_buf(string, 1);
                      }
                      else if (msg->Code == KEYDOWN)
                      {
                          string[0] = CSI;
                          string[1] = 'k';
                          string[2] = 'd';
!                          add_to_input_buf(string, 1);
                      }
                      returnEvent = ev_KeyStroke;
                      break;
                  }
--- 523,630 ----
                          string[0] = CSI;
                          string[1] = 'k';
                          string[2] = 'l';
!                          add_to_input_buf(string, 3);
                      }
                      else if (msg->Code == KEYRIGHT)
                      {
+ kprintf("## keyright");
                          string[0] = CSI;
                          string[1] = 'k';
                          string[2] = 'r';
!                          add_to_input_buf(string, 3);
                      }
                      else if (msg->Code == KEYDOWN)
                      {
                          string[0] = CSI;
                          string[1] = 'k';
                          string[2] = 'd';
!                          add_to_input_buf(string, 3);
                      }
+                      else if (msg->Code == KEYBACKSPACE)
+                      {
+                          string[0] = CSI;
+                          string[1] = 'k';
+                          string[2] = 'b';
+                          add_to_input_buf(string, 3);
+                      }
+                      else if (msg->Code == KEYDELETE)
+                      {
+                          string[0] = CSI;
+                          string[1] = 'k';
+                          string[2] = 'D';
+                          add_to_input_buf(string, 3);
+                      }
+                      else if (msg->Code == KEYINSERT)
+                      {
+                          string[0] = CSI;
+                          string[1] = 'k';
+                          string[2] = 'I';
+                          add_to_input_buf(string, 3);
+                      }
+                      else if (msg->Code == KEYHOME)
+                      {
+                          string[0] = CSI;
+                          string[1] = 'k';
+                          string[2] = 'h';
+                          add_to_input_buf(string, 3);
+                      }
+                      else if (msg->Code == KEYEND)
+                      {
+                          string[0] = CSI;
+                          string[1] = '@';
+                          string[2] = '7';
+                          add_to_input_buf(string, 3);
+                      }
+                      else if (msg->Code == KEYWHEELUP)
+                      {
+                          int vim_modifiers=0;
+
+                          switch (msg->Qualifier )
+                          {
+                              case IEQUALIFIER_LALT:
+                              case IEQUALIFIER_RALT:
+                                  D("detected a Alt key");
+                                  vim_modifiers|=MOUSE_ALT;
+                                  break;
+
+                              case IEQUALIFIER_LSHIFT:
+                              case IEQUALIFIER_RSHIFT:
+                                  D("detected a Shift key");
+                                  vim_modifiers|=MOUSE_SHIFT;
+                                  break;
+                              case IEQUALIFIER_CONTROL:
+                                  D("detected a Control key");
+                                  vim_modifiers |= MOUSE_CTRL;
+                                  break;
+                          }
+                          gui_send_mouse_event(MOUSE_4, 0, 1, FALSE, vim_modifiers);
+
+                      }
+                      else if (msg->Code == KEYWHEELDOWN)
+                      {
+                          int vim_modifiers=0;
+
+                          switch (msg->Qualifier )
+                          {
+                              case IEQUALIFIER_LALT:
+                              case IEQUALIFIER_RALT:
+                                  D("detected a Alt key");
+                                  vim_modifiers|=MOUSE_ALT;
+                                  break;
+
+                              case IEQUALIFIER_LSHIFT:
+                              case IEQUALIFIER_RSHIFT:
+                                  D("detected a Shift key");
+                                  vim_modifiers|=MOUSE_SHIFT;
+                                  break;
+                              case IEQUALIFIER_CONTROL:
+                                  D("detected a Control key");
+                                  vim_modifiers |= MOUSE_CTRL;
+                                  break;
+                          }
+                          gui_send_mouse_event(MOUSE_5, 0, 1, FALSE, vim_modifiers);
+                      }
+
                      returnEvent = ev_KeyStroke;
                      break;
                  }
***************
*** 491,506 ****
                  }
                  break;
           case IDCMP_CLOSEWINDOW:
!                  {
!                      gui_mch_exit(1);
!                      break;
!                  }
           case IDCMP_NEWSIZE:
                  {
                      int cx, cy;
!                      cx = widthPointToChar(gui.window->Width);
!                      cy = heightPointToChar(gui.window->Height);

                      gui_resize_shell(cx, cy);

                      returnEvent = ev_NewSize;
--- 672,689 ----
                  }
                  break;
           case IDCMP_CLOSEWINDOW:
!                   quit_request = TRUE;
!                   break;
!
           case IDCMP_NEWSIZE:
                  {
                      int cx, cy;
!                      //cx = widthPointToChar(gui.window->GZZWidth);
!                      //cy = heightPointToChar(gui.window->GZZHeight);

+                      cx = gui.window->GZZWidth;
+                      cy = gui.window->GZZHeight - characterHeight;
+
                      gui_resize_shell(cx, cy);

                      returnEvent = ev_NewSize;
***************
*** 524,529 ****
--- 707,715 ----
                  break;
           case IDCMP_INACTIVEWINDOW:
                  gui.in_focus = FALSE;
+                  gui_update_cursor(TRUE, FALSE);
+                  break;
+
           case IDCMP_ACTIVEWINDOW:
                  gui.in_focus = TRUE;
                  gui_update_cursor(TRUE, FALSE);
***************
*** 534,539 ****
--- 720,730 ----
       ReplyMsg((struct Message*)msg);
     }

+     if (quit_request)
+     {
+       getout(0); // gui_mch_exit(1);
+     }
+
     return returnEvent;
     /* mouse positin gui.window->MoseY, gui.window->MouseX) */
 }
***************
*** 756,761 ****
--- 947,953 ----
     void
 atexitDoThis(void)
 {
+ kprintf("atexitdothis###\n");
     gui_mch_exit(-1);
 }

***************
*** 776,792 ****
--- 968,1004 ----
 {
     int returnCode = FAIL; /* assume failure*/

+     TimerMP = CreateMsgPort();
+     if (!TimerMP) return FAIL;
+
+     TimerIO = (struct timerequest *)CreateIORequest(TimerMP, sizeof(*TimerIO));
+     if (!TimerIO) return FAIL;
+
+     if (OpenDevice("timer.device", UNIT_VBLANK, &TimerIO->tr_node, 0)) return FAIL;
+
     gui.window = OpenWindowTagList(&vimNewWindow, tags);
     if (gui.window)
     {
       gui.in_use = TRUE;
       gui.in_focus=TRUE;
+       gui.norm_pixel = gui.def_norm_pixel = 1;
+       gui.back_pixel = gui.def_back_pixel = 0;
+
+       set_normal_colors();
+       gui_check_colors();
+
       SetDrMd(gui.window->RPort, JAM2);
+       gui_mch_set_colors(gui.norm_pixel, gui.back_pixel);
+
       atexit(atexitDoThis);
+
       TextDimensions();
       returnCode = OK; /* we've had success */
       if (gui_win_x != -1 && gui_win_y != -1)
           gui_mch_set_winpos(gui_win_x, gui_win_y);
+
+       gui_mch_clear_all();
+
     }
     gui.menu = NULL;

***************
*** 796,801 ****
--- 1008,1017 ----
     void
 gui_mch_new_colors(void)
 {
+ kprintf("### gui_mch_new_colors\n");
+     SetAPen(gui.window->RPort, getrealcolor(gui.norm_pixel));
+     SetBPen(gui.window->RPort, getrealcolor(gui.back_pixel));
+
     D("gui_mch_new_colors");
 }

***************
*** 804,825 ****
 {
     D("gui_mch_open");

     return OK;
 }

     void
 gui_mch_exit(int returnCode)
 {
     D("****gui_mch_exit");
     if (gui.window)
     {
       D("Closeing window ");
       CloseWindow(gui.window);
       CloseLibrary((struct Library*)execBase);
       CloseLibrary((struct Library*)gfxBase);
       gui.window = NULL;
       gui.in_use = FALSE;
!       getout(1);
     }
 }

--- 1020,1075 ----
 {
     D("gui_mch_open");

+     highlight_gui_started();
     return OK;
 }

     void
 gui_mch_exit(int returnCode)
 {
+ kprintf("###gui_mch_exit\n");
     D("****gui_mch_exit");
+
+     if (TimerSent)
+     {
+       if (!CheckIO(&TimerIO->tr_node)) AbortIO(&TimerIO->tr_node);
+       WaitIO(&TimerIO->tr_node);
+       TimerSent = FALSE;
+     }
+
+     if (TimerIO)
+     {
+       CloseDevice(&TimerIO->tr_node);
+       DeleteIORequest(&TimerIO->tr_node);
+       TimerIO = NULL;
+     }
+
+     if (TimerMP)
+     {
+       DeleteMsgPort(TimerMP);
+       TimerMP = NULL;
+     }
+
     if (gui.window)
     {
+       int i;
+
+       for(i = 0; i < sizeof(MyColorTable) / sizeof(MyColorTable[0]); i++)
+       {
+           if (MyColorTable[i].alloced)
+           {
+               ReleasePen(gui.window->WScreen->ViewPort.ColorMap, MyColorTable[i].pen);
+               MyColorTable[i].alloced = FALSE;
+           }
+       }
+
       D("Closeing window ");
       CloseWindow(gui.window);
       CloseLibrary((struct Library*)execBase);
       CloseLibrary((struct Library*)gfxBase);
       gui.window = NULL;
       gui.in_use = FALSE;
!       //getout(1);
     }
 }

***************
*** 829,836 ****
     int
 gui_mch_get_winpos(int *x, int *y)
 {
!     /* TODO */
!     return FAIL;
 }

 /*
--- 1079,1095 ----
     int
 gui_mch_get_winpos(int *x, int *y)
 {
!     if (gui.window)
!     {
!       *x = gui.window->LeftEdge;
!       *y = gui.window->TopEdge;
!     }
!     else
!     {
!       return FAIL;
!     }
!
!     return OK;
 }

 /*
***************
*** 840,846 ****
     void
 gui_mch_set_winpos(int x, int y)
 {
!     /* TODO */
 }

     void
--- 1099,1108 ----
     void
 gui_mch_set_winpos(int x, int y)
 {
!     if (gui.window)
!     {
!       ChangeWindowBox(gui.window, x, y, gui.window->Width, gui.window->Height);
!     }
 }

     void
***************
*** 849,865 ****
 {
     D("gui_mch_set_shellsize");

!     ChangeWindowBox(gui.window, gui.window->TopEdge,
!           gui.window->LeftEdge, widthCharToPoint(width),
!           heightCharToPoint(height));
     checkEventHandler();
 }

     void
 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
 {
!     *screen_w = widthPointToChar(gui.window->Width);
!     *screen_h = heightPointToChar(gui.window->Height);
 }

     void
--- 1111,1139 ----
 {
     D("gui_mch_set_shellsize");

!     ChangeWindowBox(gui.window, gui.window->LeftEdge,
!           gui.window->TopEdge, widthCharToPoint(width) + gui.window->BorderLeft + gui.window->BorderRight,
!           heightCharToPoint(height) + gui.window->BorderTop + gui.window->BorderBottom);
     checkEventHandler();
 }

     void
 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
 {
! //    *screen_w = widthPointToChar(gui.window->GZZWidth);
! //    *screen_h = heightPointToChar(gui.window->GZZHeight);
!     *screen_w = gui.window->GZZWidth;
!     *screen_h = gui.window->GZZHeight - characterHeight;
!
!
! kprintf("=== get_screen_dimensions: screen %d,%d character %d,%d  console %d,%d\n",
! gui.window->GZZWidth,
! gui.window->GZZHeight,
! characterWidth,
! characterHeight,
! *screen_w,
! *screen_h);
!
 }

     void
***************
*** 878,883 ****
--- 1152,1189 ----
     void
 gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max)
 {
+     ULONG total = max;
+     ULONG visible = size;
+     ULONG top = val;
+     ULONG hidden;
+     ULONG overlap = 0;
+     UWORD body, pot;
+
+ kprintf("__set_scrollbar_thumb val %d  size %d  max %d\n", val, size, max);
+
+     if (total > visible)
+         hidden = total - visible;
+     else
+         hidden = 0;
+
+     if (top > hidden)
+         top = hidden;
+
+     body = (hidden > 0) ?
+             (UWORD)(((ULONG)(visible - overlap) * MAXBODY) / (total - overlap)) :
+             MAXBODY;
+
+     pot  = (hidden > 0) ? (UWORD)(((ULONG) top * MAXPOT) / hidden) : 0;
+
+ kprintf("__pot %x  body %x\n", pot, body);
+
+     NewModifyProp(&propGadget, gui.window, NULL,
+                 Gadget2SInfo.Flags,
+                 MAXPOT, pot,
+                 MAXBODY, body,
+                 1);
+     return;
+
 }

     void
***************
*** 904,909 ****
--- 1210,1220 ----
 int gui_mch_init_font(char_u *font_name, int fontset)
 {
     /*D("gui_mch_init_font");*/
+
+     gui.char_width = characterWidth;
+     gui.char_height = characterHeight;
+     gui.char_ascent = gui.window->RPort->TxBaseline;
+
     return OK;
 }

***************
*** 947,999 ****
  * Get color handle for color "name".
  * Return INVALCOLOR when not possible.
  */
!     guicolor_T
! gui_mch_get_color(char_u *name)
! {
     typedef struct guicolor_tTable
     {
       char        *name;
       unsigned long    color;
     } guicolor_tTable;

     static guicolor_tTable table[] =
     {
!       {"Grey",        0},
!       {"Black",       1},
!       {"DarkBlue",    2},
!       {"DarkGreen",   3},
!       {"DarkCyan",    4},
!       {"DarkRed",     5},
!       {"DarkMagenta", 6},
!       {"Brown",       7},
!       {"Gray",        8},
!       {"Grey",        9},
!       {"LightGray",   10},
!       {"LightGrey",   11},
!       {"DarkGray",    12},
!       {"DarkGrey",    13},
!       {"Blue",        14},
!       {"LightBlue",   15},
!       {"Green",       16},
!       {"LightGreen",  17},
!       {"Cyan",        18},
!       {"LightCyan",   19},
!       {"Red",         20},
!       {"LightRed",    21},
!       {"Magenta",     22},
!       {"LightMagenta",23},
!       {"Yellow",      24},
!       {"LightYellow", 25},    /* TODO: add DarkYellow */
!       {"White",       26},
!       {"SeaGreen",    27},
!       {"Orange",      28},
!       {"Purple",      30},
!       {"SlateBlue",   31},
!       {"grey90",      32},
!       {"grey95",      33},
!       {"grey80",      34},
       {NULL, NULL},
     };

     guicolor_T color = INVALCOLOR;

--- 1258,1315 ----
  * Get color handle for color "name".
  * Return INVALCOLOR when not possible.
  */
!
     typedef struct guicolor_tTable
     {
       char        *name;
       unsigned long    color;
+       UBYTE           red;
+       UBYTE           green;
+       UBYTE           blue;
     } guicolor_tTable;

     static guicolor_tTable table[] =
     {
!       {"Grey",        0, 190,190,190},
!       {"Black",       1, 0, 0, 0},
!       {"DarkBlue",    2, 0, 0, 139},
!       {"DarkGreen",   3, 0, 100, 0},
!       {"DarkCyan",    4, 0, 139, 139},
!       {"DarkRed",     5, 139, 0, 0},
!       {"DarkMagenta", 6, 139, 0, 139},
!       {"Brown",       7, 165, 42, 42},
!       {"Gray",        8, 190, 190, 190},
!       {"Grey",        9, 190, 190, 190},
!       {"LightGray",   10, 211, 211, 211},
!       {"LightGrey",   11, 211, 211, 211},
!       {"DarkGray",    12, 169, 169, 169},
!       {"DarkGrey",    13, 169, 169, 169},
!       {"Blue",        14, 0, 0, 255},
!       {"LightBlue",   15, 173, 216, 230},
!       {"Green",       16, 0, 255, 0},
!       {"LightGreen",  17, 144, 238, 144},
!       {"Cyan",        18, 0, 255, 255},
!       {"LightCyan",   19, 224, 255, 255},
!       {"Red",         20, 255, 0, 0},
!       {"LightRed",    21, 255, 0, 0}, /*?*/
!       {"Magenta",     22, 255, 0, 255},
!       {"LightMagenta",23, 255, 0, 255}, /*?*/
!       {"Yellow",      24, 255, 255, 0},
!       {"LightYellow", 25, 255, 255, 224},     /* TODO: add DarkYellow */
!       {"White",       26, 255, 255, 255},
!       {"SeaGreen",    27, 46, 139, 87},
!       {"Orange",      28, 255, 165, 0},
!       {"Purple",      30, 160, 32, 240},
!       {"SlateBlue",   31, 106, 90, 205},
!       {"grey90",      32, 229, 229, 229},
!       {"grey95",      33, 242, 242, 242},
!       {"grey80",      34, 204, 204, 204},
       {NULL, NULL},
     };
+
+     guicolor_T
+ gui_mch_get_color(char_u *name)
+ {

     guicolor_T color = INVALCOLOR;

***************
*** 1002,1010 ****
     for (i = 0; table[i].name != NULL;i++)
     {
       if (stricmp(name, table[i].name) == 0)
!           color = table[i].color;
     }

     if (color == INVALCOLOR)
     {
       char *looky = NULL;
--- 1318,1330 ----
     for (i = 0; table[i].name != NULL;i++)
     {
       if (stricmp(name, table[i].name) == 0)
!       {
!           //color = table[i].color;
!           color = i;
!       }
     }

+ #if 0
     if (color == INVALCOLOR)
     {
       char *looky = NULL;
***************
*** 1013,1080 ****
       if (*looky != NUL)
           color = INVALCOLOR;
     }

     return color;
 }

     void
 gui_mch_set_colors(guicolor_T fg, guicolor_T bg)
 {
     if (fg == 0)
     {
       fg = 1;
     }
!     SetABPenDrMd(gui.window->RPort, fg, bg, JAM2);
 }

     void
 gui_mch_set_fg_color(guicolor_T color)
 {
     if (color == 0)
     {
       color = 1; /* vim sends 0 as default color which is ALWAYS the
                     background on the amiga scrolling with colours as the
                     background is a very bad idea on slow machines*/
     }
!     SetAPen(gui.window->RPort, color);
     SetDrMd(gui.window->RPort, JAM2);
 }

     void
 gui_mch_set_bg_color(guicolor_T color)
 {
!     SetBPen(gui.window->RPort, color);
 }

     void
 gui_mch_draw_string(int row, int col, char_u *s, int len, int flags)
 {
!     switch(flags)
     {
!       case 0:
!           Move(gui.window->RPort, posWidthCharToPoint(col), posHeightCharToPoint(row));
!           Text(gui.window->RPort, s, len);
!           break;
!       case DRAW_TRANSP:
!           SetDrMd(gui.window->RPort, INVERSVID);
!           Move(gui.window->RPort, posWidthCharToPoint(col), posHeightCharToPoint(row));
!           Text(gui.window->RPort, s, len);
!           break;
!       case DRAW_BOLD:
!           Move(gui.window->RPort, posWidthCharToPoint(col), posHeightCharToPoint(row));
!           Text(gui.window->RPort, s, len);
!           SetDrMd(gui.window->RPort, JAM1);
!           Move(gui.window->RPort, posWidthCharToPoint(col), posHeightCharToPoint(row));
!           Draw(gui.window->RPort, posWidthCharToPoint(col+len), posHeightCharToPoint(row));
!           SetDrMd(gui.window->RPort, JAM2);
!           break;
!       case DRAW_UNDERL:
!           Move(gui.window->RPort, posWidthCharToPoint(col), posHeightCharToPoint(row));
!           Text(gui.window->RPort, s, len);
!           Move(gui.window->RPort, posWidthCharToPoint(col)+1, posHeightCharToPoint(row));
!           Text(gui.window->RPort, s, len);
!           break;
     }
 }

     int
--- 1333,1445 ----
       if (*looky != NUL)
           color = INVALCOLOR;
     }
+ #endif

+     kprintf("gui_mch_get_color[%s] = %s\n", name, table[color].name);
+
     return color;
 }

+ static UBYTE getrealcolor(guicolor_T i)
+ {
+     if (!MyColorTable[i].alloced)
+     {
+       MyColorTable[i].pen = ObtainBestPen(gui.window->WScreen->ViewPort.ColorMap,
+                                           table[i].red * 0x01010101,
+                                           table[i].green * 0x01010101,
+                                           table[i].blue * 0x01010101,
+                                           OBP_FailIfBad, FALSE,
+                                           OBP_Precision, PRECISION_GUI,
+                                           TAG_DONE);
+       if (MyColorTable[i].pen != -1)
+       {
+           MyColorTable[i].alloced = TRUE;
+       }
+     }
+
+     return MyColorTable[i].pen;
+ }
+
+
     void
 gui_mch_set_colors(guicolor_T fg, guicolor_T bg)
 {
+ #if 0
     if (fg == 0)
     {
       fg = 1;
     }
! #endif
!     SetABPenDrMd(gui.window->RPort, getrealcolor(fg), getrealcolor(bg), JAM2);
!
! kprintf("gui_mch_set_colors %s,%s\n", table[fg].name, table[bg].name);
 }

     void
 gui_mch_set_fg_color(guicolor_T color)
 {
+ #if 0
     if (color == 0)
     {
       color = 1; /* vim sends 0 as default color which is ALWAYS the
                     background on the amiga scrolling with colours as the
                     background is a very bad idea on slow machines*/
     }
! #endif
!     SetAPen(gui.window->RPort, getrealcolor(color));
     SetDrMd(gui.window->RPort, JAM2);
+
+ kprintf("gui_mch_set_fg_color %s\n", table[color].name);
+
 }

     void
 gui_mch_set_bg_color(guicolor_T color)
 {
!     SetBPen(gui.window->RPort, getrealcolor(color));
! kprintf("gui_mch_set_bg_color %s\n", table[color].name);
!
 }

     void
 gui_mch_draw_string(int row, int col, char_u *s, int len, int flags)
 {
! #if 1
!     char tempstring[300];
!
!     memcpy(tempstring, s, len);
!     tempstring[len] = '\0';
!
!     kprintf("gui_mch_draw_string(%s) flags %x\n", tempstring, flags);
! #endif
!
!     if (flags & DRAW_TRANSP)
     {
!       SetDrMd(gui.window->RPort, JAM1);
!       Move(gui.window->RPort, posWidthCharToPoint(col), posHeightCharToPoint(row) + gui.window->RPort->TxBaseline);
!       Text(gui.window->RPort, s, len);
!     }
!     else
!     {
!       SetDrMd(gui.window->RPort, JAM2);
!       Move(gui.window->RPort, posWidthCharToPoint(col), posHeightCharToPoint(row) + gui.window->RPort->TxBaseline);
!       Text(gui.window->RPort, s, len);
     }
+
+     if (flags & DRAW_BOLD)
+     {
+       SetDrMd(gui.window->RPort, JAM1);
+       Move(gui.window->RPort, posWidthCharToPoint(col)+1, posHeightCharToPoint(row) + gui.window->RPort->TxBaseline);
+       Text(gui.window->RPort, s, len);
+     }
+
+     if (flags & DRAW_UNDERL)
+     {
+       Move(gui.window->RPort, posWidthCharToPoint(col), posHeightCharToPoint(row + 1) - 1);
+       Draw(gui.window->RPort, posWidthCharToPoint(col+len) - 1, posHeightCharToPoint(row + 1) - 1);
+     }
+
+     SetDrMd(gui.window->RPort, JAM2);
 }

     int
***************
*** 1101,1106 ****
--- 1466,1477 ----
 gui_mch_flash(int msec)
 {
     D("gui_mch_flash");
+
+     SetDrMd(gui.window->RPort, COMPLEMENT);
+     RectFill(gui.window->RPort, 0, 0, gui.window->GZZWidth - 1, gui.window->GZZHeight - 1);
+     Delay(msec * 50 / 1000);
+     RectFill(gui.window->RPort, 0, 0, gui.window->GZZWidth - 1, gui.window->GZZHeight - 1);
+     SetDrMd(gui.window->RPort, JAM2);
 }

     void
***************
*** 1122,1127 ****
--- 1493,1499 ----
     void
 gui_mch_set_foreground()
 {
+     WindowToFront(gui.window);
     D("gui_mch_set_foreground");
 }
 #endif
***************
*** 1129,1134 ****
--- 1501,1507 ----
     void
 gui_mch_settitle(char_u  *title, char_u  *icon)
 {
+     SetWindowTitles(gui.window, title, (STRPTR)~0);
     D("gui_mch_settitle");
 }

***************
*** 1149,1162 ****
     void
 gui_mch_draw_hollow_cursor(guicolor_T color)
 {
!     drawBox(DB_NotFilled, gui.col, gui.row, color);
 }

     void
! gui_mch_draw_part_cursor( int col, int row, guicolor_T color)
 {
     D("gui_mch_part_cursor");
!     drawBox(DB_Filled, col, row, color);
 }

     void
--- 1522,1535 ----
     void
 gui_mch_draw_hollow_cursor(guicolor_T color)
 {
!     drawBox(DB_NotFilled, gui.col, gui.row, characterWidth, characterHeight, color);
 }

     void
! gui_mch_draw_part_cursor( int w, int h, guicolor_T color)
 {
     D("gui_mch_part_cursor");
!     drawBox(DB_Filled, gui.col, gui.row, w, h, color);
 }

     void
***************
*** 1169,1176 ****
     int
 gui_mch_wait_for_chars(int wtime)
 {
!     assert(wtime != 0);
!     return charEventHandler(wtime);
 }

     void
--- 1542,1598 ----
     int
 gui_mch_wait_for_chars(int wtime)
 {
!     ULONG timermask = 1L << TimerMP->mp_SigBit;
!     ULONG winmask = 1L << gui.window->UserPort->mp_SigBit;
!     int retval = FAIL;
!
!     kprintf("========== gui_mch_wait_for_chars %d\n", wtime);
!
!     if (wtime == -1) wtime = 1000000000;
!     if (wtime < 20) wtime = 20;
!
!     SetSignal(0, timermask);
!     TimerIO->tr_node.io_Command = TR_ADDREQUEST;
!     TimerIO->tr_time.tv_secs = wtime / 1000;
!     TimerIO->tr_time.tv_micro = (wtime % 1000) * 1000;
!     SendIO(&TimerIO->tr_node);
!     TimerSent = TRUE;
!
!     for(;;)
!     {
!       ULONG sigs = Wait(winmask | timermask);
!
!       if (sigs & winmask)
!       {
!           checkEventHandler();
!           if (!vim_is_input_buf_empty())
!           {
!               retval = OK;
!               if (!CheckIO(&TimerIO->tr_node)) AbortIO(&TimerIO->tr_node);
!               WaitIO(&TimerIO->tr_node);
!               TimerSent = FALSE;
!               break;
!           }
!       }
!
!       if (sigs & timermask)
!       {
!           struct Message *msg;
!
!           if ((msg = GetMsg(TimerMP)))
!           {
!               ReplyMsg(msg);
!               TimerSent = FALSE;
!               retval = FAIL;
!               break;
!           }
!       }
!     }
!
!     return retval;
!
! //    assert(wtime != 0);
! //    return charEventHandler(wtime);
 }

     void
***************
*** 1181,1202 ****
     void
 gui_mch_clear_block(int row1, int col1, int row2, int col2)
 {
!     register int start;
!
!     /* TODO: this isn't using "col2"! */
!     for (start = row1; start < row2; start ++)
!     {
!       Move(gui.window->RPort, 0, posHeightCharToPoint(start));
!       gui_mch_set_fg_color(0);
!       gui_mch_set_bg_color(0);
!       ClearEOL(gui.window->RPort);
!     }
 }

     void
 gui_mch_clear_all(void)
 {
!     SetRast(gui.window->RPort, 0);
     refreshBorder();
     D("gui_mch_clear_all");
 }
--- 1603,1624 ----
     void
 gui_mch_clear_block(int row1, int col1, int row2, int col2)
 {
!     UBYTE apen = GetAPen(gui.window->RPort);
!
!     SetAPen(gui.window->RPort, getrealcolor(gui.back_pixel));
!     RectFill(gui.window->RPort,
!            posWidthCharToPoint(col1),
!            posHeightCharToPoint(row1),
!            posWidthCharToPoint(col2 + 1) - 1,
!            posHeightCharToPoint(row2 + 1) - 1);
!     SetAPen(gui.window->RPort, apen);
!
 }

     void
 gui_mch_clear_all(void)
 {
!     SetRast(gui.window->RPort, GetBPen(gui.window->RPort));
     refreshBorder();
     D("gui_mch_clear_all");
 }
***************
*** 1204,1235 ****
     void
 gui_mch_delete_lines(int row, int num_lines)
 {
!     gui_clear_block(row, 0, row + num_lines, Columns - 1);
!     /* changed without checking! */
!     ScrollRaster(gui.window->RPort,
!           posWidthCharToPoint(gui.scroll_region_left),
           characterHeight * num_lines,
           posWidthCharToPoint(gui.scroll_region_left),
!           posHeightCharToPoint(row - 1) + 2,
!           posWidthCharToPoint(gui.scroll_region_right + 1),
!           posHeightCharToPoint(gui.scroll_region_bot) + 3);
 }

     void
 gui_mch_insert_lines(int row, int num_lines)
 {
!     SetABPenDrMd(gui.window->RPort, 0, 0, JAM2);
!     /* changed without checking! */
!     ScrollRaster(gui.window->RPort,
!           posWidthCharToPoint(gui.scroll_region_left),
           -characterHeight*num_lines,
           posWidthCharToPoint(gui.scroll_region_left),
!           posHeightCharToPoint(row-1)+2,
!           posWidthCharToPoint(gui.scroll_region_right + 1),
!           posHeightCharToPoint(gui.scroll_region_bot-num_lines+1)+1);

     gui_clear_block(row, gui.scroll_region_left,
!                                   row + num_lines, gui.scroll_region_right);
 }

     void
--- 1626,1660 ----
     void
 gui_mch_delete_lines(int row, int num_lines)
 {
!     ScrollWindowRaster(gui.window,
!           0,
           characterHeight * num_lines,
           posWidthCharToPoint(gui.scroll_region_left),
!           posHeightCharToPoint(row),
!           posWidthCharToPoint(gui.scroll_region_right + 1) - 1,
!           posHeightCharToPoint(gui.scroll_region_bot + 1) - 1);
!
!     gui_clear_block(gui.scroll_region_bot - num_lines + 1,
!                   gui.scroll_region_left,
!                   gui.scroll_region_bot,
!                   gui.scroll_region_right);
!
 }

     void
 gui_mch_insert_lines(int row, int num_lines)
 {
!      ScrollWindowRaster(gui.window,
!           0,
           -characterHeight*num_lines,
           posWidthCharToPoint(gui.scroll_region_left),
!           posHeightCharToPoint(row),
!           posWidthCharToPoint(gui.scroll_region_right + 1) - 1,
!           posHeightCharToPoint(gui.scroll_region_bot +1 ) - 1);

     gui_clear_block(row, gui.scroll_region_left,
!                   row + num_lines - 1, gui.scroll_region_right);
!
 }

     void
***************
*** 1308,1322 ****
     int
 gui_mch_get_mouse_x()
 {
!     /* TODO */
!     return -1;
 }

     int
 gui_mch_get_mouse_y()
 {
!     /* TODO */
!     return -1;
 }

     void
--- 1733,1745 ----
     int
 gui_mch_get_mouse_x()
 {
!     return gui.window->GZZMouseX;
 }

     int
 gui_mch_get_mouse_y()
 {
!     return gui.window->GZZMouseY;
 }

     void
***************
*** 1353,1363 ****
     long_u
 gui_mch_get_rgb(guicolor_T pixel)
 {
!     unsigned long  color;

!     color = GetRGB4(gui.window->WScreen->ViewPort.ColorMap, pixel);
!     return ((color & 0xf00) << 12) + ((color & 0x0f0) << 8)
!                                                    + ((color & 0x00f) << 4);
 }

 #endif /* USE_AMIGA_GUI*/
--- 1776,1793 ----
     long_u
 gui_mch_get_rgb(guicolor_T pixel)
 {
!     ULONG coltable[3], color;

!     GetRGB32(gui.window->WScreen->ViewPort.ColorMap,
!            getrealcolor(pixel),
!            1,
!            coltable);
!
!     color = ((coltable[0] & 0xFF000000) >> 8) |
!           ((coltable[1] & 0xFF000000) >> 16) |
!           ((coltable[2] & 0xFF000000) >> 24);
!
!     return color;
 }

 #endif /* USE_AMIGA_GUI*/
*** ../vim-6.3a.019/src/gui_amiga.h     Fri May  7 10:59:37 2004
--- src/gui_amiga.h     Thu May 13 15:04:21 2004
***************
*** 32,38 ****
     ev_KeyStroke,
     ev_IntuiTicks,
     ev_MenuHelp,
!     ev_GadgetHelp
 };

 struct MyMenuItem {
--- 32,40 ----
     ev_KeyStroke,
     ev_IntuiTicks,
     ev_MenuHelp,
!     ev_GadgetHelp,
!
!     ev_Ignore
 };

 struct MyMenuItem {
*** ../vim-6.3a.019/src/memfile.c       Fri May  7 10:59:39 2004
--- src/memfile.c       Thu May 13 15:06:49 2004
***************
*** 655,690 ****
 # endif
 #endif
 #ifdef AMIGA
       /*
        * Flush() only exists for AmigaDos 2.0.
        * For 1.3 it should be done with close() + open(), but then the risk
        * is that the open() may fail and lose the file....
        */
! # ifdef FEAT_ARP
       if (dos2)
! # endif
! # ifdef SASC
       {
           struct UFB *fp = chkufb(mfp->mf_fd);

           if (fp != NULL)
               Flush(fp->ufbfh);
       }
! # else
! #  if defined(_DCC) || defined(__GNUC__) || defined(__MORPHOS__)
       {
! #   if defined(__GNUC__) && !defined(__MORPHOS__)
           /* Have function (in libnix at least),
            * but ain't got no prototype anywhere. */
           extern unsigned long fdtofh(int filedescriptor);
! #   endif
           BPTR fh = (BPTR)fdtofh(mfp->mf_fd);

           if (fh != 0)
               Flush(fh);
!           }
! #  else /* assume Manx */
           Flush(_devtab[mfp->mf_fd].fd);
 #  endif
 # endif
 #endif /* AMIGA */
--- 655,695 ----
 # endif
 #endif
 #ifdef AMIGA
+ # ifdef __AROS__
+         if (fsync(mfp->mf_fd) != 0)
+           status = FAIL;
+ # else
       /*
        * Flush() only exists for AmigaDos 2.0.
        * For 1.3 it should be done with close() + open(), but then the risk
        * is that the open() may fail and lose the file....
        */
! #  ifdef FEAT_ARP
       if (dos2)
! #  endif
! #  ifdef SASC
       {
           struct UFB *fp = chkufb(mfp->mf_fd);

           if (fp != NULL)
               Flush(fp->ufbfh);
       }
! #  else
! #   if defined(_DCC) || defined(__GNUC__) || defined(__MORPHOS__)
       {
! #    if defined(__GNUC__) && !defined(__MORPHOS__)
           /* Have function (in libnix at least),
            * but ain't got no prototype anywhere. */
           extern unsigned long fdtofh(int filedescriptor);
! #    endif
           BPTR fh = (BPTR)fdtofh(mfp->mf_fd);

           if (fh != 0)
               Flush(fh);
!         }
! #   else /* assume Manx */
           Flush(_devtab[mfp->mf_fd].fd);
+ #   endif
 #  endif
 # endif
 #endif /* AMIGA */
*** ../vim-6.3a.019/src/os_amiga.c      Fri May  7 10:59:38 2004
--- src/os_amiga.c      Thu May 13 15:08:55 2004
***************
*** 56,62 ****
 #undef        FALSE
 #define FALSE (0)

! #ifndef AZTEC_C
 static long dos_packet __ARGS((struct MsgPort *, long, long));
 #endif
 static int lock2name __ARGS((BPTR lock, char_u *buf, long   len));
--- 56,62 ----
 #undef        FALSE
 #define FALSE (0)

! #if !defined(AZTEC_C) && !defined(__AROS__)
 static long dos_packet __ARGS((struct MsgPort *, long, long));
 #endif
 static int lock2name __ARGS((BPTR lock, char_u *buf, long   len));
***************
*** 932,939 ****
--- 932,943 ----
 mch_settmode(tmode)
     int               tmode;
 {
+ #ifdef __AROS__
+     if (!SetMode(raw_in, tmode == TMODE_RAW ? 1 : 0))
+ #else
     if (dos_packet(MP(raw_in), (long)ACTION_SCREEN_MODE,
                                         tmode == TMODE_RAW ? -1L : 0L) == 0)
+ #endif
       mch_errmsg(_("cannot change console mode ?!\n"));
 }

***************
*** 988,995 ****
--- 992,1004 ----
       OUT_STR("\233t\233u");  /* CSI t CSI u */
     out_flush();

+ #ifdef __AROS__
+     if (!Info(raw_out, id)
+                || (wb_window = (struct Window *) id->id_VolumeNode) == NULL)
+ #else
     if (dos_packet(MP(raw_out), (long)ACTION_DISK_INFO, ((ULONG) id) >> 2) == 0
           || (wb_window = (struct Window *)id->id_VolumeNode) == NULL)
+ #endif
     {
       /* it's not an amiga window, maybe aux device */
       /* terminal type should be set */
***************
*** 1057,1063 ****
     OUT_STR_NF(tltoa((unsigned long)n));
 }

! #ifndef AZTEC_C
 /*
  * Sendpacket.c
  *
--- 1066,1072 ----
     OUT_STR_NF(tltoa((unsigned long)n));
 }

! #if !defined(AZTEC_C) && !defined(__AROS__)
 /*
  * Sendpacket.c
  *
***************
*** 1125,1131 ****
     return (res1);
 # endif
 }
! #endif

 /*
  * Call shell.
--- 1134,1140 ----
     return (res1);
 # endif
 }
! #endif /* !defined(AZTEC_C) && !defined(__AROS__) */

 /*
  * Call shell.
*** ../vim-6.3a.019/src/term.c  Fri May  7 10:59:38 2004
--- src/term.c  Thu May 13 15:00:27 2004
***************
*** 296,302 ****
     {(int)KS_UE,      "\033[0m"},
     {(int)KS_CZH,     "\033[3m"},
     {(int)KS_CZR,     "\033[0m"},
! #if defined(__MORPHOS__)
     {(int)KS_CCO,     "8"},           /* allow 8 colors */
 #  ifdef TERMINFO
     {(int)KS_CAB,     "\033[4%p1%dm"},/* set background color */
--- 296,302 ----
     {(int)KS_UE,      "\033[0m"},
     {(int)KS_CZH,     "\033[3m"},
     {(int)KS_CZR,     "\033[0m"},
! #if defined(__MORPHOS__) || defined(__AROS__)
     {(int)KS_CCO,     "8"},           /* allow 8 colors */
 #  ifdef TERMINFO
     {(int)KS_CAB,     "\033[4%p1%dm"},/* set background color */
*** ../vim-6.3a.019/src/version.c       Thu May 13 14:36:40 2004
--- src/version.c       Thu May 13 15:12:00 2004
***************
*** 643,644 ****
--- 643,646 ----
 {   /* Add new patch number below this line */
+ /**/
+     20,
 /**/

--
  GALAHAD turns back.  We see from his POV the lovely ZOOT standing by him
  smiling enchantingly and a number of equally delectable GIRLIES draped
  around in the seductively poulticed room.  They look at him smilingly and
  wave.
                "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
\\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///