]> git.pld-linux.org Git - packages/vim.git/blob - 7.1.275
- updated to 7.1.326
[packages/vim.git] / 7.1.275
1 To: vim-dev@vim.org
2 Subject: Patch 7.1.275
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.1.275 (extra)
11 Problem:    Mac: ATSUI and 'antialias' don't work properly together.
12 Solution:   Fix this and the input method. (Jjgod Jiang)
13 Files:      src/vim.h, src/gui_mac.c
14
15
16 *** ../vim-7.1.274/src/vim.h    Wed Feb 20 12:22:59 2008
17 --- src/vim.h   Wed Mar 12 13:18:58 2008
18 ***************
19 *** 461,468 ****
20   /*
21    * Check input method control.
22    */
23 ! #if defined(FEAT_XIM) || \
24 !     (defined(FEAT_GUI) && (defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME)))
25   # define USE_IM_CONTROL
26   #endif
27   
28 --- 461,469 ----
29   /*
30    * Check input method control.
31    */
32 ! #if defined(FEAT_XIM) \
33 !     || (defined(FEAT_GUI) && (defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME))) \
34 !     || defined(FEAT_GUI_MAC)
35   # define USE_IM_CONTROL
36   #endif
37   
38 *** ../vim-7.1.274/src/gui_mac.c        Sat Sep 29 13:15:29 2007
39 --- src/gui_mac.c       Wed Mar 12 13:40:57 2008
40 ***************
41 *** 59,65 ****
42 --- 59,91 ----
43   
44   #ifdef MACOS_CONVERT
45   # define USE_CARBONKEYHANDLER
46
47 + static int im_is_active = FALSE;
48 + #if 0
49 + static int im_start_row = 0;
50 + static int im_start_col = 0;
51 + #endif
52
53 + #define NR_ELEMS(x)   (sizeof(x) / sizeof(x[0]))
54
55 + static TSMDocumentID gTSMDocument;
56
57 + static void im_on_window_switch(int active);
58   static EventHandlerUPP keyEventHandlerUPP = NULL;
59 + static EventHandlerUPP winEventHandlerUPP = NULL;
60
61 + static pascal OSStatus gui_mac_handle_window_activate(
62 +       EventHandlerCallRef nextHandler, EventRef theEvent, void *data);
63
64 + static pascal OSStatus gui_mac_handle_text_input(
65 +       EventHandlerCallRef nextHandler, EventRef theEvent, void *data);
66
67 + static pascal OSStatus gui_mac_update_input_area(
68 +       EventHandlerCallRef nextHandler, EventRef theEvent);
69
70 + static pascal OSStatus gui_mac_unicode_key_event(
71 +       EventHandlerCallRef nextHandler, EventRef theEvent);
72
73   #endif
74   
75   
76 ***************
77 *** 137,143 ****
78 --- 166,176 ----
79   
80   #ifdef MACOS_CONVERT
81   # define USE_ATSUI_DRAWING
82 + int       p_macatsui_last;
83   ATSUStyle   gFontStyle;
84 + # ifdef FEAT_MBYTE
85 + ATSUStyle   gWideFontStyle;
86 + # endif
87   Boolean           gIsFontFallbackSet;
88   #endif
89   
90 ***************
91 *** 265,270 ****
92 --- 298,308 ----
93   static WindowRef drawer = NULL; // TODO: put into gui.h
94   #endif
95   
96 + #ifdef USE_ATSUI_DRAWING
97 + static void gui_mac_set_font_attributes(GuiFont font);
98 + static void gui_mac_dispose_atsui_style(void);
99 + #endif
100
101   /*
102    * ------------------------------------------------------------
103    * Conversion Utility
104 ***************
105 *** 1935,1946 ****
106       /* Dim scrollbars */
107       if (whichWindow == gui.VimWindow)
108       {
109 !         ControlRef rootControl;
110 !         GetRootControl(gui.VimWindow, &rootControl);
111 !         if ((event->modifiers) & activeFlag)
112 !             ActivateControl(rootControl);
113 !         else
114 !             DeactivateControl(rootControl);
115       }
116   
117       /* Activate */
118 --- 1973,1984 ----
119       /* Dim scrollbars */
120       if (whichWindow == gui.VimWindow)
121       {
122 !       ControlRef rootControl;
123 !       GetRootControl(gui.VimWindow, &rootControl);
124 !       if ((event->modifiers) & activeFlag)
125 !           ActivateControl(rootControl);
126 !       else
127 !           DeactivateControl(rootControl);
128       }
129   
130       /* Activate */
131 ***************
132 *** 1976,1990 ****
133    * Handle the key
134    */
135   #ifdef USE_CARBONKEYHANDLER
136   
137 ! static int dialog_busy = FALSE;           /* TRUE when gui_mch_dialog() wants the keys */
138   
139   # define INLINE_KEY_BUFFER_SIZE 80
140       static pascal OSStatus
141 ! gui_mac_doKeyEventCarbon(
142         EventHandlerCallRef nextHandler,
143 !       EventRef theEvent,
144 !       void *data)
145   {
146       /* Multibyte-friendly key event handler */
147       OSStatus  err = -1;
148 --- 2014,2100 ----
149    * Handle the key
150    */
151   #ifdef USE_CARBONKEYHANDLER
152 +     static pascal OSStatus
153 + gui_mac_handle_window_activate(
154 +       EventHandlerCallRef nextHandler,
155 +       EventRef            theEvent,
156 +       void                *data)
157 + {
158 +     UInt32 eventClass = GetEventClass(theEvent);
159 +     UInt32 eventKind  = GetEventKind(theEvent);
160
161 +     if (eventClass == kEventClassWindow)
162 +     {
163 +       switch (eventKind)
164 +       {
165 +           case kEventWindowActivated:
166 + #if defined(USE_IM_CONTROL)
167 +               im_on_window_switch(TRUE);
168 + #endif
169 +               return noErr;
170
171 +           case kEventWindowDeactivated:
172 + #if defined(USE_IM_CONTROL)
173 +               im_on_window_switch(FALSE);
174 + #endif
175 +               return noErr;
176 +       }
177 +     }
178
179 +     return eventNotHandledErr;
180 + }
181
182 +     static pascal OSStatus
183 + gui_mac_handle_text_input(
184 +       EventHandlerCallRef nextHandler,
185 +       EventRef            theEvent,
186 +       void                *data)
187 + {
188 +     UInt32 eventClass = GetEventClass(theEvent);
189 +     UInt32 eventKind  = GetEventKind(theEvent);
190
191 +     if (eventClass != kEventClassTextInput)
192 +       return eventNotHandledErr;
193   
194 !     if ((kEventTextInputUpdateActiveInputArea != eventKind) &&
195 !       (kEventTextInputUnicodeForKeyEvent    != eventKind) &&
196 !       (kEventTextInputOffsetToPos           != eventKind) &&
197 !       (kEventTextInputPosToOffset           != eventKind) &&
198 !       (kEventTextInputGetSelectedText       != eventKind))
199 !             return eventNotHandledErr;
200
201 !     switch (eventKind)
202 !     {
203 !     case kEventTextInputUpdateActiveInputArea:
204 !       return gui_mac_update_input_area(nextHandler, theEvent);
205 !     case kEventTextInputUnicodeForKeyEvent:
206 !       return gui_mac_unicode_key_event(nextHandler, theEvent);
207
208 !     case kEventTextInputOffsetToPos:
209 !     case kEventTextInputPosToOffset:
210 !     case kEventTextInputGetSelectedText:
211 !       break;
212 !     }
213
214 !     return eventNotHandledErr;
215 ! }
216
217 !     static pascal
218 ! OSStatus gui_mac_update_input_area(
219 !       EventHandlerCallRef nextHandler,
220 !       EventRef            theEvent)
221 ! {
222 !     return eventNotHandledErr;
223 ! }
224
225 ! static int dialog_busy = FALSE;           /* TRUE when gui_mch_dialog() wants the
226 !                                      keys */
227   
228   # define INLINE_KEY_BUFFER_SIZE 80
229       static pascal OSStatus
230 ! gui_mac_unicode_key_event(
231         EventHandlerCallRef nextHandler,
232 !       EventRef            theEvent)
233   {
234       /* Multibyte-friendly key event handler */
235       OSStatus  err = -1;
236 ***************
237 *** 2000,2006 ****
238       char_u    *to = NULL;
239       Boolean   isSpecial = FALSE;
240       int               i;
241 !     EventRef keyEvent;
242   
243       /* Mask the mouse (as per user setting) */
244       if (p_mh)
245 --- 2110,2116 ----
246       char_u    *to = NULL;
247       Boolean   isSpecial = FALSE;
248       int               i;
249 !     EventRef  keyEvent;
250   
251       /* Mask the mouse (as per user setting) */
252       if (p_mh)
253 ***************
254 *** 2008,2046 ****
255   
256       /* Don't use the keys when the dialog wants them. */
257       if (dialog_busy)
258 !         return eventNotHandledErr;
259   
260       if (noErr != GetEventParameter(theEvent, kEventParamTextInputSendText,
261 !                 typeUnicodeText, NULL, 0, &actualSize, NULL))
262 !         return eventNotHandledErr;
263   
264       text = (UniChar *)alloc(actualSize);
265       if (!text)
266 !         return eventNotHandledErr;
267   
268       err = GetEventParameter(theEvent, kEventParamTextInputSendText,
269 !             typeUnicodeText, NULL, actualSize, NULL, text);
270       require_noerr(err, done);
271   
272       err = GetEventParameter(theEvent, kEventParamTextInputSendKeyboardEvent,
273 !             typeEventRef, NULL, sizeof(EventRef), NULL, &keyEvent);
274       require_noerr(err, done);
275   
276       err = GetEventParameter(keyEvent, kEventParamKeyModifiers,
277 !             typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
278       require_noerr(err, done);
279   
280       err = GetEventParameter(keyEvent, kEventParamKeyCode,
281 !             typeUInt32, NULL, sizeof(UInt32), NULL, &key_sym);
282       require_noerr(err, done);
283   
284       err = GetEventParameter(keyEvent, kEventParamKeyMacCharCodes,
285 !             typeChar, NULL, sizeof(char), NULL, &charcode);
286       require_noerr(err, done);
287   
288   #ifndef USE_CMD_KEY
289       if (modifiers & cmdKey)
290 !         goto done;  /* Let system handle Cmd+... */
291   #endif
292   
293       key_char = charcode;
294 --- 2118,2156 ----
295   
296       /* Don't use the keys when the dialog wants them. */
297       if (dialog_busy)
298 !       return eventNotHandledErr;
299   
300       if (noErr != GetEventParameter(theEvent, kEventParamTextInputSendText,
301 !               typeUnicodeText, NULL, 0, &actualSize, NULL))
302 !       return eventNotHandledErr;
303   
304       text = (UniChar *)alloc(actualSize);
305       if (!text)
306 !       return eventNotHandledErr;
307   
308       err = GetEventParameter(theEvent, kEventParamTextInputSendText,
309 !           typeUnicodeText, NULL, actualSize, NULL, text);
310       require_noerr(err, done);
311   
312       err = GetEventParameter(theEvent, kEventParamTextInputSendKeyboardEvent,
313 !           typeEventRef, NULL, sizeof(EventRef), NULL, &keyEvent);
314       require_noerr(err, done);
315   
316       err = GetEventParameter(keyEvent, kEventParamKeyModifiers,
317 !           typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
318       require_noerr(err, done);
319   
320       err = GetEventParameter(keyEvent, kEventParamKeyCode,
321 !           typeUInt32, NULL, sizeof(UInt32), NULL, &key_sym);
322       require_noerr(err, done);
323   
324       err = GetEventParameter(keyEvent, kEventParamKeyMacCharCodes,
325 !           typeChar, NULL, sizeof(char), NULL, &charcode);
326       require_noerr(err, done);
327   
328   #ifndef USE_CMD_KEY
329       if (modifiers & cmdKey)
330 !       goto done;  /* Let system handle Cmd+... */
331   #endif
332   
333       key_char = charcode;
334 ***************
335 *** 2048,2131 ****
336   
337       /* Find the special key (eg., for cursor keys) */
338       if (actualSize <= sizeof(UniChar) &&
339 !             ((text[0] < 0x20) || (text[0] == 0x7f)))
340       {
341 !         for (i = 0; special_keys[i].key_sym != (KeySym)0; ++i)
342 !             if (special_keys[i].key_sym == key_sym)
343 !             {
344 !                 key_char = TO_SPECIAL(special_keys[i].vim_code0,
345 !                         special_keys[i].vim_code1);
346 !                 key_char = simplify_key(key_char,
347 !                         (int *)&vimModifiers);
348 !                 isSpecial = TRUE;
349 !                 break;
350 !             }
351       }
352   
353       /* Intercept CMD-. and CTRL-c */
354       if (((modifiers & controlKey) && key_char == 'c') ||
355 !             ((modifiers & cmdKey) && key_char == '.'))
356 !         got_int = TRUE;
357   
358       if (!isSpecial)
359       {
360 !         /* remove SHIFT for keys that are already shifted, e.g.,
361 !          * '(' and '*' */
362 !         if (key_char < 0x100 && !isalpha(key_char) && isprint(key_char))
363 !             vimModifiers &= ~MOD_MASK_SHIFT;
364
365 !         /* remove CTRL from keys that already have it */
366 !         if (key_char < 0x20)
367 !             vimModifiers &= ~MOD_MASK_CTRL;
368
369 !         /* don't process unicode characters here */
370 !         if (!IS_SPECIAL(key_char))
371 !         {
372 !             /* Following code to simplify and consolidate vimModifiers
373 !              * taken liberally from gui_w48.c */
374 !             key_char = simplify_key(key_char, (int *)&vimModifiers);
375
376 !             /* Interpret META, include SHIFT, etc. */
377 !             key_char = extract_modifiers(key_char, (int *)&vimModifiers);
378 !             if (key_char == CSI)
379 !                 key_char = K_CSI;
380
381 !             if (IS_SPECIAL(key_char))
382 !                 isSpecial = TRUE;
383 !         }
384       }
385   
386       if (vimModifiers)
387       {
388 !         result[len++] = CSI;
389 !         result[len++] = KS_MODIFIER;
390 !         result[len++] = vimModifiers;
391       }
392   
393       if (isSpecial && IS_SPECIAL(key_char))
394       {
395 !         result[len++] = CSI;
396 !         result[len++] = K_SECOND(key_char);
397 !         result[len++] = K_THIRD(key_char);
398       }
399       else
400       {
401 !         encLen = actualSize;
402 !         to = mac_utf16_to_enc(text, actualSize, &encLen);
403 !         if (to)
404 !         {
405 !             /* This is basically add_to_input_buf_csi() */
406 !             for (i = 0; i < encLen && len < (INLINE_KEY_BUFFER_SIZE-1); ++i)
407 !             {
408 !                 result[len++] = to[i];
409 !                 if (to[i] == CSI)
410 !                 {
411 !                     result[len++] = KS_EXTRA;
412 !                     result[len++] = (int)KE_CSI;
413 !                 }
414 !             }
415 !             vim_free(to);
416 !         }
417       }
418   
419       add_to_input_buf(result, len);
420 --- 2158,2241 ----
421   
422       /* Find the special key (eg., for cursor keys) */
423       if (actualSize <= sizeof(UniChar) &&
424 !           ((text[0] < 0x20) || (text[0] == 0x7f)))
425       {
426 !       for (i = 0; special_keys[i].key_sym != (KeySym)0; ++i)
427 !           if (special_keys[i].key_sym == key_sym)
428 !           {
429 !               key_char = TO_SPECIAL(special_keys[i].vim_code0,
430 !                       special_keys[i].vim_code1);
431 !               key_char = simplify_key(key_char,
432 !                       (int *)&vimModifiers);
433 !               isSpecial = TRUE;
434 !               break;
435 !           }
436       }
437   
438       /* Intercept CMD-. and CTRL-c */
439       if (((modifiers & controlKey) && key_char == 'c') ||
440 !           ((modifiers & cmdKey) && key_char == '.'))
441 !       got_int = TRUE;
442   
443       if (!isSpecial)
444       {
445 !       /* remove SHIFT for keys that are already shifted, e.g.,
446 !        * '(' and '*' */
447 !       if (key_char < 0x100 && !isalpha(key_char) && isprint(key_char))
448 !           vimModifiers &= ~MOD_MASK_SHIFT;
449
450 !       /* remove CTRL from keys that already have it */
451 !       if (key_char < 0x20)
452 !           vimModifiers &= ~MOD_MASK_CTRL;
453
454 !       /* don't process unicode characters here */
455 !       if (!IS_SPECIAL(key_char))
456 !       {
457 !           /* Following code to simplify and consolidate vimModifiers
458 !            * taken liberally from gui_w48.c */
459 !           key_char = simplify_key(key_char, (int *)&vimModifiers);
460
461 !           /* Interpret META, include SHIFT, etc. */
462 !           key_char = extract_modifiers(key_char, (int *)&vimModifiers);
463 !           if (key_char == CSI)
464 !               key_char = K_CSI;
465
466 !           if (IS_SPECIAL(key_char))
467 !               isSpecial = TRUE;
468 !       }
469       }
470   
471       if (vimModifiers)
472       {
473 !       result[len++] = CSI;
474 !       result[len++] = KS_MODIFIER;
475 !       result[len++] = vimModifiers;
476       }
477   
478       if (isSpecial && IS_SPECIAL(key_char))
479       {
480 !       result[len++] = CSI;
481 !       result[len++] = K_SECOND(key_char);
482 !       result[len++] = K_THIRD(key_char);
483       }
484       else
485       {
486 !       encLen = actualSize;
487 !       to = mac_utf16_to_enc(text, actualSize, &encLen);
488 !       if (to)
489 !       {
490 !           /* This is basically add_to_input_buf_csi() */
491 !           for (i = 0; i < encLen && len < (INLINE_KEY_BUFFER_SIZE-1); ++i)
492 !           {
493 !               result[len++] = to[i];
494 !               if (to[i] == CSI)
495 !               {
496 !                   result[len++] = KS_EXTRA;
497 !                   result[len++] = (int)KE_CSI;
498 !               }
499 !           }
500 !           vim_free(to);
501 !       }
502       }
503   
504       add_to_input_buf(result, len);
505 ***************
506 *** 2135,2144 ****
507       vim_free(text);
508       if (err == noErr)
509       {
510 !         /* Fake event to wake up WNE (required to get
511 !          * key repeat working */
512 !         PostEvent(keyUp, 0);
513 !         return noErr;
514       }
515   
516       return eventNotHandledErr;
517 --- 2245,2254 ----
518       vim_free(text);
519       if (err == noErr)
520       {
521 !       /* Fake event to wake up WNE (required to get
522 !        * key repeat working */
523 !       PostEvent(keyUp, 0);
524 !       return noErr;
525       }
526   
527       return eventNotHandledErr;
528 ***************
529 *** 2334,2340 ****
530       /* prevent that the vim window size changes if it's activated by a
531          click into the tab pane */
532       if (whichWindow == drawer)
533 !         return;
534   #endif
535   
536       switch (thePart)
537 --- 2444,2450 ----
538       /* prevent that the vim window size changes if it's activated by a
539          click into the tab pane */
540       if (whichWindow == drawer)
541 !       return;
542   #endif
543   
544       switch (thePart)
545 ***************
546 *** 2569,2579 ****
547       if (IsShowContextualMenuClick(event))
548       {
549   # if 0
550 !         gui_mac_handle_contextual_menu(event);
551   # else
552 !         gui_mac_doMouseDownEvent(event);
553   # endif
554 !         return;
555       }
556   
557       /* Handle normal event */
558 --- 2679,2689 ----
559       if (IsShowContextualMenuClick(event))
560       {
561   # if 0
562 !       gui_mac_handle_contextual_menu(event);
563   # else
564 !       gui_mac_doMouseDownEvent(event);
565   # endif
566 !       return;
567       }
568   
569       /* Handle normal event */
570 ***************
571 *** 2832,2838 ****
572   # else
573       /* OSErr GetApplicationBundleFSSpec(FSSpecPtr theFSSpecPtr)
574        * of TN2015
575 -      * This technic remove the ../Contents/MacOS/etc part
576        */
577       (void)GetCurrentProcess(&psn);
578       /* if (err != noErr) return err; */
579 --- 2942,2947 ----
580 ***************
581 *** 2933,2942 ****
582       /* TODO: Move most of this stuff toward gui_mch_init */
583       Rect      windRect;
584       MenuHandle        pomme;
585 -     EventTypeSpec   eventTypeSpec;
586       EventHandlerRef mouseWheelHandlerRef;
587   #ifdef USE_CARBONKEYHANDLER
588 !     EventHandlerRef keyEventHandlerRef;
589   #endif
590       ControlRef rootControl;
591   
592 --- 3042,3050 ----
593       /* TODO: Move most of this stuff toward gui_mch_init */
594       Rect      windRect;
595       MenuHandle        pomme;
596       EventHandlerRef mouseWheelHandlerRef;
597   #ifdef USE_CARBONKEYHANDLER
598 !     EventTypeSpec   eventTypeSpec;
599   #endif
600       ControlRef rootControl;
601   
602 ***************
603 *** 3042,3057 ****
604       }
605   
606   #ifdef USE_CARBONKEYHANDLER
607 !     eventTypeSpec.eventClass = kEventClassTextInput;
608 !     eventTypeSpec.eventKind = kEventUnicodeForKeyEvent;
609 !     keyEventHandlerUPP = NewEventHandlerUPP(gui_mac_doKeyEventCarbon);
610 !     if (noErr != InstallApplicationEventHandler(keyEventHandlerUPP, 1,
611 !               &eventTypeSpec, NULL, &keyEventHandlerRef))
612       {
613 -       keyEventHandlerRef = NULL;
614         DisposeEventHandlerUPP(keyEventHandlerUPP);
615         keyEventHandlerUPP = NULL;
616       }
617   #endif
618   
619   /*
620 --- 3150,3196 ----
621       }
622   
623   #ifdef USE_CARBONKEYHANDLER
624 !     InterfaceTypeList supportedServices = { kUnicodeDocument };
625 !     NewTSMDocument(1, supportedServices, &gTSMDocument, 0);
626
627 !     /* We don't support inline input yet, use input window by default */
628 !     UseInputWindow(gTSMDocument, TRUE);
629
630 !     /* Should we activate the document by default? */
631 !     // ActivateTSMDocument(gTSMDocument);
632
633 !     EventTypeSpec textEventTypes[] = {
634 !       { kEventClassTextInput, kEventTextInputUpdateActiveInputArea },
635 !       { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent },
636 !       { kEventClassTextInput, kEventTextInputPosToOffset },
637 !       { kEventClassTextInput, kEventTextInputOffsetToPos },
638 !     };
639
640 !     keyEventHandlerUPP = NewEventHandlerUPP(gui_mac_handle_text_input);
641 !     if (noErr != InstallApplicationEventHandler(keyEventHandlerUPP,
642 !                                               NR_ELEMS(textEventTypes),
643 !                                               textEventTypes, NULL, NULL))
644       {
645         DisposeEventHandlerUPP(keyEventHandlerUPP);
646         keyEventHandlerUPP = NULL;
647       }
648
649 +     EventTypeSpec windowEventTypes[] = {
650 +       { kEventClassWindow, kEventWindowActivated },
651 +       { kEventClassWindow, kEventWindowDeactivated },
652 +     };
653
654 +     /* Install window event handler to support TSMDocument activate and
655 +      * deactivate */
656 +     winEventHandlerUPP = NewEventHandlerUPP(gui_mac_handle_window_activate);
657 +     if (noErr != InstallWindowEventHandler(gui.VimWindow,
658 +                                          winEventHandlerUPP,
659 +                                          NR_ELEMS(windowEventTypes),
660 +                                          windowEventTypes, NULL, NULL))
661 +     {
662 +       DisposeEventHandlerUPP(winEventHandlerUPP);
663 +       winEventHandlerUPP = NULL;
664 +     }
665   #endif
666   
667   /*
668 ***************
669 *** 3107,3112 ****
670 --- 3246,3264 ----
671       return OK;
672   }
673   
674 + #ifdef USE_ATSUI_DRAWING
675 +     static void
676 + gui_mac_dispose_atsui_style(void)
677 + {
678 +     if (p_macatsui && gFontStyle)
679 +       ATSUDisposeStyle(gFontStyle);
680 + #ifdef FEAT_MBYTE
681 +     if (p_macatsui && gWideFontStyle)
682 +       ATSUDisposeStyle(gWideFontStyle);
683 + #endif
684 + }
685 + #endif
686
687       void
688   gui_mch_exit(int rc)
689   {
690 ***************
691 *** 3122,3129 ****
692         DisposeEventHandlerUPP(mouseWheelHandlerUPP);
693   
694   #ifdef USE_ATSUI_DRAWING
695 !     if (p_macatsui && gFontStyle)
696 !       ATSUDisposeStyle(gFontStyle);
697   #endif
698   
699       /* Exit to shell? */
700 --- 3274,3286 ----
701         DisposeEventHandlerUPP(mouseWheelHandlerUPP);
702   
703   #ifdef USE_ATSUI_DRAWING
704 !     gui_mac_dispose_atsui_style();
705 ! #endif
706
707 ! #ifdef USE_CARBONKEYHANDLER
708 !     FixTSMDocument(gTSMDocument);
709 !     DeactivateTSMDocument(gTSMDocument);
710 !     DeleteTSMDocument(gTSMDocument);
711   #endif
712   
713       /* Exit to shell? */
714 ***************
715 *** 3263,3268 ****
716 --- 3420,3445 ----
717       return selected_font;
718   }
719   
720 + #ifdef USE_ATSUI_DRAWING
721 +     static void
722 + gui_mac_create_atsui_style(void)
723 + {
724 +     if (p_macatsui && gFontStyle == NULL)
725 +     {
726 +       if (ATSUCreateStyle(&gFontStyle) != noErr)
727 +           gFontStyle = NULL;
728 +     }
729 + #ifdef FEAT_MBYTE
730 +     if (p_macatsui && gWideFontStyle == NULL)
731 +     {
732 +       if (ATSUCreateStyle(&gWideFontStyle) != noErr)
733 +           gWideFontStyle = NULL;
734 +     }
735 + #endif
736
737 +     p_macatsui_last = p_macatsui;
738 + }
739 + #endif
740   
741   /*
742    * Initialise vim to use the font with the given name.        Return FAIL if the font
743 ***************
744 *** 3280,3290 ****
745       char_u    used_font_name[512];
746   
747   #ifdef USE_ATSUI_DRAWING
748 !     if (p_macatsui && gFontStyle == NULL)
749 !     {
750 !       if (ATSUCreateStyle(&gFontStyle) != noErr)
751 !           gFontStyle = NULL;
752 !     }
753   #endif
754   
755       if (font_name == NULL)
756 --- 3457,3463 ----
757       char_u    used_font_name[512];
758   
759   #ifdef USE_ATSUI_DRAWING
760 !     gui_mac_create_atsui_style();
761   #endif
762   
763       if (font_name == NULL)
764 ***************
765 *** 3348,3396 ****
766       gui.char_height = font_info.ascent + font_info.descent + p_linespace;
767   
768   #ifdef USE_ATSUI_DRAWING
769 -     ATSUFontID                        fontID;
770 -     Fixed                     fontSize;
771 -     ATSStyleRenderingOptions  fontOptions;
772
773       if (p_macatsui && gFontStyle)
774 !     {
775 !       fontID = font & 0xFFFF;
776 !       fontSize = Long2Fix(font >> 16);
777
778 !       /* No antialiasing by default (do not attempt to touch antialising
779 !        * options on pre-Jaguar) */
780 !       fontOptions =
781 !           (gMacSystemVersion >= 0x1020) ?
782 !           kATSStyleNoAntiAliasing :
783 !           kATSStyleNoOptions;
784
785 !       ATSUAttributeTag attribTags[] =
786 !       {
787 !           kATSUFontTag, kATSUSizeTag, kATSUStyleRenderingOptionsTag,
788 !           kATSUMaxATSUITagValue+1
789 !       };
790 !       ByteCount attribSizes[] =
791 !       {
792 !           sizeof(ATSUFontID), sizeof(Fixed),
793 !           sizeof(ATSStyleRenderingOptions), sizeof font
794 !       };
795 !       ATSUAttributeValuePtr attribValues[] =
796 !       {
797 !           &fontID, &fontSize, &fontOptions, &font
798 !       };
799
800 !       /* Convert font id to ATSUFontID */
801 !       if (FMGetFontFromFontFamilyInstance(fontID, 0, &fontID, NULL) == noErr)
802 !       {
803 !           if (ATSUSetAttributes(gFontStyle,
804 !                       (sizeof attribTags)/sizeof(ATSUAttributeTag),
805 !                       attribTags, attribSizes, attribValues) != noErr)
806 !           {
807 !               ATSUDisposeStyle(gFontStyle);
808 !               gFontStyle = NULL;
809 !           }
810 !       }
811 !     }
812   #endif
813   
814       return OK;
815 --- 3521,3528 ----
816       gui.char_height = font_info.ascent + font_info.descent + p_linespace;
817   
818   #ifdef USE_ATSUI_DRAWING
819       if (p_macatsui && gFontStyle)
820 !       gui_mac_set_font_attributes(font);
821   #endif
822   
823       return OK;
824 ***************
825 *** 3447,3452 ****
826 --- 3579,3646 ----
827   }
828   #endif
829   
830 + #ifdef USE_ATSUI_DRAWING
831 +     static void
832 + gui_mac_set_font_attributes(GuiFont font)
833 + {
834 +     ATSUFontID        fontID;
835 +     Fixed     fontSize;
836 +     Fixed     fontWidth;
837
838 +     fontID    = font & 0xFFFF;
839 +     fontSize  = Long2Fix(font >> 16);
840 +     fontWidth = Long2Fix(gui.char_width);
841
842 +     ATSUAttributeTag attribTags[] =
843 +     {
844 +       kATSUFontTag, kATSUSizeTag, kATSUImposeWidthTag,
845 +       kATSUMaxATSUITagValue + 1
846 +     };
847
848 +     ByteCount attribSizes[] =
849 +     {
850 +       sizeof(ATSUFontID), sizeof(Fixed), sizeof(fontWidth),
851 +       sizeof(font)
852 +     };
853
854 +     ATSUAttributeValuePtr attribValues[] =
855 +     {
856 +       &fontID, &fontSize, &fontWidth, &font
857 +     };
858
859 +     if (FMGetFontFromFontFamilyInstance(fontID, 0, &fontID, NULL) == noErr)
860 +     {
861 +       if (ATSUSetAttributes(gFontStyle,
862 +                   (sizeof attribTags) / sizeof(ATSUAttributeTag),
863 +                   attribTags, attribSizes, attribValues) != noErr)
864 +       {
865 + # ifndef NDEBUG
866 +           fprintf(stderr, "couldn't set font style\n");
867 + # endif
868 +           ATSUDisposeStyle(gFontStyle);
869 +           gFontStyle = NULL;
870 +       }
871
872 + #ifdef FEAT_MBYTE
873 +       if (has_mbyte)
874 +       {
875 +           /* FIXME: we should use a more mbyte sensitive way to support
876 +            * wide font drawing */
877 +           fontWidth = Long2Fix(gui.char_width * 2);
878
879 +           if (ATSUSetAttributes(gWideFontStyle,
880 +                       (sizeof attribTags) / sizeof(ATSUAttributeTag),
881 +                       attribTags, attribSizes, attribValues) != noErr)
882 +           {
883 +               ATSUDisposeStyle(gWideFontStyle);
884 +               gWideFontStyle = NULL;
885 +           }
886 +       }
887 + #endif
888 +     }
889 + }
890 + #endif
891
892   /*
893    * Set the current text font.
894    */
895 ***************
896 *** 3456,3518 ****
897   #ifdef USE_ATSUI_DRAWING
898       GuiFont                   currFont;
899       ByteCount                 actualFontByteCount;
900 -     ATSUFontID                        fontID;
901 -     Fixed                     fontSize;
902 -     ATSStyleRenderingOptions  fontOptions;
903   
904       if (p_macatsui && gFontStyle)
905       {
906         /* Avoid setting same font again */
907 !       if (ATSUGetAttribute(gFontStyle, kATSUMaxATSUITagValue+1, sizeof font,
908 !                   &currFont, &actualFontByteCount) == noErr &&
909 !               actualFontByteCount == (sizeof font))
910         {
911             if (currFont == font)
912                 return;
913         }
914   
915 !       fontID = font & 0xFFFF;
916 !       fontSize = Long2Fix(font >> 16);
917 !       /* Respect p_antialias setting only for wide font.
918 !        * The reason for doing this at the moment is a bit complicated,
919 !        * but it's mainly because a) latin (non-wide) aliased fonts
920 !        * look bad in OS X 10.3.x and below (due to a bug in ATS), and
921 !        * b) wide multibyte input does not suffer from that problem. */
922 !       /*fontOptions =
923 !           (p_antialias && (font == gui.wide_font)) ?
924 !           kATSStyleNoOptions : kATSStyleNoAntiAliasing;
925 !       */
926 !       /*fontOptions = kATSStyleAntiAliasing;*/
927
928 !       ATSUAttributeTag attribTags[] =
929 !       {
930 !           kATSUFontTag, kATSUSizeTag, kATSUStyleRenderingOptionsTag,
931 !           kATSUMaxATSUITagValue+1
932 !       };
933 !       ByteCount attribSizes[] =
934 !       {
935 !           sizeof(ATSUFontID), sizeof(Fixed),
936 !           sizeof(ATSStyleRenderingOptions), sizeof font
937 !       };
938 !       ATSUAttributeValuePtr attribValues[] =
939 !       {
940 !           &fontID, &fontSize, &fontOptions, &font
941 !       };
942
943 !       if (FMGetFontFromFontFamilyInstance(fontID, 0, &fontID, NULL) == noErr)
944 !       {
945 !           if (ATSUSetAttributes(gFontStyle,
946 !                       (sizeof attribTags)/sizeof(ATSUAttributeTag),
947 !                       attribTags, attribSizes, attribValues) != noErr)
948 !           {
949 ! # ifndef NDEBUG
950 !               fprintf(stderr, "couldn't set font style\n");
951 ! # endif
952 !               ATSUDisposeStyle(gFontStyle);
953 !               gFontStyle = NULL;
954 !           }
955 !       }
956
957       }
958   
959       if (p_macatsui && !gIsFontFallbackSet)
960 --- 3650,3668 ----
961   #ifdef USE_ATSUI_DRAWING
962       GuiFont                   currFont;
963       ByteCount                 actualFontByteCount;
964   
965       if (p_macatsui && gFontStyle)
966       {
967         /* Avoid setting same font again */
968 !       if (ATSUGetAttribute(gFontStyle, kATSUMaxATSUITagValue + 1,
969 !                   sizeof(font), &currFont, &actualFontByteCount) == noErr
970 !               && actualFontByteCount == (sizeof font))
971         {
972             if (currFont == font)
973                 return;
974         }
975   
976 !       gui_mac_set_font_attributes(font);
977       }
978   
979       if (p_macatsui && !gIsFontFallbackSet)
980 ***************
981 *** 3536,3542 ****
982                         &fallbackFonts,
983                         NULL) == noErr)
984             {
985 !               ATSUSetFontFallbacks((sizeof fallbackFonts)/sizeof(ATSUFontID), &fallbackFonts, kATSUSequentialFallbacksPreferred);
986             }
987   /*
988         ATSUAttributeValuePtr fallbackValues[] = { };
989 --- 3686,3694 ----
990                         &fallbackFonts,
991                         NULL) == noErr)
992             {
993 !               ATSUSetFontFallbacks((sizeof fallbackFonts)/sizeof(ATSUFontID),
994 !                                    &fallbackFonts,
995 !                                    kATSUSequentialFallbacksPreferred);
996             }
997   /*
998         ATSUAttributeValuePtr fallbackValues[] = { };
999 ***************
1000 *** 3921,3927 ****
1001   
1002       /* - ATSUI automatically antialiases text (Someone)
1003        * - for some reason it does not work... (Jussi) */
1004
1005       /*
1006        * When antialiasing we're using srcOr mode, we have to clear the block
1007        * before drawing the text.
1008 --- 4073,4082 ----
1009   
1010       /* - ATSUI automatically antialiases text (Someone)
1011        * - for some reason it does not work... (Jussi) */
1012 ! #ifdef MAC_ATSUI_DEBUG
1013 !     fprintf(stderr, "row = %d, col = %d, len = %d: '%c'\n",
1014 !           row, col, len, len == 1 ? s[0] : ' ');
1015 ! #endif
1016       /*
1017        * When antialiasing we're using srcOr mode, we have to clear the block
1018        * before drawing the text.
1019 ***************
1020 *** 3956,3990 ****
1021       }
1022   
1023       {
1024 -       /* Use old-style, non-antialiased QuickDraw text rendering. */
1025         TextMode(srcCopy);
1026         TextFace(normal);
1027   
1028 !     /*  SelectFont(hdc, gui.currFont); */
1029
1030         if (flags & DRAW_TRANSP)
1031         {
1032             TextMode(srcOr);
1033         }
1034   
1035         MoveTo(TEXT_X(col), TEXT_Y(row));
1036 -       ATSUTextLayout textLayout;
1037   
1038 !       if (ATSUCreateTextLayoutWithTextPtr(tofree,
1039 !                   kATSUFromTextBeginning, kATSUToTextEnd,
1040 !                   utf16_len,
1041 !                   (gFontStyle ? 1 : 0), &utf16_len,
1042 !                   (gFontStyle ? &gFontStyle : NULL),
1043 !                   &textLayout) == noErr)
1044         {
1045 !           ATSUSetTransientFontMatching(textLayout, TRUE);
1046   
1047 !           ATSUDrawText(textLayout,
1048 !                   kATSUFromTextBeginning, kATSUToTextEnd,
1049 !                   kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
1050   
1051             ATSUDisposeTextLayout(textLayout);
1052         }
1053       }
1054   
1055       if (flags & DRAW_UNDERC)
1056 --- 4111,4232 ----
1057       }
1058   
1059       {
1060         TextMode(srcCopy);
1061         TextFace(normal);
1062   
1063 !       /*  SelectFont(hdc, gui.currFont); */
1064         if (flags & DRAW_TRANSP)
1065         {
1066             TextMode(srcOr);
1067         }
1068   
1069         MoveTo(TEXT_X(col), TEXT_Y(row));
1070   
1071 !       if (gFontStyle && flags & DRAW_BOLD)
1072         {
1073 !           Boolean attValue = true;
1074 !           ATSUAttributeTag attribTags[] = { kATSUQDBoldfaceTag };
1075 !           ByteCount attribSizes[] = { sizeof(Boolean) };
1076 !           ATSUAttributeValuePtr attribValues[] = { &attValue };
1077   
1078 !           ATSUSetAttributes(gFontStyle, 1, attribTags, attribSizes, attribValues);
1079 !       }
1080
1081 ! #ifdef FEAT_MBYTE
1082 !       if (has_mbyte)
1083 !       {
1084 !           int n, width_in_cell, last_width_in_cell;
1085 !           UniCharArrayOffset offset = 0;
1086 !           UniCharCount yet_to_draw = 0;
1087 !           ATSUTextLayout textLayout;
1088 !           ATSUStyle      textStyle;
1089
1090 !           last_width_in_cell = 1;
1091 !           ATSUCreateTextLayout(&textLayout);
1092 !           ATSUSetTextPointerLocation(textLayout, tofree,
1093 !                                      kATSUFromTextBeginning,
1094 !                                      kATSUToTextEnd, utf16_len);
1095 !           /*
1096 !              ATSUSetRunStyle(textLayout, gFontStyle,
1097 !              kATSUFromTextBeginning, kATSUToTextEnd); */
1098
1099 !           /* Compute the length in display cells. */
1100 !           for (n = 0; n < len; n += MB_BYTE2LEN(s[n]))
1101 !           {
1102 !               width_in_cell = (*mb_ptr2cells)(s + n);
1103
1104 !               /* probably we are switching from single byte character
1105 !                * to multibyte characters (which requires more than one
1106 !                * cell to draw) */
1107 !               if (width_in_cell != last_width_in_cell)
1108 !               {
1109 ! #ifdef MAC_ATSUI_DEBUG
1110 !                   fprintf(stderr, "\tn = %2d, (%d-%d), offset = %d, yet_to_draw = %d\n",
1111 !                           n, last_width_in_cell, width_in_cell, offset, yet_to_draw);
1112 ! #endif
1113 !                   textStyle = last_width_in_cell > 1 ? gWideFontStyle
1114 !                                                                : gFontStyle;
1115
1116 !                   ATSUSetRunStyle(textLayout, textStyle, offset, yet_to_draw);
1117 !                   offset += yet_to_draw;
1118 !                   yet_to_draw = 0;
1119 !                   last_width_in_cell = width_in_cell;
1120 !               }
1121   
1122 +               yet_to_draw++;
1123 +           }
1124
1125 +           if (yet_to_draw)
1126 +           {
1127 + #ifdef MAC_ATSUI_DEBUG
1128 +               fprintf(stderr, "\tn = %2d, (%d-%d), offset = %d, yet_to_draw = %d\n",
1129 +                       n, last_width_in_cell, width_in_cell, offset, yet_to_draw);
1130 + #endif
1131 +               /* finish the rest style */
1132 +               textStyle = width_in_cell > 1 ? gWideFontStyle : gFontStyle;
1133 +               ATSUSetRunStyle(textLayout, textStyle, offset, kATSUToTextEnd);
1134 +           }
1135
1136 +           ATSUSetTransientFontMatching(textLayout, TRUE);
1137 +           ATSUDrawText(textLayout,
1138 +                        kATSUFromTextBeginning, kATSUToTextEnd,
1139 +                        kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
1140             ATSUDisposeTextLayout(textLayout);
1141         }
1142 +       else
1143 + #endif
1144 +       {
1145 +           ATSUTextLayout textLayout;
1146
1147 +           if (ATSUCreateTextLayoutWithTextPtr(tofree,
1148 +                       kATSUFromTextBeginning, kATSUToTextEnd,
1149 +                       utf16_len,
1150 +                       (gFontStyle ? 1 : 0), &utf16_len,
1151 +                       (gFontStyle ? &gFontStyle : NULL),
1152 +                       &textLayout) == noErr)
1153 +           {
1154 +               ATSUSetTransientFontMatching(textLayout, TRUE);
1155
1156 +               ATSUDrawText(textLayout,
1157 +                       kATSUFromTextBeginning, kATSUToTextEnd,
1158 +                       kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
1159
1160 +               ATSUDisposeTextLayout(textLayout);
1161 +           }
1162 +       }
1163
1164 +       /* drawing is done, now reset bold to normal */
1165 +       if (gFontStyle && flags & DRAW_BOLD)
1166 +       {
1167 +           Boolean attValue = false;
1168
1169 +           ATSUAttributeTag attribTags[] = { kATSUQDBoldfaceTag };
1170 +           ByteCount attribSizes[] = { sizeof(Boolean) };
1171 +           ATSUAttributeValuePtr attribValues[] = { &attValue };
1172
1173 +           ATSUSetAttributes(gFontStyle, 1, attribTags, attribSizes,
1174 +                                                               attribValues);
1175 +       }
1176       }
1177   
1178       if (flags & DRAW_UNDERC)
1179 ***************
1180 *** 3998,4003 ****
1181 --- 4240,4252 ----
1182   gui_mch_draw_string(int row, int col, char_u *s, int len, int flags)
1183   {
1184   #if defined(USE_ATSUI_DRAWING)
1185 +     if (p_macatsui == 0 && p_macatsui_last != 0)
1186 +       /* switch from macatsui to nomacatsui */
1187 +       gui_mac_dispose_atsui_style();
1188 +     else if (p_macatsui != 0 && p_macatsui_last == 0)
1189 +       /* switch from nomacatsui to macatsui */
1190 +       gui_mac_create_atsui_style();
1191
1192       if (p_macatsui)
1193         draw_string_ATSUI(row, col, s, len, flags);
1194       else
1195 ***************
1196 *** 4228,4239 ****
1197          */
1198         /* TODO: reduce wtime accordinly???  */
1199         if (wtime > -1)
1200 !           sleeppyTick = 60*wtime/1000;
1201         else
1202             sleeppyTick = 32767;
1203         if (WaitNextEventWrp(mask, &event, sleeppyTick, dragRgn))
1204         {
1205 !               gui_mac_handle_event(&event);
1206             if (input_available())
1207             {
1208                 allow_scrollbar = FALSE;
1209 --- 4477,4489 ----
1210          */
1211         /* TODO: reduce wtime accordinly???  */
1212         if (wtime > -1)
1213 !           sleeppyTick = 60 * wtime / 1000;
1214         else
1215             sleeppyTick = 32767;
1216
1217         if (WaitNextEventWrp(mask, &event, sleeppyTick, dragRgn))
1218         {
1219 !           gui_mac_handle_event(&event);
1220             if (input_available())
1221             {
1222                 allow_scrollbar = FALSE;
1223 ***************
1224 *** 6031,6037 ****
1225   #endif
1226   }
1227   
1228 ! #if defined(USE_IM_CONTROL) || defined(PROTO)
1229   /*
1230    * Input Method Control functions.
1231    */
1232 --- 6346,6352 ----
1233   #endif
1234   }
1235   
1236 ! #if (defined(USE_IM_CONTROL) || defined(PROTO)) && defined(USE_CARBONKEYHANDLER)
1237   /*
1238    * Input Method Control functions.
1239    */
1240 ***************
1241 *** 6042,6048 ****
1242 --- 6357,6427 ----
1243       void
1244   im_set_position(int row, int col)
1245   {
1246 + #if 0
1247       /* TODO: Implement me! */
1248 +     im_start_row = row;
1249 +     im_start_col = col;
1250 + #endif
1251 + }
1252
1253 + static ScriptLanguageRecord gTSLWindow;
1254 + static ScriptLanguageRecord gTSLInsert;
1255 + static ScriptLanguageRecord gTSLDefault = { 0, 0 };
1256
1257 + static Component           gTSCWindow;
1258 + static Component           gTSCInsert;
1259 + static Component           gTSCDefault;
1260
1261 + static int                 im_initialized = 0;
1262
1263 +     static void
1264 + im_on_window_switch(int active)
1265 + {
1266 +     ScriptLanguageRecord *slptr = NULL;
1267 +     OSStatus err;
1268
1269 +     if (! gui.in_use)
1270 +       return;
1271
1272 +     if (im_initialized == 0)
1273 +     {
1274 +       im_initialized = 1;
1275
1276 +       /* save default TSM component (should be U.S.) to default */
1277 +       GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault,
1278 +                                    kKeyboardInputMethodClass);
1279 +     }
1280
1281 +     if (active == TRUE)
1282 +     {
1283 +       im_is_active = TRUE;
1284 +       ActivateTSMDocument(gTSMDocument);
1285 +       slptr = &gTSLWindow;
1286
1287 +       if (slptr)
1288 +       {
1289 +           err = SetDefaultInputMethodOfClass(gTSCWindow, slptr,
1290 +                                              kKeyboardInputMethodClass);
1291 +           if (err == noErr)
1292 +               err = SetTextServiceLanguage(slptr);
1293
1294 +           if (err == noErr)
1295 +               KeyScript(slptr->fScript | smKeyForceKeyScriptMask);
1296 +       }
1297 +     }
1298 +     else
1299 +     {
1300 +       err = GetTextServiceLanguage(&gTSLWindow);
1301 +       if (err == noErr)
1302 +           slptr = &gTSLWindow;
1303
1304 +       if (slptr)
1305 +           GetDefaultInputMethodOfClass(&gTSCWindow, slptr,
1306 +                                        kKeyboardInputMethodClass);
1307
1308 +       im_is_active = FALSE;
1309 +       DeactivateTSMDocument(gTSMDocument);
1310 +     }
1311   }
1312   
1313   /*
1314 ***************
1315 *** 6051,6057 ****
1316       void
1317   im_set_active(int active)
1318   {
1319 !     KeyScript(active ? smKeySysScript : smKeyRoman);
1320   }
1321   
1322   /*
1323 --- 6430,6486 ----
1324       void
1325   im_set_active(int active)
1326   {
1327 !     ScriptLanguageRecord *slptr = NULL;
1328 !     OSStatus err;
1329
1330 !     if (! gui.in_use)
1331 !       return;
1332
1333 !     if (im_initialized == 0)
1334 !     {
1335 !       im_initialized = 1;
1336
1337 !       /* save default TSM component (should be U.S.) to default */
1338 !       GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault,
1339 !                                    kKeyboardInputMethodClass);
1340 !     }
1341
1342 !     if (active == TRUE)
1343 !     {
1344 !       im_is_active = TRUE;
1345 !       ActivateTSMDocument(gTSMDocument);
1346 !       slptr = &gTSLInsert;
1347
1348 !       if (slptr)
1349 !       {
1350 !           err = SetDefaultInputMethodOfClass(gTSCInsert, slptr,
1351 !                                              kKeyboardInputMethodClass);
1352 !           if (err == noErr)
1353 !               err = SetTextServiceLanguage(slptr);
1354
1355 !           if (err == noErr)
1356 !               KeyScript(slptr->fScript | smKeyForceKeyScriptMask);
1357 !       }
1358 !     }
1359 !     else
1360 !     {
1361 !       err = GetTextServiceLanguage(&gTSLInsert);
1362 !       if (err == noErr)
1363 !           slptr = &gTSLInsert;
1364
1365 !       if (slptr)
1366 !           GetDefaultInputMethodOfClass(&gTSCInsert, slptr,
1367 !                                        kKeyboardInputMethodClass);
1368
1369 !       /* restore to default when switch to normal mode, so than we could
1370 !        * enter commands easier */
1371 !       SetDefaultInputMethodOfClass(gTSCDefault, &gTSLDefault,
1372 !                                    kKeyboardInputMethodClass);
1373 !       SetTextServiceLanguage(&gTSLDefault);
1374
1375 !       im_is_active = FALSE;
1376 !       DeactivateTSMDocument(gTSMDocument);
1377 !     }
1378   }
1379   
1380   /*
1381 ***************
1382 *** 6060,6068 ****
1383       int
1384   im_get_status(void)
1385   {
1386 !     SInt32 script = GetScriptManagerVariable(smKeyScript);
1387 !     return (script != smRoman
1388 !           && script == GetScriptManagerVariable(smSysScript)) ? 1 : 0;
1389   }
1390   
1391   #endif /* defined(USE_IM_CONTROL) || defined(PROTO) */
1392 --- 6489,6498 ----
1393       int
1394   im_get_status(void)
1395   {
1396 !     if (! gui.in_use)
1397 !       return 0;
1398
1399 !     return im_is_active;
1400   }
1401   
1402   #endif /* defined(USE_IM_CONTROL) || defined(PROTO) */
1403 ***************
1404 *** 6118,6124 ****
1405       int               numTabs = 0;
1406   
1407       for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
1408 !         ++numTabs;
1409       return numTabs;
1410   }
1411   
1412 --- 6548,6554 ----
1413       int               numTabs = 0;
1414   
1415       for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
1416 !       ++numTabs;
1417       return numTabs;
1418   }
1419   
1420 ***************
1421 *** 6126,6133 ****
1422       static OSStatus
1423   dbItemDataCallback(ControlRef browser,
1424         DataBrowserItemID itemID,
1425 !         DataBrowserPropertyID property /* column id */,
1426 !         DataBrowserItemDataRef itemData,
1427         Boolean changeValue)
1428   {
1429       OSStatus status = noErr;
1430 --- 6556,6563 ----
1431       static OSStatus
1432   dbItemDataCallback(ControlRef browser,
1433         DataBrowserItemID itemID,
1434 !       DataBrowserPropertyID property /* column id */,
1435 !       DataBrowserItemDataRef itemData,
1436         Boolean changeValue)
1437   {
1438       OSStatus status = noErr;
1439 ***************
1440 *** 6170,6178 ****
1441       static void
1442   dbGetContextualMenuCallback(ControlRef browser,
1443         MenuRef *menu,
1444 !         UInt32 *helpType,
1445         CFStringRef *helpItemString,
1446 !         AEDesc *selection)
1447   {
1448       // on mac os 9: kCMHelpItemNoHelp, but it's not the same
1449       *helpType = kCMHelpItemRemoveHelp; // OS X only ;-)
1450 --- 6600,6608 ----
1451       static void
1452   dbGetContextualMenuCallback(ControlRef browser,
1453         MenuRef *menu,
1454 !       UInt32 *helpType,
1455         CFStringRef *helpItemString,
1456 !       AEDesc *selection)
1457   {
1458       // on mac os 9: kCMHelpItemNoHelp, but it's not the same
1459       *helpType = kCMHelpItemRemoveHelp; // OS X only ;-)
1460 ***************
1461 *** 6395,6403 ****
1462   gui_mch_show_tabline(int showit)
1463   {
1464       if (showit == 0)
1465 !         CloseDrawer(drawer, true);
1466       else
1467 !         OpenDrawer(drawer, kWindowEdgeRight, true);
1468   }
1469   
1470   /*
1471 --- 6825,6833 ----
1472   gui_mch_show_tabline(int showit)
1473   {
1474       if (showit == 0)
1475 !       CloseDrawer(drawer, true);
1476       else
1477 !       OpenDrawer(drawer, kWindowEdgeRight, true);
1478   }
1479   
1480   /*
1481 ***************
1482 *** 6425,6435 ****
1483       // adjust data browser
1484       if (tabLabels != NULL)
1485       {
1486 !         int i;
1487   
1488 !         for (i = 0; i < tabLabelsSize; ++i)
1489 !             CFRelease(tabLabels[i]);
1490 !         free(tabLabels);
1491       }
1492       tabLabels = (CFStringRef *)malloc(numTabs * sizeof(CFStringRef));
1493       tabLabelsSize = numTabs;
1494 --- 6855,6865 ----
1495       // adjust data browser
1496       if (tabLabels != NULL)
1497       {
1498 !       int i;
1499   
1500 !       for (i = 0; i < tabLabelsSize; ++i)
1501 !           CFRelease(tabLabels[i]);
1502 !       free(tabLabels);
1503       }
1504       tabLabels = (CFStringRef *)malloc(numTabs * sizeof(CFStringRef));
1505       tabLabelsSize = numTabs;
1506 ***************
1507 *** 6438,6444 ****
1508       {
1509         if (tp == curtab)
1510             curtabidx = nr;
1511 !         tabLabels[nr-1] = getTabLabel(tp);
1512       }
1513   
1514       RemoveDataBrowserItems(dataBrowser, kDataBrowserNoItem, 0, NULL,
1515 --- 6868,6874 ----
1516       {
1517         if (tp == curtab)
1518             curtabidx = nr;
1519 !       tabLabels[nr-1] = getTabLabel(tp);
1520       }
1521   
1522       RemoveDataBrowserItems(dataBrowser, kDataBrowserNoItem, 0, NULL,
1523 *** ../vim-7.1.274/src/version.c        Wed Mar 12 13:45:34 2008
1524 --- src/version.c       Wed Mar 12 14:31:37 2008
1525 ***************
1526 *** 668,669 ****
1527 --- 668,671 ----
1528   {   /* Add new patch number below this line */
1529 + /**/
1530 +     275,
1531   /**/
1532
1533 -- 
1534 hundred-and-one symptoms of being an internet addict:
1535 115. You are late picking up your kid from school and try to explain
1536      to the teacher you were stuck in Web traffic.
1537
1538  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
1539 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
1540 \\\        download, build and distribute -- http://www.A-A-P.org        ///
1541  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.170373 seconds and 3 git commands to generate.