ea4a5a8
To: vim-dev@vim.org
ea4a5a8
Subject: Patch 7.1.275
ea4a5a8
Fcc: outbox
ea4a5a8
From: Bram Moolenaar <Bram@moolenaar.net>
ea4a5a8
Mime-Version: 1.0
ea4a5a8
Content-Type: text/plain; charset=ISO-8859-1
ea4a5a8
Content-Transfer-Encoding: 8bit
ea4a5a8
------------
ea4a5a8
ea4a5a8
Patch 7.1.275 (extra)
ea4a5a8
Problem:    Mac: ATSUI and 'antialias' don't work properly together.
ea4a5a8
Solution:   Fix this and the input method. (Jjgod Jiang)
ea4a5a8
Files:	    src/vim.h, src/gui_mac.c
ea4a5a8
ea4a5a8
ea4a5a8
*** ../vim-7.1.274/src/vim.h	Wed Feb 20 12:22:59 2008
ea4a5a8
--- src/vim.h	Wed Mar 12 13:18:58 2008
ea4a5a8
***************
ea4a5a8
*** 461,468 ****
ea4a5a8
  /*
ea4a5a8
   * Check input method control.
ea4a5a8
   */
ea4a5a8
! #if defined(FEAT_XIM) || \
ea4a5a8
!     (defined(FEAT_GUI) && (defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME)))
ea4a5a8
  # define USE_IM_CONTROL
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
--- 461,469 ----
ea4a5a8
  /*
ea4a5a8
   * Check input method control.
ea4a5a8
   */
ea4a5a8
! #if defined(FEAT_XIM) \
ea4a5a8
!     || (defined(FEAT_GUI) && (defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \
ea4a5a8
!     || defined(FEAT_GUI_MAC)
ea4a5a8
  # define USE_IM_CONTROL
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
*** ../vim-7.1.274/src/gui_mac.c	Sat Sep 29 13:15:29 2007
ea4a5a8
--- src/gui_mac.c	Wed Mar 12 13:40:57 2008
ea4a5a8
***************
ea4a5a8
*** 59,65 ****
ea4a5a8
--- 59,91 ----
ea4a5a8
  
ea4a5a8
  #ifdef MACOS_CONVERT
ea4a5a8
  # define USE_CARBONKEYHANDLER
ea4a5a8
+ 
ea4a5a8
+ static int im_is_active = FALSE;
ea4a5a8
+ #if 0
ea4a5a8
+ static int im_start_row = 0;
ea4a5a8
+ static int im_start_col = 0;
ea4a5a8
+ #endif
ea4a5a8
+ 
ea4a5a8
+ #define NR_ELEMS(x)	(sizeof(x) / sizeof(x[0]))
ea4a5a8
+ 
ea4a5a8
+ static TSMDocumentID gTSMDocument;
ea4a5a8
+ 
ea4a5a8
+ static void im_on_window_switch(int active);
ea4a5a8
  static EventHandlerUPP keyEventHandlerUPP = NULL;
ea4a5a8
+ static EventHandlerUPP winEventHandlerUPP = NULL;
ea4a5a8
+ 
ea4a5a8
+ static pascal OSStatus gui_mac_handle_window_activate(
ea4a5a8
+ 	EventHandlerCallRef nextHandler, EventRef theEvent, void *data);
ea4a5a8
+ 
ea4a5a8
+ static pascal OSStatus gui_mac_handle_text_input(
ea4a5a8
+ 	EventHandlerCallRef nextHandler, EventRef theEvent, void *data);
ea4a5a8
+ 
ea4a5a8
+ static pascal OSStatus gui_mac_update_input_area(
ea4a5a8
+ 	EventHandlerCallRef nextHandler, EventRef theEvent);
ea4a5a8
+ 
ea4a5a8
+ static pascal OSStatus gui_mac_unicode_key_event(
ea4a5a8
+ 	EventHandlerCallRef nextHandler, EventRef theEvent);
ea4a5a8
+ 
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
  
ea4a5a8
***************
ea4a5a8
*** 137,143 ****
ea4a5a8
--- 166,176 ----
ea4a5a8
  
ea4a5a8
  #ifdef MACOS_CONVERT
ea4a5a8
  # define USE_ATSUI_DRAWING
ea4a5a8
+ int	    p_macatsui_last;
ea4a5a8
  ATSUStyle   gFontStyle;
ea4a5a8
+ # ifdef FEAT_MBYTE
ea4a5a8
+ ATSUStyle   gWideFontStyle;
ea4a5a8
+ # endif
ea4a5a8
  Boolean	    gIsFontFallbackSet;
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
***************
ea4a5a8
*** 265,270 ****
ea4a5a8
--- 298,308 ----
ea4a5a8
  static WindowRef drawer = NULL; // TODO: put into gui.h
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
+ #ifdef USE_ATSUI_DRAWING
ea4a5a8
+ static void gui_mac_set_font_attributes(GuiFont font);
ea4a5a8
+ static void gui_mac_dispose_atsui_style(void);
ea4a5a8
+ #endif
ea4a5a8
+ 
ea4a5a8
  /*
ea4a5a8
   * ------------------------------------------------------------
ea4a5a8
   * Conversion Utility
ea4a5a8
***************
ea4a5a8
*** 1935,1946 ****
ea4a5a8
      /* Dim scrollbars */
ea4a5a8
      if (whichWindow == gui.VimWindow)
ea4a5a8
      {
ea4a5a8
!         ControlRef rootControl;
ea4a5a8
!         GetRootControl(gui.VimWindow, &rootControl);
ea4a5a8
!         if ((event->modifiers) & activeFlag)
ea4a5a8
!             ActivateControl(rootControl);
ea4a5a8
!         else
ea4a5a8
!             DeactivateControl(rootControl);
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      /* Activate */
ea4a5a8
--- 1973,1984 ----
ea4a5a8
      /* Dim scrollbars */
ea4a5a8
      if (whichWindow == gui.VimWindow)
ea4a5a8
      {
ea4a5a8
! 	ControlRef rootControl;
ea4a5a8
! 	GetRootControl(gui.VimWindow, &rootControl);
ea4a5a8
! 	if ((event->modifiers) & activeFlag)
ea4a5a8
! 	    ActivateControl(rootControl);
ea4a5a8
! 	else
ea4a5a8
! 	    DeactivateControl(rootControl);
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      /* Activate */
ea4a5a8
***************
ea4a5a8
*** 1976,1990 ****
ea4a5a8
   * Handle the key
ea4a5a8
   */
ea4a5a8
  #ifdef USE_CARBONKEYHANDLER
ea4a5a8
  
ea4a5a8
! static int dialog_busy = FALSE;	    /* TRUE when gui_mch_dialog() wants the keys */
ea4a5a8
  
ea4a5a8
  # define INLINE_KEY_BUFFER_SIZE 80
ea4a5a8
      static pascal OSStatus
ea4a5a8
! gui_mac_doKeyEventCarbon(
ea4a5a8
  	EventHandlerCallRef nextHandler,
ea4a5a8
! 	EventRef theEvent,
ea4a5a8
! 	void *data)
ea4a5a8
  {
ea4a5a8
      /* Multibyte-friendly key event handler */
ea4a5a8
      OSStatus	err = -1;
ea4a5a8
--- 2014,2100 ----
ea4a5a8
   * Handle the key
ea4a5a8
   */
ea4a5a8
  #ifdef USE_CARBONKEYHANDLER
ea4a5a8
+     static pascal OSStatus
ea4a5a8
+ gui_mac_handle_window_activate(
ea4a5a8
+ 	EventHandlerCallRef nextHandler,
ea4a5a8
+ 	EventRef	    theEvent,
ea4a5a8
+ 	void		    *data)
ea4a5a8
+ {
ea4a5a8
+     UInt32 eventClass = GetEventClass(theEvent);
ea4a5a8
+     UInt32 eventKind  = GetEventKind(theEvent);
ea4a5a8
+ 
ea4a5a8
+     if (eventClass == kEventClassWindow)
ea4a5a8
+     {
ea4a5a8
+ 	switch (eventKind)
ea4a5a8
+ 	{
ea4a5a8
+ 	    case kEventWindowActivated:
ea4a5a8
+ #if defined(USE_IM_CONTROL)
ea4a5a8
+ 		im_on_window_switch(TRUE);
ea4a5a8
+ #endif
ea4a5a8
+ 		return noErr;
ea4a5a8
+ 
ea4a5a8
+ 	    case kEventWindowDeactivated:
ea4a5a8
+ #if defined(USE_IM_CONTROL)
ea4a5a8
+ 		im_on_window_switch(FALSE);
ea4a5a8
+ #endif
ea4a5a8
+ 		return noErr;
ea4a5a8
+ 	}
ea4a5a8
+     }
ea4a5a8
+ 
ea4a5a8
+     return eventNotHandledErr;
ea4a5a8
+ }
ea4a5a8
+ 
ea4a5a8
+     static pascal OSStatus
ea4a5a8
+ gui_mac_handle_text_input(
ea4a5a8
+ 	EventHandlerCallRef nextHandler,
ea4a5a8
+ 	EventRef	    theEvent,
ea4a5a8
+ 	void		    *data)
ea4a5a8
+ {
ea4a5a8
+     UInt32 eventClass = GetEventClass(theEvent);
ea4a5a8
+     UInt32 eventKind  = GetEventKind(theEvent);
ea4a5a8
+ 
ea4a5a8
+     if (eventClass != kEventClassTextInput)
ea4a5a8
+ 	return eventNotHandledErr;
ea4a5a8
  
ea4a5a8
!     if ((kEventTextInputUpdateActiveInputArea != eventKind) &&
ea4a5a8
! 	(kEventTextInputUnicodeForKeyEvent    != eventKind) &&
ea4a5a8
! 	(kEventTextInputOffsetToPos	      != eventKind) &&
ea4a5a8
! 	(kEventTextInputPosToOffset	      != eventKind) &&
ea4a5a8
! 	(kEventTextInputGetSelectedText       != eventKind))
ea4a5a8
! 	      return eventNotHandledErr;
ea4a5a8
! 
ea4a5a8
!     switch (eventKind)
ea4a5a8
!     {
ea4a5a8
!     case kEventTextInputUpdateActiveInputArea:
ea4a5a8
! 	return gui_mac_update_input_area(nextHandler, theEvent);
ea4a5a8
!     case kEventTextInputUnicodeForKeyEvent:
ea4a5a8
! 	return gui_mac_unicode_key_event(nextHandler, theEvent);
ea4a5a8
! 
ea4a5a8
!     case kEventTextInputOffsetToPos:
ea4a5a8
!     case kEventTextInputPosToOffset:
ea4a5a8
!     case kEventTextInputGetSelectedText:
ea4a5a8
! 	break;
ea4a5a8
!     }
ea4a5a8
! 
ea4a5a8
!     return eventNotHandledErr;
ea4a5a8
! }
ea4a5a8
! 
ea4a5a8
!     static pascal
ea4a5a8
! OSStatus gui_mac_update_input_area(
ea4a5a8
! 	EventHandlerCallRef nextHandler,
ea4a5a8
! 	EventRef	    theEvent)
ea4a5a8
! {
ea4a5a8
!     return eventNotHandledErr;
ea4a5a8
! }
ea4a5a8
! 
ea4a5a8
! static int dialog_busy = FALSE;	    /* TRUE when gui_mch_dialog() wants the
ea4a5a8
! 				       keys */
ea4a5a8
  
ea4a5a8
  # define INLINE_KEY_BUFFER_SIZE 80
ea4a5a8
      static pascal OSStatus
ea4a5a8
! gui_mac_unicode_key_event(
ea4a5a8
  	EventHandlerCallRef nextHandler,
ea4a5a8
! 	EventRef	    theEvent)
ea4a5a8
  {
ea4a5a8
      /* Multibyte-friendly key event handler */
ea4a5a8
      OSStatus	err = -1;
ea4a5a8
***************
ea4a5a8
*** 2000,2006 ****
ea4a5a8
      char_u	*to = NULL;
ea4a5a8
      Boolean	isSpecial = FALSE;
ea4a5a8
      int		i;
ea4a5a8
!     EventRef keyEvent;
ea4a5a8
  
ea4a5a8
      /* Mask the mouse (as per user setting) */
ea4a5a8
      if (p_mh)
ea4a5a8
--- 2110,2116 ----
ea4a5a8
      char_u	*to = NULL;
ea4a5a8
      Boolean	isSpecial = FALSE;
ea4a5a8
      int		i;
ea4a5a8
!     EventRef	keyEvent;
ea4a5a8
  
ea4a5a8
      /* Mask the mouse (as per user setting) */
ea4a5a8
      if (p_mh)
ea4a5a8
***************
ea4a5a8
*** 2008,2046 ****
ea4a5a8
  
ea4a5a8
      /* Don't use the keys when the dialog wants them. */
ea4a5a8
      if (dialog_busy)
ea4a5a8
!         return eventNotHandledErr;
ea4a5a8
  
ea4a5a8
      if (noErr != GetEventParameter(theEvent, kEventParamTextInputSendText,
ea4a5a8
!                 typeUnicodeText, NULL, 0, &actualSize, NULL))
ea4a5a8
!         return eventNotHandledErr;
ea4a5a8
  
ea4a5a8
      text = (UniChar *)alloc(actualSize);
ea4a5a8
      if (!text)
ea4a5a8
!         return eventNotHandledErr;
ea4a5a8
  
ea4a5a8
      err = GetEventParameter(theEvent, kEventParamTextInputSendText,
ea4a5a8
!             typeUnicodeText, NULL, actualSize, NULL, text);
ea4a5a8
      require_noerr(err, done);
ea4a5a8
  
ea4a5a8
      err = GetEventParameter(theEvent, kEventParamTextInputSendKeyboardEvent,
ea4a5a8
!             typeEventRef, NULL, sizeof(EventRef), NULL, &keyEvent);
ea4a5a8
      require_noerr(err, done);
ea4a5a8
  
ea4a5a8
      err = GetEventParameter(keyEvent, kEventParamKeyModifiers,
ea4a5a8
!             typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
ea4a5a8
      require_noerr(err, done);
ea4a5a8
  
ea4a5a8
      err = GetEventParameter(keyEvent, kEventParamKeyCode,
ea4a5a8
!             typeUInt32, NULL, sizeof(UInt32), NULL, &key_sym);
ea4a5a8
      require_noerr(err, done);
ea4a5a8
  
ea4a5a8
      err = GetEventParameter(keyEvent, kEventParamKeyMacCharCodes,
ea4a5a8
!             typeChar, NULL, sizeof(char), NULL, &charcode);
ea4a5a8
      require_noerr(err, done);
ea4a5a8
  
ea4a5a8
  #ifndef USE_CMD_KEY
ea4a5a8
      if (modifiers & cmdKey)
ea4a5a8
!         goto done;  /* Let system handle Cmd+... */
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
      key_char = charcode;
ea4a5a8
--- 2118,2156 ----
ea4a5a8
  
ea4a5a8
      /* Don't use the keys when the dialog wants them. */
ea4a5a8
      if (dialog_busy)
ea4a5a8
! 	return eventNotHandledErr;
ea4a5a8
  
ea4a5a8
      if (noErr != GetEventParameter(theEvent, kEventParamTextInputSendText,
ea4a5a8
! 		typeUnicodeText, NULL, 0, &actualSize, NULL))
ea4a5a8
! 	return eventNotHandledErr;
ea4a5a8
  
ea4a5a8
      text = (UniChar *)alloc(actualSize);
ea4a5a8
      if (!text)
ea4a5a8
! 	return eventNotHandledErr;
ea4a5a8
  
ea4a5a8
      err = GetEventParameter(theEvent, kEventParamTextInputSendText,
ea4a5a8
! 	    typeUnicodeText, NULL, actualSize, NULL, text);
ea4a5a8
      require_noerr(err, done);
ea4a5a8
  
ea4a5a8
      err = GetEventParameter(theEvent, kEventParamTextInputSendKeyboardEvent,
ea4a5a8
! 	    typeEventRef, NULL, sizeof(EventRef), NULL, &keyEvent);
ea4a5a8
      require_noerr(err, done);
ea4a5a8
  
ea4a5a8
      err = GetEventParameter(keyEvent, kEventParamKeyModifiers,
ea4a5a8
! 	    typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
ea4a5a8
      require_noerr(err, done);
ea4a5a8
  
ea4a5a8
      err = GetEventParameter(keyEvent, kEventParamKeyCode,
ea4a5a8
! 	    typeUInt32, NULL, sizeof(UInt32), NULL, &key_sym);
ea4a5a8
      require_noerr(err, done);
ea4a5a8
  
ea4a5a8
      err = GetEventParameter(keyEvent, kEventParamKeyMacCharCodes,
ea4a5a8
! 	    typeChar, NULL, sizeof(char), NULL, &charcode);
ea4a5a8
      require_noerr(err, done);
ea4a5a8
  
ea4a5a8
  #ifndef USE_CMD_KEY
ea4a5a8
      if (modifiers & cmdKey)
ea4a5a8
! 	goto done;  /* Let system handle Cmd+... */
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
      key_char = charcode;
ea4a5a8
***************
ea4a5a8
*** 2048,2131 ****
ea4a5a8
  
ea4a5a8
      /* Find the special key (eg., for cursor keys) */
ea4a5a8
      if (actualSize <= sizeof(UniChar) &&
ea4a5a8
!             ((text[0] < 0x20) || (text[0] == 0x7f)))
ea4a5a8
      {
ea4a5a8
!         for (i = 0; special_keys[i].key_sym != (KeySym)0; ++i)
ea4a5a8
!             if (special_keys[i].key_sym == key_sym)
ea4a5a8
!             {
ea4a5a8
!                 key_char = TO_SPECIAL(special_keys[i].vim_code0,
ea4a5a8
!                         special_keys[i].vim_code1);
ea4a5a8
!                 key_char = simplify_key(key_char,
ea4a5a8
!                         (int *)&vimModifiers);
ea4a5a8
!                 isSpecial = TRUE;
ea4a5a8
!                 break;
ea4a5a8
!             }
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      /* Intercept CMD-. and CTRL-c */
ea4a5a8
      if (((modifiers & controlKey) && key_char == 'c') ||
ea4a5a8
!             ((modifiers & cmdKey) && key_char == '.'))
ea4a5a8
!         got_int = TRUE;
ea4a5a8
  
ea4a5a8
      if (!isSpecial)
ea4a5a8
      {
ea4a5a8
!         /* remove SHIFT for keys that are already shifted, e.g.,
ea4a5a8
!          * '(' and '*' */
ea4a5a8
!         if (key_char < 0x100 && !isalpha(key_char) && isprint(key_char))
ea4a5a8
!             vimModifiers &= ~MOD_MASK_SHIFT;
ea4a5a8
! 
ea4a5a8
!         /* remove CTRL from keys that already have it */
ea4a5a8
!         if (key_char < 0x20)
ea4a5a8
!             vimModifiers &= ~MOD_MASK_CTRL;
ea4a5a8
! 
ea4a5a8
!         /* don't process unicode characters here */
ea4a5a8
!         if (!IS_SPECIAL(key_char))
ea4a5a8
!         {
ea4a5a8
!             /* Following code to simplify and consolidate vimModifiers
ea4a5a8
!              * taken liberally from gui_w48.c */
ea4a5a8
!             key_char = simplify_key(key_char, (int *)&vimModifiers);
ea4a5a8
! 
ea4a5a8
!             /* Interpret META, include SHIFT, etc. */
ea4a5a8
!             key_char = extract_modifiers(key_char, (int *)&vimModifiers);
ea4a5a8
!             if (key_char == CSI)
ea4a5a8
!                 key_char = K_CSI;
ea4a5a8
! 
ea4a5a8
!             if (IS_SPECIAL(key_char))
ea4a5a8
!                 isSpecial = TRUE;
ea4a5a8
!         }
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      if (vimModifiers)
ea4a5a8
      {
ea4a5a8
!         result[len++] = CSI;
ea4a5a8
!         result[len++] = KS_MODIFIER;
ea4a5a8
!         result[len++] = vimModifiers;
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      if (isSpecial && IS_SPECIAL(key_char))
ea4a5a8
      {
ea4a5a8
!         result[len++] = CSI;
ea4a5a8
!         result[len++] = K_SECOND(key_char);
ea4a5a8
!         result[len++] = K_THIRD(key_char);
ea4a5a8
      }
ea4a5a8
      else
ea4a5a8
      {
ea4a5a8
!         encLen = actualSize;
ea4a5a8
!         to = mac_utf16_to_enc(text, actualSize, &encLen);
ea4a5a8
!         if (to)
ea4a5a8
!         {
ea4a5a8
!             /* This is basically add_to_input_buf_csi() */
ea4a5a8
!             for (i = 0; i < encLen && len < (INLINE_KEY_BUFFER_SIZE-1); ++i)
ea4a5a8
!             {
ea4a5a8
!                 result[len++] = to[i];
ea4a5a8
!                 if (to[i] == CSI)
ea4a5a8
!                 {
ea4a5a8
!                     result[len++] = KS_EXTRA;
ea4a5a8
!                     result[len++] = (int)KE_CSI;
ea4a5a8
!                 }
ea4a5a8
!             }
ea4a5a8
!             vim_free(to);
ea4a5a8
!         }
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      add_to_input_buf(result, len);
ea4a5a8
--- 2158,2241 ----
ea4a5a8
  
ea4a5a8
      /* Find the special key (eg., for cursor keys) */
ea4a5a8
      if (actualSize <= sizeof(UniChar) &&
ea4a5a8
! 	    ((text[0] < 0x20) || (text[0] == 0x7f)))
ea4a5a8
      {
ea4a5a8
! 	for (i = 0; special_keys[i].key_sym != (KeySym)0; ++i)
ea4a5a8
! 	    if (special_keys[i].key_sym == key_sym)
ea4a5a8
! 	    {
ea4a5a8
! 		key_char = TO_SPECIAL(special_keys[i].vim_code0,
ea4a5a8
! 			special_keys[i].vim_code1);
ea4a5a8
! 		key_char = simplify_key(key_char,
ea4a5a8
! 			(int *)&vimModifiers);
ea4a5a8
! 		isSpecial = TRUE;
ea4a5a8
! 		break;
ea4a5a8
! 	    }
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      /* Intercept CMD-. and CTRL-c */
ea4a5a8
      if (((modifiers & controlKey) && key_char == 'c') ||
ea4a5a8
! 	    ((modifiers & cmdKey) && key_char == '.'))
ea4a5a8
! 	got_int = TRUE;
ea4a5a8
  
ea4a5a8
      if (!isSpecial)
ea4a5a8
      {
ea4a5a8
! 	/* remove SHIFT for keys that are already shifted, e.g.,
ea4a5a8
! 	 * '(' and '*' */
ea4a5a8
! 	if (key_char < 0x100 && !isalpha(key_char) && isprint(key_char))
ea4a5a8
! 	    vimModifiers &= ~MOD_MASK_SHIFT;
ea4a5a8
! 
ea4a5a8
! 	/* remove CTRL from keys that already have it */
ea4a5a8
! 	if (key_char < 0x20)
ea4a5a8
! 	    vimModifiers &= ~MOD_MASK_CTRL;
ea4a5a8
! 
ea4a5a8
! 	/* don't process unicode characters here */
ea4a5a8
! 	if (!IS_SPECIAL(key_char))
ea4a5a8
! 	{
ea4a5a8
! 	    /* Following code to simplify and consolidate vimModifiers
ea4a5a8
! 	     * taken liberally from gui_w48.c */
ea4a5a8
! 	    key_char = simplify_key(key_char, (int *)&vimModifiers);
ea4a5a8
! 
ea4a5a8
! 	    /* Interpret META, include SHIFT, etc. */
ea4a5a8
! 	    key_char = extract_modifiers(key_char, (int *)&vimModifiers);
ea4a5a8
! 	    if (key_char == CSI)
ea4a5a8
! 		key_char = K_CSI;
ea4a5a8
! 
ea4a5a8
! 	    if (IS_SPECIAL(key_char))
ea4a5a8
! 		isSpecial = TRUE;
ea4a5a8
! 	}
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      if (vimModifiers)
ea4a5a8
      {
ea4a5a8
! 	result[len++] = CSI;
ea4a5a8
! 	result[len++] = KS_MODIFIER;
ea4a5a8
! 	result[len++] = vimModifiers;
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      if (isSpecial && IS_SPECIAL(key_char))
ea4a5a8
      {
ea4a5a8
! 	result[len++] = CSI;
ea4a5a8
! 	result[len++] = K_SECOND(key_char);
ea4a5a8
! 	result[len++] = K_THIRD(key_char);
ea4a5a8
      }
ea4a5a8
      else
ea4a5a8
      {
ea4a5a8
! 	encLen = actualSize;
ea4a5a8
! 	to = mac_utf16_to_enc(text, actualSize, &encLen);
ea4a5a8
! 	if (to)
ea4a5a8
! 	{
ea4a5a8
! 	    /* This is basically add_to_input_buf_csi() */
ea4a5a8
! 	    for (i = 0; i < encLen && len < (INLINE_KEY_BUFFER_SIZE-1); ++i)
ea4a5a8
! 	    {
ea4a5a8
! 		result[len++] = to[i];
ea4a5a8
! 		if (to[i] == CSI)
ea4a5a8
! 		{
ea4a5a8
! 		    result[len++] = KS_EXTRA;
ea4a5a8
! 		    result[len++] = (int)KE_CSI;
ea4a5a8
! 		}
ea4a5a8
! 	    }
ea4a5a8
! 	    vim_free(to);
ea4a5a8
! 	}
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      add_to_input_buf(result, len);
ea4a5a8
***************
ea4a5a8
*** 2135,2144 ****
ea4a5a8
      vim_free(text);
ea4a5a8
      if (err == noErr)
ea4a5a8
      {
ea4a5a8
!         /* Fake event to wake up WNE (required to get
ea4a5a8
!          * key repeat working */
ea4a5a8
!         PostEvent(keyUp, 0);
ea4a5a8
!         return noErr;
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      return eventNotHandledErr;
ea4a5a8
--- 2245,2254 ----
ea4a5a8
      vim_free(text);
ea4a5a8
      if (err == noErr)
ea4a5a8
      {
ea4a5a8
! 	/* Fake event to wake up WNE (required to get
ea4a5a8
! 	 * key repeat working */
ea4a5a8
! 	PostEvent(keyUp, 0);
ea4a5a8
! 	return noErr;
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      return eventNotHandledErr;
ea4a5a8
***************
ea4a5a8
*** 2334,2340 ****
ea4a5a8
      /* prevent that the vim window size changes if it's activated by a
ea4a5a8
         click into the tab pane */
ea4a5a8
      if (whichWindow == drawer)
ea4a5a8
!         return;
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
      switch (thePart)
ea4a5a8
--- 2444,2450 ----
ea4a5a8
      /* prevent that the vim window size changes if it's activated by a
ea4a5a8
         click into the tab pane */
ea4a5a8
      if (whichWindow == drawer)
ea4a5a8
! 	return;
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
      switch (thePart)
ea4a5a8
***************
ea4a5a8
*** 2569,2579 ****
ea4a5a8
      if (IsShowContextualMenuClick(event))
ea4a5a8
      {
ea4a5a8
  # if 0
ea4a5a8
!         gui_mac_handle_contextual_menu(event);
ea4a5a8
  # else
ea4a5a8
!         gui_mac_doMouseDownEvent(event);
ea4a5a8
  # endif
ea4a5a8
!         return;
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      /* Handle normal event */
ea4a5a8
--- 2679,2689 ----
ea4a5a8
      if (IsShowContextualMenuClick(event))
ea4a5a8
      {
ea4a5a8
  # if 0
ea4a5a8
! 	gui_mac_handle_contextual_menu(event);
ea4a5a8
  # else
ea4a5a8
! 	gui_mac_doMouseDownEvent(event);
ea4a5a8
  # endif
ea4a5a8
! 	return;
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      /* Handle normal event */
ea4a5a8
***************
ea4a5a8
*** 2832,2838 ****
ea4a5a8
  # else
ea4a5a8
      /* OSErr GetApplicationBundleFSSpec(FSSpecPtr theFSSpecPtr)
ea4a5a8
       * of TN2015
ea4a5a8
-      * This technic remove the ../Contents/MacOS/etc part
ea4a5a8
       */
ea4a5a8
      (void)GetCurrentProcess(&psn;;
ea4a5a8
      /* if (err != noErr) return err; */
ea4a5a8
--- 2942,2947 ----
ea4a5a8
***************
ea4a5a8
*** 2933,2942 ****
ea4a5a8
      /* TODO: Move most of this stuff toward gui_mch_init */
ea4a5a8
      Rect	windRect;
ea4a5a8
      MenuHandle	pomme;
ea4a5a8
-     EventTypeSpec   eventTypeSpec;
ea4a5a8
      EventHandlerRef mouseWheelHandlerRef;
ea4a5a8
  #ifdef USE_CARBONKEYHANDLER
ea4a5a8
!     EventHandlerRef keyEventHandlerRef;
ea4a5a8
  #endif
ea4a5a8
      ControlRef rootControl;
ea4a5a8
  
ea4a5a8
--- 3042,3050 ----
ea4a5a8
      /* TODO: Move most of this stuff toward gui_mch_init */
ea4a5a8
      Rect	windRect;
ea4a5a8
      MenuHandle	pomme;
ea4a5a8
      EventHandlerRef mouseWheelHandlerRef;
ea4a5a8
  #ifdef USE_CARBONKEYHANDLER
ea4a5a8
!     EventTypeSpec   eventTypeSpec;
ea4a5a8
  #endif
ea4a5a8
      ControlRef rootControl;
ea4a5a8
  
ea4a5a8
***************
ea4a5a8
*** 3042,3057 ****
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
  #ifdef USE_CARBONKEYHANDLER
ea4a5a8
!     eventTypeSpec.eventClass = kEventClassTextInput;
ea4a5a8
!     eventTypeSpec.eventKind = kEventUnicodeForKeyEvent;
ea4a5a8
!     keyEventHandlerUPP = NewEventHandlerUPP(gui_mac_doKeyEventCarbon);
ea4a5a8
!     if (noErr != InstallApplicationEventHandler(keyEventHandlerUPP, 1,
ea4a5a8
! 		&eventTypeSpec, NULL, &keyEventHandlerRef))
ea4a5a8
      {
ea4a5a8
- 	keyEventHandlerRef = NULL;
ea4a5a8
  	DisposeEventHandlerUPP(keyEventHandlerUPP);
ea4a5a8
  	keyEventHandlerUPP = NULL;
ea4a5a8
      }
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
  /*
ea4a5a8
--- 3150,3196 ----
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
  #ifdef USE_CARBONKEYHANDLER
ea4a5a8
!     InterfaceTypeList supportedServices = { kUnicodeDocument };
ea4a5a8
!     NewTSMDocument(1, supportedServices, &gTSMDocument, 0);
ea4a5a8
! 
ea4a5a8
!     /* We don't support inline input yet, use input window by default */
ea4a5a8
!     UseInputWindow(gTSMDocument, TRUE);
ea4a5a8
! 
ea4a5a8
!     /* Should we activate the document by default? */
ea4a5a8
!     // ActivateTSMDocument(gTSMDocument);
ea4a5a8
! 
ea4a5a8
!     EventTypeSpec textEventTypes[] = {
ea4a5a8
! 	{ kEventClassTextInput, kEventTextInputUpdateActiveInputArea },
ea4a5a8
! 	{ kEventClassTextInput, kEventTextInputUnicodeForKeyEvent },
ea4a5a8
! 	{ kEventClassTextInput, kEventTextInputPosToOffset },
ea4a5a8
! 	{ kEventClassTextInput, kEventTextInputOffsetToPos },
ea4a5a8
!     };
ea4a5a8
! 
ea4a5a8
!     keyEventHandlerUPP = NewEventHandlerUPP(gui_mac_handle_text_input);
ea4a5a8
!     if (noErr != InstallApplicationEventHandler(keyEventHandlerUPP,
ea4a5a8
! 						NR_ELEMS(textEventTypes),
ea4a5a8
! 						textEventTypes, NULL, NULL))
ea4a5a8
      {
ea4a5a8
  	DisposeEventHandlerUPP(keyEventHandlerUPP);
ea4a5a8
  	keyEventHandlerUPP = NULL;
ea4a5a8
      }
ea4a5a8
+ 
ea4a5a8
+     EventTypeSpec windowEventTypes[] = {
ea4a5a8
+ 	{ kEventClassWindow, kEventWindowActivated },
ea4a5a8
+ 	{ kEventClassWindow, kEventWindowDeactivated },
ea4a5a8
+     };
ea4a5a8
+ 
ea4a5a8
+     /* Install window event handler to support TSMDocument activate and
ea4a5a8
+      * deactivate */
ea4a5a8
+     winEventHandlerUPP = NewEventHandlerUPP(gui_mac_handle_window_activate);
ea4a5a8
+     if (noErr != InstallWindowEventHandler(gui.VimWindow,
ea4a5a8
+ 					   winEventHandlerUPP,
ea4a5a8
+ 					   NR_ELEMS(windowEventTypes),
ea4a5a8
+ 					   windowEventTypes, NULL, NULL))
ea4a5a8
+     {
ea4a5a8
+ 	DisposeEventHandlerUPP(winEventHandlerUPP);
ea4a5a8
+ 	winEventHandlerUPP = NULL;
ea4a5a8
+     }
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
  /*
ea4a5a8
***************
ea4a5a8
*** 3107,3112 ****
ea4a5a8
--- 3246,3264 ----
ea4a5a8
      return OK;
ea4a5a8
  }
ea4a5a8
  
ea4a5a8
+ #ifdef USE_ATSUI_DRAWING
ea4a5a8
+     static void
ea4a5a8
+ gui_mac_dispose_atsui_style(void)
ea4a5a8
+ {
ea4a5a8
+     if (p_macatsui && gFontStyle)
ea4a5a8
+ 	ATSUDisposeStyle(gFontStyle);
ea4a5a8
+ #ifdef FEAT_MBYTE
ea4a5a8
+     if (p_macatsui && gWideFontStyle)
ea4a5a8
+ 	ATSUDisposeStyle(gWideFontStyle);
ea4a5a8
+ #endif
ea4a5a8
+ }
ea4a5a8
+ #endif
ea4a5a8
+ 
ea4a5a8
      void
ea4a5a8
  gui_mch_exit(int rc)
ea4a5a8
  {
ea4a5a8
***************
ea4a5a8
*** 3122,3129 ****
ea4a5a8
  	DisposeEventHandlerUPP(mouseWheelHandlerUPP);
ea4a5a8
  
ea4a5a8
  #ifdef USE_ATSUI_DRAWING
ea4a5a8
!     if (p_macatsui && gFontStyle)
ea4a5a8
! 	ATSUDisposeStyle(gFontStyle);
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
      /* Exit to shell? */
ea4a5a8
--- 3274,3286 ----
ea4a5a8
  	DisposeEventHandlerUPP(mouseWheelHandlerUPP);
ea4a5a8
  
ea4a5a8
  #ifdef USE_ATSUI_DRAWING
ea4a5a8
!     gui_mac_dispose_atsui_style();
ea4a5a8
! #endif
ea4a5a8
! 
ea4a5a8
! #ifdef USE_CARBONKEYHANDLER
ea4a5a8
!     FixTSMDocument(gTSMDocument);
ea4a5a8
!     DeactivateTSMDocument(gTSMDocument);
ea4a5a8
!     DeleteTSMDocument(gTSMDocument);
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
      /* Exit to shell? */
ea4a5a8
***************
ea4a5a8
*** 3263,3268 ****
ea4a5a8
--- 3420,3445 ----
ea4a5a8
      return selected_font;
ea4a5a8
  }
ea4a5a8
  
ea4a5a8
+ #ifdef USE_ATSUI_DRAWING
ea4a5a8
+     static void
ea4a5a8
+ gui_mac_create_atsui_style(void)
ea4a5a8
+ {
ea4a5a8
+     if (p_macatsui && gFontStyle == NULL)
ea4a5a8
+     {
ea4a5a8
+ 	if (ATSUCreateStyle(&gFontStyle) != noErr)
ea4a5a8
+ 	    gFontStyle = NULL;
ea4a5a8
+     }
ea4a5a8
+ #ifdef FEAT_MBYTE
ea4a5a8
+     if (p_macatsui && gWideFontStyle == NULL)
ea4a5a8
+     {
ea4a5a8
+ 	if (ATSUCreateStyle(&gWideFontStyle) != noErr)
ea4a5a8
+ 	    gWideFontStyle = NULL;
ea4a5a8
+     }
ea4a5a8
+ #endif
ea4a5a8
+ 
ea4a5a8
+     p_macatsui_last = p_macatsui;
ea4a5a8
+ }
ea4a5a8
+ #endif
ea4a5a8
  
ea4a5a8
  /*
ea4a5a8
   * Initialise vim to use the font with the given name.	Return FAIL if the font
ea4a5a8
***************
ea4a5a8
*** 3280,3290 ****
ea4a5a8
      char_u	used_font_name[512];
ea4a5a8
  
ea4a5a8
  #ifdef USE_ATSUI_DRAWING
ea4a5a8
!     if (p_macatsui && gFontStyle == NULL)
ea4a5a8
!     {
ea4a5a8
! 	if (ATSUCreateStyle(&gFontStyle) != noErr)
ea4a5a8
! 	    gFontStyle = NULL;
ea4a5a8
!     }
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
      if (font_name == NULL)
ea4a5a8
--- 3457,3463 ----
ea4a5a8
      char_u	used_font_name[512];
ea4a5a8
  
ea4a5a8
  #ifdef USE_ATSUI_DRAWING
ea4a5a8
!     gui_mac_create_atsui_style();
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
      if (font_name == NULL)
ea4a5a8
***************
ea4a5a8
*** 3348,3396 ****
ea4a5a8
      gui.char_height = font_info.ascent + font_info.descent + p_linespace;
ea4a5a8
  
ea4a5a8
  #ifdef USE_ATSUI_DRAWING
ea4a5a8
-     ATSUFontID			fontID;
ea4a5a8
-     Fixed			fontSize;
ea4a5a8
-     ATSStyleRenderingOptions	fontOptions;
ea4a5a8
- 
ea4a5a8
      if (p_macatsui && gFontStyle)
ea4a5a8
!     {
ea4a5a8
! 	fontID = font & 0xFFFF;
ea4a5a8
! 	fontSize = Long2Fix(font >> 16);
ea4a5a8
! 
ea4a5a8
! 	/* No antialiasing by default (do not attempt to touch antialising
ea4a5a8
! 	 * options on pre-Jaguar) */
ea4a5a8
! 	fontOptions =
ea4a5a8
! 	    (gMacSystemVersion >= 0x1020) ?
ea4a5a8
! 	    kATSStyleNoAntiAliasing :
ea4a5a8
! 	    kATSStyleNoOptions;
ea4a5a8
! 
ea4a5a8
! 	ATSUAttributeTag attribTags[] =
ea4a5a8
! 	{
ea4a5a8
! 	    kATSUFontTag, kATSUSizeTag, kATSUStyleRenderingOptionsTag,
ea4a5a8
! 	    kATSUMaxATSUITagValue+1
ea4a5a8
! 	};
ea4a5a8
! 	ByteCount attribSizes[] =
ea4a5a8
! 	{
ea4a5a8
! 	    sizeof(ATSUFontID), sizeof(Fixed),
ea4a5a8
! 	    sizeof(ATSStyleRenderingOptions), sizeof font
ea4a5a8
! 	};
ea4a5a8
! 	ATSUAttributeValuePtr attribValues[] =
ea4a5a8
! 	{
ea4a5a8
! 	    &fontID, &fontSize, &fontOptions, &font
ea4a5a8
! 	};
ea4a5a8
! 
ea4a5a8
! 	/* Convert font id to ATSUFontID */
ea4a5a8
! 	if (FMGetFontFromFontFamilyInstance(fontID, 0, &fontID, NULL) == noErr)
ea4a5a8
! 	{
ea4a5a8
! 	    if (ATSUSetAttributes(gFontStyle,
ea4a5a8
! 			(sizeof attribTags)/sizeof(ATSUAttributeTag),
ea4a5a8
! 			attribTags, attribSizes, attribValues) != noErr)
ea4a5a8
! 	    {
ea4a5a8
! 		ATSUDisposeStyle(gFontStyle);
ea4a5a8
! 		gFontStyle = NULL;
ea4a5a8
! 	    }
ea4a5a8
! 	}
ea4a5a8
!     }
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
      return OK;
ea4a5a8
--- 3521,3528 ----
ea4a5a8
      gui.char_height = font_info.ascent + font_info.descent + p_linespace;
ea4a5a8
  
ea4a5a8
  #ifdef USE_ATSUI_DRAWING
ea4a5a8
      if (p_macatsui && gFontStyle)
ea4a5a8
! 	gui_mac_set_font_attributes(font);
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
      return OK;
ea4a5a8
***************
ea4a5a8
*** 3447,3452 ****
ea4a5a8
--- 3579,3646 ----
ea4a5a8
  }
ea4a5a8
  #endif
ea4a5a8
  
ea4a5a8
+ #ifdef USE_ATSUI_DRAWING
ea4a5a8
+     static void
ea4a5a8
+ gui_mac_set_font_attributes(GuiFont font)
ea4a5a8
+ {
ea4a5a8
+     ATSUFontID	fontID;
ea4a5a8
+     Fixed	fontSize;
ea4a5a8
+     Fixed	fontWidth;
ea4a5a8
+ 
ea4a5a8
+     fontID    = font & 0xFFFF;
ea4a5a8
+     fontSize  = Long2Fix(font >> 16);
ea4a5a8
+     fontWidth = Long2Fix(gui.char_width);
ea4a5a8
+ 
ea4a5a8
+     ATSUAttributeTag attribTags[] =
ea4a5a8
+     {
ea4a5a8
+ 	kATSUFontTag, kATSUSizeTag, kATSUImposeWidthTag,
ea4a5a8
+ 	kATSUMaxATSUITagValue + 1
ea4a5a8
+     };
ea4a5a8
+ 
ea4a5a8
+     ByteCount attribSizes[] =
ea4a5a8
+     {
ea4a5a8
+ 	sizeof(ATSUFontID), sizeof(Fixed), sizeof(fontWidth),
ea4a5a8
+ 	sizeof(font)
ea4a5a8
+     };
ea4a5a8
+ 
ea4a5a8
+     ATSUAttributeValuePtr attribValues[] =
ea4a5a8
+     {
ea4a5a8
+ 	&fontID, &fontSize, &fontWidth, &font
ea4a5a8
+     };
ea4a5a8
+ 
ea4a5a8
+     if (FMGetFontFromFontFamilyInstance(fontID, 0, &fontID, NULL) == noErr)
ea4a5a8
+     {
ea4a5a8
+ 	if (ATSUSetAttributes(gFontStyle,
ea4a5a8
+ 		    (sizeof attribTags) / sizeof(ATSUAttributeTag),
ea4a5a8
+ 		    attribTags, attribSizes, attribValues) != noErr)
ea4a5a8
+ 	{
ea4a5a8
+ # ifndef NDEBUG
ea4a5a8
+ 	    fprintf(stderr, "couldn't set font style\n");
ea4a5a8
+ # endif
ea4a5a8
+ 	    ATSUDisposeStyle(gFontStyle);
ea4a5a8
+ 	    gFontStyle = NULL;
ea4a5a8
+ 	}
ea4a5a8
+ 
ea4a5a8
+ #ifdef FEAT_MBYTE
ea4a5a8
+ 	if (has_mbyte)
ea4a5a8
+ 	{
ea4a5a8
+ 	    /* FIXME: we should use a more mbyte sensitive way to support
ea4a5a8
+ 	     * wide font drawing */
ea4a5a8
+ 	    fontWidth = Long2Fix(gui.char_width * 2);
ea4a5a8
+ 
ea4a5a8
+ 	    if (ATSUSetAttributes(gWideFontStyle,
ea4a5a8
+ 			(sizeof attribTags) / sizeof(ATSUAttributeTag),
ea4a5a8
+ 			attribTags, attribSizes, attribValues) != noErr)
ea4a5a8
+ 	    {
ea4a5a8
+ 		ATSUDisposeStyle(gWideFontStyle);
ea4a5a8
+ 		gWideFontStyle = NULL;
ea4a5a8
+ 	    }
ea4a5a8
+ 	}
ea4a5a8
+ #endif
ea4a5a8
+     }
ea4a5a8
+ }
ea4a5a8
+ #endif
ea4a5a8
+ 
ea4a5a8
  /*
ea4a5a8
   * Set the current text font.
ea4a5a8
   */
ea4a5a8
***************
ea4a5a8
*** 3456,3518 ****
ea4a5a8
  #ifdef USE_ATSUI_DRAWING
ea4a5a8
      GuiFont			currFont;
ea4a5a8
      ByteCount			actualFontByteCount;
ea4a5a8
-     ATSUFontID			fontID;
ea4a5a8
-     Fixed			fontSize;
ea4a5a8
-     ATSStyleRenderingOptions	fontOptions;
ea4a5a8
  
ea4a5a8
      if (p_macatsui && gFontStyle)
ea4a5a8
      {
ea4a5a8
  	/* Avoid setting same font again */
ea4a5a8
! 	if (ATSUGetAttribute(gFontStyle, kATSUMaxATSUITagValue+1, sizeof font,
ea4a5a8
! 		    &currFont, &actualFontByteCount) == noErr &&
ea4a5a8
! 		actualFontByteCount == (sizeof font))
ea4a5a8
  	{
ea4a5a8
  	    if (currFont == font)
ea4a5a8
  		return;
ea4a5a8
  	}
ea4a5a8
  
ea4a5a8
! 	fontID = font & 0xFFFF;
ea4a5a8
! 	fontSize = Long2Fix(font >> 16);
ea4a5a8
! 	/* Respect p_antialias setting only for wide font.
ea4a5a8
! 	 * The reason for doing this at the moment is a bit complicated,
ea4a5a8
! 	 * but it's mainly because a) latin (non-wide) aliased fonts
ea4a5a8
! 	 * look bad in OS X 10.3.x and below (due to a bug in ATS), and
ea4a5a8
! 	 * b) wide multibyte input does not suffer from that problem. */
ea4a5a8
! 	/*fontOptions =
ea4a5a8
! 	    (p_antialias && (font == gui.wide_font)) ?
ea4a5a8
! 	    kATSStyleNoOptions : kATSStyleNoAntiAliasing;
ea4a5a8
! 	*/
ea4a5a8
! 	/*fontOptions = kATSStyleAntiAliasing;*/
ea4a5a8
! 
ea4a5a8
! 	ATSUAttributeTag attribTags[] =
ea4a5a8
! 	{
ea4a5a8
! 	    kATSUFontTag, kATSUSizeTag, kATSUStyleRenderingOptionsTag,
ea4a5a8
! 	    kATSUMaxATSUITagValue+1
ea4a5a8
! 	};
ea4a5a8
! 	ByteCount attribSizes[] =
ea4a5a8
! 	{
ea4a5a8
! 	    sizeof(ATSUFontID), sizeof(Fixed),
ea4a5a8
! 	    sizeof(ATSStyleRenderingOptions), sizeof font
ea4a5a8
! 	};
ea4a5a8
! 	ATSUAttributeValuePtr attribValues[] =
ea4a5a8
! 	{
ea4a5a8
! 	    &fontID, &fontSize, &fontOptions, &font
ea4a5a8
! 	};
ea4a5a8
! 
ea4a5a8
! 	if (FMGetFontFromFontFamilyInstance(fontID, 0, &fontID, NULL) == noErr)
ea4a5a8
! 	{
ea4a5a8
! 	    if (ATSUSetAttributes(gFontStyle,
ea4a5a8
! 			(sizeof attribTags)/sizeof(ATSUAttributeTag),
ea4a5a8
! 			attribTags, attribSizes, attribValues) != noErr)
ea4a5a8
! 	    {
ea4a5a8
! # ifndef NDEBUG
ea4a5a8
! 		fprintf(stderr, "couldn't set font style\n");
ea4a5a8
! # endif
ea4a5a8
! 		ATSUDisposeStyle(gFontStyle);
ea4a5a8
! 		gFontStyle = NULL;
ea4a5a8
! 	    }
ea4a5a8
! 	}
ea4a5a8
! 
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      if (p_macatsui && !gIsFontFallbackSet)
ea4a5a8
--- 3650,3668 ----
ea4a5a8
  #ifdef USE_ATSUI_DRAWING
ea4a5a8
      GuiFont			currFont;
ea4a5a8
      ByteCount			actualFontByteCount;
ea4a5a8
  
ea4a5a8
      if (p_macatsui && gFontStyle)
ea4a5a8
      {
ea4a5a8
  	/* Avoid setting same font again */
ea4a5a8
! 	if (ATSUGetAttribute(gFontStyle, kATSUMaxATSUITagValue + 1,
ea4a5a8
! 		    sizeof(font), &currFont, &actualFontByteCount) == noErr
ea4a5a8
! 		&& actualFontByteCount == (sizeof font))
ea4a5a8
  	{
ea4a5a8
  	    if (currFont == font)
ea4a5a8
  		return;
ea4a5a8
  	}
ea4a5a8
  
ea4a5a8
! 	gui_mac_set_font_attributes(font);
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      if (p_macatsui && !gIsFontFallbackSet)
ea4a5a8
***************
ea4a5a8
*** 3536,3542 ****
ea4a5a8
  			&fallbackFonts,
ea4a5a8
  			NULL) == noErr)
ea4a5a8
  	    {
ea4a5a8
! 		ATSUSetFontFallbacks((sizeof fallbackFonts)/sizeof(ATSUFontID), &fallbackFonts, kATSUSequentialFallbacksPreferred);
ea4a5a8
  	    }
ea4a5a8
  /*
ea4a5a8
  	ATSUAttributeValuePtr fallbackValues[] = { };
ea4a5a8
--- 3686,3694 ----
ea4a5a8
  			&fallbackFonts,
ea4a5a8
  			NULL) == noErr)
ea4a5a8
  	    {
ea4a5a8
! 		ATSUSetFontFallbacks((sizeof fallbackFonts)/sizeof(ATSUFontID),
ea4a5a8
! 				     &fallbackFonts,
ea4a5a8
! 				     kATSUSequentialFallbacksPreferred);
ea4a5a8
  	    }
ea4a5a8
  /*
ea4a5a8
  	ATSUAttributeValuePtr fallbackValues[] = { };
ea4a5a8
***************
ea4a5a8
*** 3921,3927 ****
ea4a5a8
  
ea4a5a8
      /* - ATSUI automatically antialiases text (Someone)
ea4a5a8
       * - for some reason it does not work... (Jussi) */
ea4a5a8
! 
ea4a5a8
      /*
ea4a5a8
       * When antialiasing we're using srcOr mode, we have to clear the block
ea4a5a8
       * before drawing the text.
ea4a5a8
--- 4073,4082 ----
ea4a5a8
  
ea4a5a8
      /* - ATSUI automatically antialiases text (Someone)
ea4a5a8
       * - for some reason it does not work... (Jussi) */
ea4a5a8
! #ifdef MAC_ATSUI_DEBUG
ea4a5a8
!     fprintf(stderr, "row = %d, col = %d, len = %d: '%c'\n",
ea4a5a8
! 	    row, col, len, len == 1 ? s[0] : ' ');
ea4a5a8
! #endif
ea4a5a8
      /*
ea4a5a8
       * When antialiasing we're using srcOr mode, we have to clear the block
ea4a5a8
       * before drawing the text.
ea4a5a8
***************
ea4a5a8
*** 3956,3990 ****
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      {
ea4a5a8
- 	/* Use old-style, non-antialiased QuickDraw text rendering. */
ea4a5a8
  	TextMode(srcCopy);
ea4a5a8
  	TextFace(normal);
ea4a5a8
  
ea4a5a8
!     /*  SelectFont(hdc, gui.currFont); */
ea4a5a8
! 
ea4a5a8
  	if (flags & DRAW_TRANSP)
ea4a5a8
  	{
ea4a5a8
  	    TextMode(srcOr);
ea4a5a8
  	}
ea4a5a8
  
ea4a5a8
  	MoveTo(TEXT_X(col), TEXT_Y(row));
ea4a5a8
- 	ATSUTextLayout textLayout;
ea4a5a8
  
ea4a5a8
! 	if (ATSUCreateTextLayoutWithTextPtr(tofree,
ea4a5a8
! 		    kATSUFromTextBeginning, kATSUToTextEnd,
ea4a5a8
! 		    utf16_len,
ea4a5a8
! 		    (gFontStyle ? 1 : 0), &utf16_len,
ea4a5a8
! 		    (gFontStyle ? &gFontStyle : NULL),
ea4a5a8
! 		    &textLayout) == noErr)
ea4a5a8
  	{
ea4a5a8
! 	    ATSUSetTransientFontMatching(textLayout, TRUE);
ea4a5a8
  
ea4a5a8
! 	    ATSUDrawText(textLayout,
ea4a5a8
! 		    kATSUFromTextBeginning, kATSUToTextEnd,
ea4a5a8
! 		    kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
ea4a5a8
  
ea4a5a8
  	    ATSUDisposeTextLayout(textLayout);
ea4a5a8
  	}
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      if (flags & DRAW_UNDERC)
ea4a5a8
--- 4111,4232 ----
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      {
ea4a5a8
  	TextMode(srcCopy);
ea4a5a8
  	TextFace(normal);
ea4a5a8
  
ea4a5a8
! 	/*  SelectFont(hdc, gui.currFont); */
ea4a5a8
  	if (flags & DRAW_TRANSP)
ea4a5a8
  	{
ea4a5a8
  	    TextMode(srcOr);
ea4a5a8
  	}
ea4a5a8
  
ea4a5a8
  	MoveTo(TEXT_X(col), TEXT_Y(row));
ea4a5a8
  
ea4a5a8
! 	if (gFontStyle && flags & DRAW_BOLD)
ea4a5a8
  	{
ea4a5a8
! 	    Boolean attValue = true;
ea4a5a8
! 	    ATSUAttributeTag attribTags[] = { kATSUQDBoldfaceTag };
ea4a5a8
! 	    ByteCount attribSizes[] = { sizeof(Boolean) };
ea4a5a8
! 	    ATSUAttributeValuePtr attribValues[] = { &attValue };
ea4a5a8
  
ea4a5a8
! 	    ATSUSetAttributes(gFontStyle, 1, attribTags, attribSizes, attribValues);
ea4a5a8
! 	}
ea4a5a8
! 
ea4a5a8
! #ifdef FEAT_MBYTE
ea4a5a8
! 	if (has_mbyte)
ea4a5a8
! 	{
ea4a5a8
! 	    int n, width_in_cell, last_width_in_cell;
ea4a5a8
! 	    UniCharArrayOffset offset = 0;
ea4a5a8
! 	    UniCharCount yet_to_draw = 0;
ea4a5a8
! 	    ATSUTextLayout textLayout;
ea4a5a8
! 	    ATSUStyle      textStyle;
ea4a5a8
! 
ea4a5a8
! 	    last_width_in_cell = 1;
ea4a5a8
! 	    ATSUCreateTextLayout(&textLayout);
ea4a5a8
! 	    ATSUSetTextPointerLocation(textLayout, tofree,
ea4a5a8
! 				       kATSUFromTextBeginning,
ea4a5a8
! 				       kATSUToTextEnd, utf16_len);
ea4a5a8
! 	    /*
ea4a5a8
! 	       ATSUSetRunStyle(textLayout, gFontStyle,
ea4a5a8
! 	       kATSUFromTextBeginning, kATSUToTextEnd); */
ea4a5a8
! 
ea4a5a8
! 	    /* Compute the length in display cells. */
ea4a5a8
! 	    for (n = 0; n < len; n += MB_BYTE2LEN(s[n]))
ea4a5a8
! 	    {
ea4a5a8
! 		width_in_cell = (*mb_ptr2cells)(s + n);
ea4a5a8
! 
ea4a5a8
! 		/* probably we are switching from single byte character
ea4a5a8
! 		 * to multibyte characters (which requires more than one
ea4a5a8
! 		 * cell to draw) */
ea4a5a8
! 		if (width_in_cell != last_width_in_cell)
ea4a5a8
! 		{
ea4a5a8
! #ifdef MAC_ATSUI_DEBUG
ea4a5a8
! 		    fprintf(stderr, "\tn = %2d, (%d-%d), offset = %d, yet_to_draw = %d\n",
ea4a5a8
! 			    n, last_width_in_cell, width_in_cell, offset, yet_to_draw);
ea4a5a8
! #endif
ea4a5a8
! 		    textStyle = last_width_in_cell > 1 ? gWideFontStyle
ea4a5a8
! 								 : gFontStyle;
ea4a5a8
! 
ea4a5a8
! 		    ATSUSetRunStyle(textLayout, textStyle, offset, yet_to_draw);
ea4a5a8
! 		    offset += yet_to_draw;
ea4a5a8
! 		    yet_to_draw = 0;
ea4a5a8
! 		    last_width_in_cell = width_in_cell;
ea4a5a8
! 		}
ea4a5a8
  
ea4a5a8
+ 		yet_to_draw++;
ea4a5a8
+ 	    }
ea4a5a8
+ 
ea4a5a8
+ 	    if (yet_to_draw)
ea4a5a8
+ 	    {
ea4a5a8
+ #ifdef MAC_ATSUI_DEBUG
ea4a5a8
+ 		fprintf(stderr, "\tn = %2d, (%d-%d), offset = %d, yet_to_draw = %d\n",
ea4a5a8
+ 			n, last_width_in_cell, width_in_cell, offset, yet_to_draw);
ea4a5a8
+ #endif
ea4a5a8
+ 		/* finish the rest style */
ea4a5a8
+ 		textStyle = width_in_cell > 1 ? gWideFontStyle : gFontStyle;
ea4a5a8
+ 		ATSUSetRunStyle(textLayout, textStyle, offset, kATSUToTextEnd);
ea4a5a8
+ 	    }
ea4a5a8
+ 
ea4a5a8
+ 	    ATSUSetTransientFontMatching(textLayout, TRUE);
ea4a5a8
+ 	    ATSUDrawText(textLayout,
ea4a5a8
+ 			 kATSUFromTextBeginning, kATSUToTextEnd,
ea4a5a8
+ 			 kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
ea4a5a8
  	    ATSUDisposeTextLayout(textLayout);
ea4a5a8
  	}
ea4a5a8
+ 	else
ea4a5a8
+ #endif
ea4a5a8
+ 	{
ea4a5a8
+ 	    ATSUTextLayout textLayout;
ea4a5a8
+ 
ea4a5a8
+ 	    if (ATSUCreateTextLayoutWithTextPtr(tofree,
ea4a5a8
+ 			kATSUFromTextBeginning, kATSUToTextEnd,
ea4a5a8
+ 			utf16_len,
ea4a5a8
+ 			(gFontStyle ? 1 : 0), &utf16_len,
ea4a5a8
+ 			(gFontStyle ? &gFontStyle : NULL),
ea4a5a8
+ 			&textLayout) == noErr)
ea4a5a8
+ 	    {
ea4a5a8
+ 		ATSUSetTransientFontMatching(textLayout, TRUE);
ea4a5a8
+ 
ea4a5a8
+ 		ATSUDrawText(textLayout,
ea4a5a8
+ 			kATSUFromTextBeginning, kATSUToTextEnd,
ea4a5a8
+ 			kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
ea4a5a8
+ 
ea4a5a8
+ 		ATSUDisposeTextLayout(textLayout);
ea4a5a8
+ 	    }
ea4a5a8
+ 	}
ea4a5a8
+ 
ea4a5a8
+ 	/* drawing is done, now reset bold to normal */
ea4a5a8
+ 	if (gFontStyle && flags & DRAW_BOLD)
ea4a5a8
+ 	{
ea4a5a8
+ 	    Boolean attValue = false;
ea4a5a8
+ 
ea4a5a8
+ 	    ATSUAttributeTag attribTags[] = { kATSUQDBoldfaceTag };
ea4a5a8
+ 	    ByteCount attribSizes[] = { sizeof(Boolean) };
ea4a5a8
+ 	    ATSUAttributeValuePtr attribValues[] = { &attValue };
ea4a5a8
+ 
ea4a5a8
+ 	    ATSUSetAttributes(gFontStyle, 1, attribTags, attribSizes,
ea4a5a8
+ 								attribValues);
ea4a5a8
+ 	}
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      if (flags & DRAW_UNDERC)
ea4a5a8
***************
ea4a5a8
*** 3998,4003 ****
ea4a5a8
--- 4240,4252 ----
ea4a5a8
  gui_mch_draw_string(int row, int col, char_u *s, int len, int flags)
ea4a5a8
  {
ea4a5a8
  #if defined(USE_ATSUI_DRAWING)
ea4a5a8
+     if (p_macatsui == 0 && p_macatsui_last != 0)
ea4a5a8
+ 	/* switch from macatsui to nomacatsui */
ea4a5a8
+ 	gui_mac_dispose_atsui_style();
ea4a5a8
+     else if (p_macatsui != 0 && p_macatsui_last == 0)
ea4a5a8
+ 	/* switch from nomacatsui to macatsui */
ea4a5a8
+ 	gui_mac_create_atsui_style();
ea4a5a8
+ 
ea4a5a8
      if (p_macatsui)
ea4a5a8
  	draw_string_ATSUI(row, col, s, len, flags);
ea4a5a8
      else
ea4a5a8
***************
ea4a5a8
*** 4228,4239 ****
ea4a5a8
  	 */
ea4a5a8
  	/* TODO: reduce wtime accordinly???  */
ea4a5a8
  	if (wtime > -1)
ea4a5a8
! 	    sleeppyTick = 60*wtime/1000;
ea4a5a8
  	else
ea4a5a8
  	    sleeppyTick = 32767;
ea4a5a8
  	if (WaitNextEventWrp(mask, &event, sleeppyTick, dragRgn))
ea4a5a8
  	{
ea4a5a8
! 		gui_mac_handle_event(&event);
ea4a5a8
  	    if (input_available())
ea4a5a8
  	    {
ea4a5a8
  		allow_scrollbar = FALSE;
ea4a5a8
--- 4477,4489 ----
ea4a5a8
  	 */
ea4a5a8
  	/* TODO: reduce wtime accordinly???  */
ea4a5a8
  	if (wtime > -1)
ea4a5a8
! 	    sleeppyTick = 60 * wtime / 1000;
ea4a5a8
  	else
ea4a5a8
  	    sleeppyTick = 32767;
ea4a5a8
+ 
ea4a5a8
  	if (WaitNextEventWrp(mask, &event, sleeppyTick, dragRgn))
ea4a5a8
  	{
ea4a5a8
! 	    gui_mac_handle_event(&event);
ea4a5a8
  	    if (input_available())
ea4a5a8
  	    {
ea4a5a8
  		allow_scrollbar = FALSE;
ea4a5a8
***************
ea4a5a8
*** 6031,6037 ****
ea4a5a8
  #endif
ea4a5a8
  }
ea4a5a8
  
ea4a5a8
! #if defined(USE_IM_CONTROL) || defined(PROTO)
ea4a5a8
  /*
ea4a5a8
   * Input Method Control functions.
ea4a5a8
   */
ea4a5a8
--- 6346,6352 ----
ea4a5a8
  #endif
ea4a5a8
  }
ea4a5a8
  
ea4a5a8
! #if (defined(USE_IM_CONTROL) || defined(PROTO)) && defined(USE_CARBONKEYHANDLER)
ea4a5a8
  /*
ea4a5a8
   * Input Method Control functions.
ea4a5a8
   */
ea4a5a8
***************
ea4a5a8
*** 6042,6048 ****
ea4a5a8
--- 6357,6427 ----
ea4a5a8
      void
ea4a5a8
  im_set_position(int row, int col)
ea4a5a8
  {
ea4a5a8
+ #if 0
ea4a5a8
      /* TODO: Implement me! */
ea4a5a8
+     im_start_row = row;
ea4a5a8
+     im_start_col = col;
ea4a5a8
+ #endif
ea4a5a8
+ }
ea4a5a8
+ 
ea4a5a8
+ static ScriptLanguageRecord gTSLWindow;
ea4a5a8
+ static ScriptLanguageRecord gTSLInsert;
ea4a5a8
+ static ScriptLanguageRecord gTSLDefault = { 0, 0 };
ea4a5a8
+ 
ea4a5a8
+ static Component	     gTSCWindow;
ea4a5a8
+ static Component	     gTSCInsert;
ea4a5a8
+ static Component	     gTSCDefault;
ea4a5a8
+ 
ea4a5a8
+ static int		     im_initialized = 0;
ea4a5a8
+ 
ea4a5a8
+     static void
ea4a5a8
+ im_on_window_switch(int active)
ea4a5a8
+ {
ea4a5a8
+     ScriptLanguageRecord *slptr = NULL;
ea4a5a8
+     OSStatus err;
ea4a5a8
+ 
ea4a5a8
+     if (! gui.in_use)
ea4a5a8
+ 	return;
ea4a5a8
+ 
ea4a5a8
+     if (im_initialized == 0)
ea4a5a8
+     {
ea4a5a8
+ 	im_initialized = 1;
ea4a5a8
+ 
ea4a5a8
+ 	/* save default TSM component (should be U.S.) to default */
ea4a5a8
+ 	GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault,
ea4a5a8
+ 				     kKeyboardInputMethodClass);
ea4a5a8
+     }
ea4a5a8
+ 
ea4a5a8
+     if (active == TRUE)
ea4a5a8
+     {
ea4a5a8
+ 	im_is_active = TRUE;
ea4a5a8
+ 	ActivateTSMDocument(gTSMDocument);
ea4a5a8
+ 	slptr = &gTSLWindow;
ea4a5a8
+ 
ea4a5a8
+ 	if (slptr)
ea4a5a8
+ 	{
ea4a5a8
+ 	    err = SetDefaultInputMethodOfClass(gTSCWindow, slptr,
ea4a5a8
+ 					       kKeyboardInputMethodClass);
ea4a5a8
+ 	    if (err == noErr)
ea4a5a8
+ 		err = SetTextServiceLanguage(slptr);
ea4a5a8
+ 
ea4a5a8
+ 	    if (err == noErr)
ea4a5a8
+ 		KeyScript(slptr->fScript | smKeyForceKeyScriptMask);
ea4a5a8
+ 	}
ea4a5a8
+     }
ea4a5a8
+     else
ea4a5a8
+     {
ea4a5a8
+ 	err = GetTextServiceLanguage(&gTSLWindow);
ea4a5a8
+ 	if (err == noErr)
ea4a5a8
+ 	    slptr = &gTSLWindow;
ea4a5a8
+ 
ea4a5a8
+ 	if (slptr)
ea4a5a8
+ 	    GetDefaultInputMethodOfClass(&gTSCWindow, slptr,
ea4a5a8
+ 					 kKeyboardInputMethodClass);
ea4a5a8
+ 
ea4a5a8
+ 	im_is_active = FALSE;
ea4a5a8
+ 	DeactivateTSMDocument(gTSMDocument);
ea4a5a8
+     }
ea4a5a8
  }
ea4a5a8
  
ea4a5a8
  /*
ea4a5a8
***************
ea4a5a8
*** 6051,6057 ****
ea4a5a8
      void
ea4a5a8
  im_set_active(int active)
ea4a5a8
  {
ea4a5a8
!     KeyScript(active ? smKeySysScript : smKeyRoman);
ea4a5a8
  }
ea4a5a8
  
ea4a5a8
  /*
ea4a5a8
--- 6430,6486 ----
ea4a5a8
      void
ea4a5a8
  im_set_active(int active)
ea4a5a8
  {
ea4a5a8
!     ScriptLanguageRecord *slptr = NULL;
ea4a5a8
!     OSStatus err;
ea4a5a8
! 
ea4a5a8
!     if (! gui.in_use)
ea4a5a8
! 	return;
ea4a5a8
! 
ea4a5a8
!     if (im_initialized == 0)
ea4a5a8
!     {
ea4a5a8
! 	im_initialized = 1;
ea4a5a8
! 
ea4a5a8
! 	/* save default TSM component (should be U.S.) to default */
ea4a5a8
! 	GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault,
ea4a5a8
! 				     kKeyboardInputMethodClass);
ea4a5a8
!     }
ea4a5a8
! 
ea4a5a8
!     if (active == TRUE)
ea4a5a8
!     {
ea4a5a8
! 	im_is_active = TRUE;
ea4a5a8
! 	ActivateTSMDocument(gTSMDocument);
ea4a5a8
! 	slptr = &gTSLInsert;
ea4a5a8
! 
ea4a5a8
! 	if (slptr)
ea4a5a8
! 	{
ea4a5a8
! 	    err = SetDefaultInputMethodOfClass(gTSCInsert, slptr,
ea4a5a8
! 					       kKeyboardInputMethodClass);
ea4a5a8
! 	    if (err == noErr)
ea4a5a8
! 		err = SetTextServiceLanguage(slptr);
ea4a5a8
! 
ea4a5a8
! 	    if (err == noErr)
ea4a5a8
! 		KeyScript(slptr->fScript | smKeyForceKeyScriptMask);
ea4a5a8
! 	}
ea4a5a8
!     }
ea4a5a8
!     else
ea4a5a8
!     {
ea4a5a8
! 	err = GetTextServiceLanguage(&gTSLInsert);
ea4a5a8
! 	if (err == noErr)
ea4a5a8
! 	    slptr = &gTSLInsert;
ea4a5a8
! 
ea4a5a8
! 	if (slptr)
ea4a5a8
! 	    GetDefaultInputMethodOfClass(&gTSCInsert, slptr,
ea4a5a8
! 					 kKeyboardInputMethodClass);
ea4a5a8
! 
ea4a5a8
! 	/* restore to default when switch to normal mode, so than we could
ea4a5a8
! 	 * enter commands easier */
ea4a5a8
! 	SetDefaultInputMethodOfClass(gTSCDefault, &gTSLDefault,
ea4a5a8
! 				     kKeyboardInputMethodClass);
ea4a5a8
! 	SetTextServiceLanguage(&gTSLDefault);
ea4a5a8
! 
ea4a5a8
! 	im_is_active = FALSE;
ea4a5a8
! 	DeactivateTSMDocument(gTSMDocument);
ea4a5a8
!     }
ea4a5a8
  }
ea4a5a8
  
ea4a5a8
  /*
ea4a5a8
***************
ea4a5a8
*** 6060,6068 ****
ea4a5a8
      int
ea4a5a8
  im_get_status(void)
ea4a5a8
  {
ea4a5a8
!     SInt32 script = GetScriptManagerVariable(smKeyScript);
ea4a5a8
!     return (script != smRoman
ea4a5a8
! 	    && script == GetScriptManagerVariable(smSysScript)) ? 1 : 0;
ea4a5a8
  }
ea4a5a8
  
ea4a5a8
  #endif /* defined(USE_IM_CONTROL) || defined(PROTO) */
ea4a5a8
--- 6489,6498 ----
ea4a5a8
      int
ea4a5a8
  im_get_status(void)
ea4a5a8
  {
ea4a5a8
!     if (! gui.in_use)
ea4a5a8
! 	return 0;
ea4a5a8
! 
ea4a5a8
!     return im_is_active;
ea4a5a8
  }
ea4a5a8
  
ea4a5a8
  #endif /* defined(USE_IM_CONTROL) || defined(PROTO) */
ea4a5a8
***************
ea4a5a8
*** 6118,6124 ****
ea4a5a8
      int		numTabs = 0;
ea4a5a8
  
ea4a5a8
      for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
ea4a5a8
!         ++numTabs;
ea4a5a8
      return numTabs;
ea4a5a8
  }
ea4a5a8
  
ea4a5a8
--- 6548,6554 ----
ea4a5a8
      int		numTabs = 0;
ea4a5a8
  
ea4a5a8
      for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
ea4a5a8
! 	++numTabs;
ea4a5a8
      return numTabs;
ea4a5a8
  }
ea4a5a8
  
ea4a5a8
***************
ea4a5a8
*** 6126,6133 ****
ea4a5a8
      static OSStatus
ea4a5a8
  dbItemDataCallback(ControlRef browser,
ea4a5a8
  	DataBrowserItemID itemID,
ea4a5a8
!         DataBrowserPropertyID property /* column id */,
ea4a5a8
!         DataBrowserItemDataRef itemData,
ea4a5a8
  	Boolean changeValue)
ea4a5a8
  {
ea4a5a8
      OSStatus status = noErr;
ea4a5a8
--- 6556,6563 ----
ea4a5a8
      static OSStatus
ea4a5a8
  dbItemDataCallback(ControlRef browser,
ea4a5a8
  	DataBrowserItemID itemID,
ea4a5a8
! 	DataBrowserPropertyID property /* column id */,
ea4a5a8
! 	DataBrowserItemDataRef itemData,
ea4a5a8
  	Boolean changeValue)
ea4a5a8
  {
ea4a5a8
      OSStatus status = noErr;
ea4a5a8
***************
ea4a5a8
*** 6170,6178 ****
ea4a5a8
      static void
ea4a5a8
  dbGetContextualMenuCallback(ControlRef browser,
ea4a5a8
  	MenuRef *menu,
ea4a5a8
!         UInt32 *helpType,
ea4a5a8
  	CFStringRef *helpItemString,
ea4a5a8
!         AEDesc *selection)
ea4a5a8
  {
ea4a5a8
      // on mac os 9: kCMHelpItemNoHelp, but it's not the same
ea4a5a8
      *helpType = kCMHelpItemRemoveHelp; // OS X only ;-)
ea4a5a8
--- 6600,6608 ----
ea4a5a8
      static void
ea4a5a8
  dbGetContextualMenuCallback(ControlRef browser,
ea4a5a8
  	MenuRef *menu,
ea4a5a8
! 	UInt32 *helpType,
ea4a5a8
  	CFStringRef *helpItemString,
ea4a5a8
! 	AEDesc *selection)
ea4a5a8
  {
ea4a5a8
      // on mac os 9: kCMHelpItemNoHelp, but it's not the same
ea4a5a8
      *helpType = kCMHelpItemRemoveHelp; // OS X only ;-)
ea4a5a8
***************
ea4a5a8
*** 6395,6403 ****
ea4a5a8
  gui_mch_show_tabline(int showit)
ea4a5a8
  {
ea4a5a8
      if (showit == 0)
ea4a5a8
!         CloseDrawer(drawer, true);
ea4a5a8
      else
ea4a5a8
!         OpenDrawer(drawer, kWindowEdgeRight, true);
ea4a5a8
  }
ea4a5a8
  
ea4a5a8
  /*
ea4a5a8
--- 6825,6833 ----
ea4a5a8
  gui_mch_show_tabline(int showit)
ea4a5a8
  {
ea4a5a8
      if (showit == 0)
ea4a5a8
! 	CloseDrawer(drawer, true);
ea4a5a8
      else
ea4a5a8
! 	OpenDrawer(drawer, kWindowEdgeRight, true);
ea4a5a8
  }
ea4a5a8
  
ea4a5a8
  /*
ea4a5a8
***************
ea4a5a8
*** 6425,6435 ****
ea4a5a8
      // adjust data browser
ea4a5a8
      if (tabLabels != NULL)
ea4a5a8
      {
ea4a5a8
!         int i;
ea4a5a8
  
ea4a5a8
!         for (i = 0; i < tabLabelsSize; ++i)
ea4a5a8
!             CFRelease(tabLabels[i]);
ea4a5a8
!         free(tabLabels);
ea4a5a8
      }
ea4a5a8
      tabLabels = (CFStringRef *)malloc(numTabs * sizeof(CFStringRef));
ea4a5a8
      tabLabelsSize = numTabs;
ea4a5a8
--- 6855,6865 ----
ea4a5a8
      // adjust data browser
ea4a5a8
      if (tabLabels != NULL)
ea4a5a8
      {
ea4a5a8
! 	int i;
ea4a5a8
  
ea4a5a8
! 	for (i = 0; i < tabLabelsSize; ++i)
ea4a5a8
! 	    CFRelease(tabLabels[i]);
ea4a5a8
! 	free(tabLabels);
ea4a5a8
      }
ea4a5a8
      tabLabels = (CFStringRef *)malloc(numTabs * sizeof(CFStringRef));
ea4a5a8
      tabLabelsSize = numTabs;
ea4a5a8
***************
ea4a5a8
*** 6438,6444 ****
ea4a5a8
      {
ea4a5a8
  	if (tp == curtab)
ea4a5a8
  	    curtabidx = nr;
ea4a5a8
!         tabLabels[nr-1] = getTabLabel(tp);
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      RemoveDataBrowserItems(dataBrowser, kDataBrowserNoItem, 0, NULL,
ea4a5a8
--- 6868,6874 ----
ea4a5a8
      {
ea4a5a8
  	if (tp == curtab)
ea4a5a8
  	    curtabidx = nr;
ea4a5a8
! 	tabLabels[nr-1] = getTabLabel(tp);
ea4a5a8
      }
ea4a5a8
  
ea4a5a8
      RemoveDataBrowserItems(dataBrowser, kDataBrowserNoItem, 0, NULL,
ea4a5a8
*** ../vim-7.1.274/src/version.c	Wed Mar 12 13:45:34 2008
ea4a5a8
--- src/version.c	Wed Mar 12 14:31:37 2008
ea4a5a8
***************
ea4a5a8
*** 668,669 ****
ea4a5a8
--- 668,671 ----
ea4a5a8
  {   /* Add new patch number below this line */
ea4a5a8
+ /**/
ea4a5a8
+     275,
ea4a5a8
  /**/
ea4a5a8
ea4a5a8
-- 
ea4a5a8
hundred-and-one symptoms of being an internet addict:
ea4a5a8
115. You are late picking up your kid from school and try to explain
ea4a5a8
     to the teacher you were stuck in Web traffic.
ea4a5a8
ea4a5a8
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
ea4a5a8
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
ea4a5a8
\\\        download, build and distribute -- http://www.A-A-P.org        ///
ea4a5a8
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///