Mercurial > vim
comparison src/gui_mac.c @ 18788:e1f4e9d78a6a v8.1.2383
patch 8.1.2383: using old C style comments
Commit: https://github.com/vim/vim/commit/734a867ffe198886da7365b618be67ab8ed9d9f6
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Dec 2 22:49:38 2019 +0100
patch 8.1.2383: using old C style comments
Problem: Using old C style comments.
Solution: Use // comments where appropriate.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 02 Dec 2019 23:00:04 +0100 |
parents | 506bf60a30a0 |
children | 2ef19eed524a |
comparison
equal
deleted
inserted
replaced
18787:06ed2fe62dce | 18788:e1f4e9d78a6a |
---|---|
26 * ScrapManager error handling. | 26 * ScrapManager error handling. |
27 * Comments about function remaining to Carbonize. | 27 * Comments about function remaining to Carbonize. |
28 * | 28 * |
29 */ | 29 */ |
30 | 30 |
31 /* TODO (Jussi) | 31 /* |
32 * TODO (Jussi) | |
32 * * Clipboard does not work (at least some cases) | 33 * * Clipboard does not work (at least some cases) |
33 * * ATSU font rendering has some problems | 34 * * ATSU font rendering has some problems |
34 * * Investigate and remove dead code (there is still lots of that) | 35 * * Investigate and remove dead code (there is still lots of that) |
35 */ | 36 */ |
36 | 37 |
37 #include <Devices.h> /* included first to avoid CR problems */ | 38 #include <Devices.h> // included first to avoid CR problems |
38 #include "vim.h" | 39 #include "vim.h" |
39 | 40 |
40 #define USE_CARBONIZED | 41 #define USE_CARBONIZED |
41 #define USE_AEVENT /* Enable AEVENT */ | 42 #define USE_AEVENT // Enable AEVENT |
42 #undef USE_OFFSETED_WINDOW /* Debugging feature: start Vim window OFFSETed */ | 43 #undef USE_OFFSETED_WINDOW // Debugging feature: start Vim window OFFSETed |
43 | 44 |
44 /* Compile as CodeWarrior External Editor */ | 45 // Compile as CodeWarrior External Editor |
45 #if defined(FEAT_CW_EDITOR) && !defined(USE_AEVENT) | 46 #if defined(FEAT_CW_EDITOR) && !defined(USE_AEVENT) |
46 # define USE_AEVENT /* Need Apple Event Support */ | 47 # define USE_AEVENT // Need Apple Event Support |
47 #endif | 48 #endif |
48 | 49 |
49 /* Vim's Scrap flavor. */ | 50 // Vim's Scrap flavor. |
50 #define VIMSCRAPFLAVOR 'VIM!' | 51 #define VIMSCRAPFLAVOR 'VIM!' |
51 #define SCRAPTEXTFLAVOR kScrapFlavorTypeUnicode | 52 #define SCRAPTEXTFLAVOR kScrapFlavorTypeUnicode |
52 | 53 |
53 static EventHandlerUPP mouseWheelHandlerUPP = NULL; | 54 static EventHandlerUPP mouseWheelHandlerUPP = NULL; |
54 SInt32 gMacSystemVersion; | 55 SInt32 gMacSystemVersion; |
56 #ifdef MACOS_CONVERT | 57 #ifdef MACOS_CONVERT |
57 # define USE_CARBONKEYHANDLER | 58 # define USE_CARBONKEYHANDLER |
58 | 59 |
59 static int im_is_active = FALSE; | 60 static int im_is_active = FALSE; |
60 # if 0 | 61 # if 0 |
61 /* TODO: Implement me! */ | 62 // TODO: Implement me! |
62 static int im_start_row = 0; | 63 static int im_start_row = 0; |
63 static int im_start_col = 0; | 64 static int im_start_col = 0; |
64 # endif | 65 # endif |
65 | 66 |
66 # define NR_ELEMS(x) (sizeof(x) / sizeof(x[0])) | 67 # define NR_ELEMS(x) (sizeof(x) / sizeof(x[0])) |
84 EventHandlerCallRef nextHandler, EventRef theEvent); | 85 EventHandlerCallRef nextHandler, EventRef theEvent); |
85 | 86 |
86 #endif | 87 #endif |
87 | 88 |
88 | 89 |
89 /* Include some file. TODO: move into os_mac.h */ | 90 // Include some file. TODO: move into os_mac.h |
90 #include <Menus.h> | 91 #include <Menus.h> |
91 #include <Resources.h> | 92 #include <Resources.h> |
92 #include <Processes.h> | 93 #include <Processes.h> |
93 #ifdef USE_AEVENT | 94 #ifdef USE_AEVENT |
94 # include <AppleEvents.h> | 95 # include <AppleEvents.h> |
95 # include <AERegistry.h> | 96 # include <AERegistry.h> |
96 #endif | 97 #endif |
97 # include <Gestalt.h> | 98 # include <Gestalt.h> |
98 #if UNIVERSAL_INTERFACES_VERSION >= 0x0330 | 99 #if UNIVERSAL_INTERFACES_VERSION >= 0x0330 |
99 # include <ControlDefinitions.h> | 100 # include <ControlDefinitions.h> |
100 # include <Navigation.h> /* Navigation only part of ?? */ | 101 # include <Navigation.h> // Navigation only part of ?? |
101 #endif | 102 #endif |
102 | 103 |
103 /* Help Manager (balloon.h, HM prefixed functions) are not supported | 104 // Help Manager (balloon.h, HM prefixed functions) are not supported |
104 * under Carbon (Jussi) */ | 105 // under Carbon (Jussi) |
105 # if 0 | 106 # if 0 |
106 /* New Help Interface for Mac, not implemented yet.*/ | 107 // New Help Interface for Mac, not implemented yet. |
107 # include <MacHelp.h> | 108 # include <MacHelp.h> |
108 # endif | 109 # endif |
109 | 110 |
110 /* | 111 /* |
111 * These seem to be rectangle options. Why are they not found in | 112 * These seem to be rectangle options. Why are they not found in |
112 * headers? (Jussi) | 113 * headers? (Jussi) |
113 */ | 114 */ |
114 #define kNothing 0 | 115 #define kNothing 0 |
115 #define kCreateEmpty 2 /*1*/ | 116 #define kCreateEmpty 2 //1 |
116 #define kCreateRect 2 | 117 #define kCreateRect 2 |
117 #define kDestroy 3 | 118 #define kDestroy 3 |
118 | 119 |
119 /* | 120 /* |
120 * Dany: Don't like those... | 121 * Dany: Don't like those... |
121 */ | 122 */ |
122 #define topLeft(r) (((Point*)&(r))[0]) | 123 #define topLeft(r) (((Point*)&(r))[0]) |
123 #define botRight(r) (((Point*)&(r))[1]) | 124 #define botRight(r) (((Point*)&(r))[1]) |
124 | 125 |
125 | 126 |
126 /* Time of last mouse click, to detect double-click */ | 127 // Time of last mouse click, to detect double-click |
127 static long lastMouseTick = 0; | 128 static long lastMouseTick = 0; |
128 | 129 |
129 /* ??? */ | 130 // ??? |
130 static RgnHandle cursorRgn; | 131 static RgnHandle cursorRgn; |
131 static RgnHandle dragRgn; | 132 static RgnHandle dragRgn; |
132 static Rect dragRect; | 133 static Rect dragRect; |
133 static short dragRectEnbl; | 134 static short dragRectEnbl; |
134 static short dragRectControl; | 135 static short dragRectControl; |
135 | 136 |
136 /* This variable is set when waiting for an event, which is the only moment | 137 // This variable is set when waiting for an event, which is the only moment |
137 * scrollbar dragging can be done directly. It's not allowed while commands | 138 // scrollbar dragging can be done directly. It's not allowed while commands |
138 * are executed, because it may move the cursor and that may cause unexpected | 139 // are executed, because it may move the cursor and that may cause unexpected |
139 * problems (e.g., while ":s" is working). | 140 // problems (e.g., while ":s" is working). |
140 */ | |
141 static int allow_scrollbar = FALSE; | 141 static int allow_scrollbar = FALSE; |
142 | 142 |
143 /* Last mouse click caused contextual menu, (to provide proper release) */ | 143 // Last mouse click caused contextual menu, (to provide proper release) |
144 static short clickIsPopup; | 144 static short clickIsPopup; |
145 | 145 |
146 /* Feedback Action for Scrollbar */ | 146 // Feedback Action for Scrollbar |
147 ControlActionUPP gScrollAction; | 147 ControlActionUPP gScrollAction; |
148 ControlActionUPP gScrollDrag; | 148 ControlActionUPP gScrollDrag; |
149 | 149 |
150 /* Keeping track of which scrollbar is being dragged */ | 150 // Keeping track of which scrollbar is being dragged |
151 static ControlHandle dragged_sb = NULL; | 151 static ControlHandle dragged_sb = NULL; |
152 | 152 |
153 /* Vector of char_u --> control index for hotkeys in dialogs */ | 153 // Vector of char_u --> control index for hotkeys in dialogs |
154 static short *gDialogHotKeys; | 154 static short *gDialogHotKeys; |
155 | 155 |
156 static struct | 156 static struct |
157 { | 157 { |
158 FMFontFamily family; | 158 FMFontFamily family; |
168 ATSUStyle gWideFontStyle; | 168 ATSUStyle gWideFontStyle; |
169 Boolean gIsFontFallbackSet; | 169 Boolean gIsFontFallbackSet; |
170 UInt32 useAntialias_cached = 0x0; | 170 UInt32 useAntialias_cached = 0x0; |
171 #endif | 171 #endif |
172 | 172 |
173 /* Colors Macros */ | 173 // Colors Macros |
174 #define RGB(r,g,b) ((r) << 16) + ((g) << 8) + (b) | 174 #define RGB(r,g,b) ((r) << 16) + ((g) << 8) + (b) |
175 #define Red(c) ((c & 0x00FF0000) >> 16) | 175 #define Red(c) ((c & 0x00FF0000) >> 16) |
176 #define Green(c) ((c & 0x0000FF00) >> 8) | 176 #define Green(c) ((c & 0x0000FF00) >> 8) |
177 #define Blue(c) ((c & 0x000000FF) >> 0) | 177 #define Blue(c) ((c & 0x000000FF) >> 0) |
178 | 178 |
179 /* Key mapping */ | 179 // Key mapping |
180 | 180 |
181 #define vk_Esc 0x35 /* -> 1B */ | 181 #define vk_Esc 0x35 // -> 1B |
182 | 182 |
183 #define vk_F1 0x7A /* -> 10 */ | 183 #define vk_F1 0x7A // -> 10 |
184 #define vk_F2 0x78 /*0x63*/ | 184 #define vk_F2 0x78 //0x63 |
185 #define vk_F3 0x63 /*0x76*/ | 185 #define vk_F3 0x63 //0x76 |
186 #define vk_F4 0x76 /*0x60*/ | 186 #define vk_F4 0x76 //0x60 |
187 #define vk_F5 0x60 /*0x61*/ | 187 #define vk_F5 0x60 //0x61 |
188 #define vk_F6 0x61 /*0x62*/ | 188 #define vk_F6 0x61 //0x62 |
189 #define vk_F7 0x62 /*0x63*/ /*?*/ | 189 #define vk_F7 0x62 //0x63 ? |
190 #define vk_F8 0x64 | 190 #define vk_F8 0x64 |
191 #define vk_F9 0x65 | 191 #define vk_F9 0x65 |
192 #define vk_F10 0x6D | 192 #define vk_F10 0x6D |
193 #define vk_F11 0x67 | 193 #define vk_F11 0x67 |
194 #define vk_F12 0x6F | 194 #define vk_F12 0x6F |
195 #define vk_F13 0x69 | 195 #define vk_F13 0x69 |
196 #define vk_F14 0x6B | 196 #define vk_F14 0x6B |
197 #define vk_F15 0x71 | 197 #define vk_F15 0x71 |
198 | 198 |
199 #define vk_Clr 0x47 /* -> 1B (ESC) */ | 199 #define vk_Clr 0x47 // -> 1B (ESC) |
200 #define vk_Enter 0x4C /* -> 03 */ | 200 #define vk_Enter 0x4C // -> 03 |
201 | 201 |
202 #define vk_Space 0x31 /* -> 20 */ | 202 #define vk_Space 0x31 // -> 20 |
203 #define vk_Tab 0x30 /* -> 09 */ | 203 #define vk_Tab 0x30 // -> 09 |
204 #define vk_Return 0x24 /* -> 0D */ | 204 #define vk_Return 0x24 // -> 0D |
205 /* This is wrong for OSX, what is it for? */ | 205 // This is wrong for OSX, what is it for? |
206 #define vk_Delete 0X08 /* -> 08 BackSpace */ | 206 #define vk_Delete 0X08 // -> 08 BackSpace |
207 | 207 |
208 #define vk_Help 0x72 /* -> 05 */ | 208 #define vk_Help 0x72 // -> 05 |
209 #define vk_Home 0x73 /* -> 01 */ | 209 #define vk_Home 0x73 // -> 01 |
210 #define vk_PageUp 0x74 /* -> 0D */ | 210 #define vk_PageUp 0x74 // -> 0D |
211 #define vk_FwdDelete 0x75 /* -> 7F */ | 211 #define vk_FwdDelete 0x75 // -> 7F |
212 #define vk_End 0x77 /* -> 04 */ | 212 #define vk_End 0x77 // -> 04 |
213 #define vk_PageDown 0x79 /* -> 0C */ | 213 #define vk_PageDown 0x79 // -> 0C |
214 | 214 |
215 #define vk_Up 0x7E /* -> 1E */ | 215 #define vk_Up 0x7E // -> 1E |
216 #define vk_Down 0x7D /* -> 1F */ | 216 #define vk_Down 0x7D // -> 1F |
217 #define vk_Left 0x7B /* -> 1C */ | 217 #define vk_Left 0x7B // -> 1C |
218 #define vk_Right 0x7C /* -> 1D */ | 218 #define vk_Right 0x7C // -> 1D |
219 | 219 |
220 #define vk_Undo vk_F1 | 220 #define vk_Undo vk_F1 |
221 #define vk_Cut vk_F2 | 221 #define vk_Cut vk_F2 |
222 #define vk_Copy vk_F3 | 222 #define vk_Copy vk_F3 |
223 #define vk_Paste vk_F4 | 223 #define vk_Paste vk_F4 |
256 {vk_F12, 'F', '2'}, | 256 {vk_F12, 'F', '2'}, |
257 {vk_F13, 'F', '3'}, | 257 {vk_F13, 'F', '3'}, |
258 {vk_F14, 'F', '4'}, | 258 {vk_F14, 'F', '4'}, |
259 {vk_F15, 'F', '5'}, | 259 {vk_F15, 'F', '5'}, |
260 | 260 |
261 /* {XK_Help, '%', '1'}, */ | 261 // {XK_Help, '%', '1'}, |
262 /* {XK_Undo, '&', '8'}, */ | 262 // {XK_Undo, '&', '8'}, |
263 /* {XK_BackSpace, 'k', 'b'}, */ | 263 // {XK_BackSpace, 'k', 'b'}, |
264 /* {vk_Delete, 'k', 'b'}, */ | 264 // {vk_Delete, 'k', 'b'}, |
265 {vk_Insert, 'k', 'I'}, | 265 {vk_Insert, 'k', 'I'}, |
266 {vk_FwdDelete, 'k', 'D'}, | 266 {vk_FwdDelete, 'k', 'D'}, |
267 {vk_Home, 'k', 'h'}, | 267 {vk_Home, 'k', 'h'}, |
268 {vk_End, '@', '7'}, | 268 {vk_End, '@', '7'}, |
269 /* {XK_Prior, 'k', 'P'}, */ | 269 // {XK_Prior, 'k', 'P'}, |
270 /* {XK_Next, 'k', 'N'}, */ | 270 // {XK_Next, 'k', 'N'}, |
271 /* {XK_Print, '%', '9'}, */ | 271 // {XK_Print, '%', '9'}, |
272 | 272 |
273 {vk_PageUp, 'k', 'P'}, | 273 {vk_PageUp, 'k', 'P'}, |
274 {vk_PageDown, 'k', 'N'}, | 274 {vk_PageDown, 'k', 'N'}, |
275 | 275 |
276 /* End of list marker: */ | 276 // End of list marker: |
277 {(KeySym)0, 0, 0} | 277 {(KeySym)0, 0, 0} |
278 }; | 278 }; |
279 | 279 |
280 /* | 280 /* |
281 * ------------------------------------------------------------ | 281 * ------------------------------------------------------------ |
319 if (Cstring == NULL) | 319 if (Cstring == NULL) |
320 return NULL; | 320 return NULL; |
321 | 321 |
322 len = STRLEN(Cstring); | 322 len = STRLEN(Cstring); |
323 | 323 |
324 if (len > 255) /* Truncate if necessary */ | 324 if (len > 255) // Truncate if necessary |
325 len = 255; | 325 len = 255; |
326 | 326 |
327 PascalString = alloc(len + 1); | 327 PascalString = alloc(len + 1); |
328 if (PascalString != NULL) | 328 if (PascalString != NULL) |
329 { | 329 { |
349 int len; | 349 int len; |
350 char_u *p, *c; | 350 char_u *p, *c; |
351 | 351 |
352 len = STRLEN(Cstring); | 352 len = STRLEN(Cstring); |
353 | 353 |
354 if (len > 255) /* Truncate if necessary */ | 354 if (len > 255) // Truncate if necessary |
355 len = 255; | 355 len = 255; |
356 | 356 |
357 PascalString = alloc(len + 1); | 357 PascalString = alloc(len + 1); |
358 if (PascalString != NULL) | 358 if (PascalString != NULL) |
359 { | 359 { |
385 if (macModifiers & (controlKey | rightControlKey)) | 385 if (macModifiers & (controlKey | rightControlKey)) |
386 vimModifiers |= MOUSE_CTRL; | 386 vimModifiers |= MOUSE_CTRL; |
387 if (macModifiers & (optionKey | rightOptionKey)) | 387 if (macModifiers & (optionKey | rightOptionKey)) |
388 vimModifiers |= MOUSE_ALT; | 388 vimModifiers |= MOUSE_ALT; |
389 #if 0 | 389 #if 0 |
390 /* Not yet supported */ | 390 // Not yet supported |
391 if (macModifiers & (cmdKey)) /* There's no rightCmdKey */ | 391 if (macModifiers & (cmdKey)) // There's no rightCmdKey |
392 vimModifiers |= MOUSE_CMD; | 392 vimModifiers |= MOUSE_CMD; |
393 #endif | 393 #endif |
394 return (vimModifiers); | 394 return (vimModifiers); |
395 } | 395 } |
396 | 396 |
408 if (macModifiers & (controlKey | rightControlKey)) | 408 if (macModifiers & (controlKey | rightControlKey)) |
409 vimModifiers |= MOD_MASK_CTRL; | 409 vimModifiers |= MOD_MASK_CTRL; |
410 if (macModifiers & (optionKey | rightOptionKey)) | 410 if (macModifiers & (optionKey | rightOptionKey)) |
411 vimModifiers |= MOD_MASK_ALT; | 411 vimModifiers |= MOD_MASK_ALT; |
412 #ifdef USE_CMD_KEY | 412 #ifdef USE_CMD_KEY |
413 if (macModifiers & (cmdKey)) /* There's no rightCmdKey */ | 413 if (macModifiers & (cmdKey)) // There's no rightCmdKey |
414 vimModifiers |= MOD_MASK_CMD; | 414 vimModifiers |= MOD_MASK_CMD; |
415 #endif | 415 #endif |
416 return (vimModifiers); | 416 return (vimModifiers); |
417 } | 417 } |
418 | 418 |
419 /* Convert a string representing a point size into pixels. The string should | 419 /* |
420 * Convert a string representing a point size into pixels. The string should | |
420 * be a positive decimal number, with an optional decimal point (eg, "12", or | 421 * be a positive decimal number, with an optional decimal point (eg, "12", or |
421 * "10.5"). The pixel value is returned, and a pointer to the next unconverted | 422 * "10.5"). The pixel value is returned, and a pointer to the next unconverted |
422 * character is stored in *end. The flag "vertical" says whether this | 423 * character is stored in *end. The flag "vertical" says whether this |
423 * calculation is for a vertical (height) size or a horizontal (width) one. | 424 * calculation is for a vertical (height) size or a horizontal (width) one. |
424 * | 425 * |
433 | 434 |
434 while (*str) | 435 while (*str) |
435 { | 436 { |
436 if (*str == '.' && divisor == 0) | 437 if (*str == '.' && divisor == 0) |
437 { | 438 { |
438 /* Start keeping a divisor, for later */ | 439 // Start keeping a divisor, for later |
439 divisor = 1; | 440 divisor = 1; |
440 continue; | 441 continue; |
441 } | 442 } |
442 | 443 |
443 if (!isdigit(*str)) | 444 if (!isdigit(*str)) |
477 menuTitleLen = STRLEN(menu->dname); | 478 menuTitleLen = STRLEN(menu->dname); |
478 name = (CFStringRef) mac_enc_to_cfstring(menu->dname, menuTitleLen); | 479 name = (CFStringRef) mac_enc_to_cfstring(menu->dname, menuTitleLen); |
479 | 480 |
480 if (name) | 481 if (name) |
481 { | 482 { |
482 /* Simple mnemonic-removal algorithm, assumes single parenthesized | 483 // Simple mnemonic-removal algorithm, assumes single parenthesized |
483 * mnemonic character towards the end of the menu text */ | 484 // mnemonic character towards the end of the menu text |
484 mnemonicStart = CFStringFind(name, CFSTR("("), kCFCompareBackwards); | 485 mnemonicStart = CFStringFind(name, CFSTR("("), kCFCompareBackwards); |
485 displayLen = CFStringGetLength(name); | 486 displayLen = CFStringGetLength(name); |
486 | 487 |
487 if (mnemonicStart.location != kCFNotFound | 488 if (mnemonicStart.location != kCFNotFound |
488 && (mnemonicStart.location + 2) < displayLen | 489 && (mnemonicStart.location + 2) < displayLen |
528 FSSpec fileToOpen; | 529 FSSpec fileToOpen; |
529 long actualSize; | 530 long actualSize; |
530 AEKeyword dummyKeyword; | 531 AEKeyword dummyKeyword; |
531 DescType dummyType; | 532 DescType dummyType; |
532 | 533 |
533 /* Get number of files in list */ | 534 // Get number of files in list |
534 *error = AECountItems(theList, numFiles); | 535 *error = AECountItems(theList, numFiles); |
535 if (*error) | 536 if (*error) |
536 return fnames; | 537 return fnames; |
537 | 538 |
538 /* Allocate the pointer list */ | 539 // Allocate the pointer list |
539 fnames = ALLOC_MULT(char_u *, *numFiles); | 540 fnames = ALLOC_MULT(char_u *, *numFiles); |
540 | 541 |
541 /* Empty out the list */ | 542 // Empty out the list |
542 for (fileCount = 0; fileCount < *numFiles; fileCount++) | 543 for (fileCount = 0; fileCount < *numFiles; fileCount++) |
543 fnames[fileCount] = NULL; | 544 fnames[fileCount] = NULL; |
544 | 545 |
545 /* Scan the list of FSSpec */ | 546 // Scan the list of FSSpec |
546 for (fileCount = 1; fileCount <= *numFiles; fileCount++) | 547 for (fileCount = 1; fileCount <= *numFiles; fileCount++) |
547 { | 548 { |
548 /* Get the alias for the nth file, convert to an FSSpec */ | 549 // Get the alias for the nth file, convert to an FSSpec |
549 newError = AEGetNthPtr(theList, fileCount, typeFSS, | 550 newError = AEGetNthPtr(theList, fileCount, typeFSS, |
550 &dummyKeyword, &dummyType, | 551 &dummyKeyword, &dummyType, |
551 (Ptr) &fileToOpen, sizeof(FSSpec), &actualSize); | 552 (Ptr) &fileToOpen, sizeof(FSSpec), &actualSize); |
552 if (newError) | 553 if (newError) |
553 { | 554 { |
554 /* Caller is able to clean up */ | 555 // Caller is able to clean up |
555 /* TODO: Should be clean up or not? For safety. */ | 556 // TODO: Should be clean up or not? For safety. |
556 return fnames; | 557 return fnames; |
557 } | 558 } |
558 | 559 |
559 /* Convert the FSSpec to a pathname */ | 560 // Convert the FSSpec to a pathname |
560 fnames[fileCount - 1] = FullPathFromFSSpec_save(fileToOpen); | 561 fnames[fileCount - 1] = FullPathFromFSSpec_save(fileToOpen); |
561 } | 562 } |
562 | 563 |
563 return (fnames); | 564 return (fnames); |
564 } | 565 } |
593 * not opened, put the value fnfErr(file not found) in that location. | 594 * not opened, put the value fnfErr(file not found) in that location. |
594 * | 595 * |
595 */ | 596 */ |
596 | 597 |
597 typedef struct WindowSearch WindowSearch; | 598 typedef struct WindowSearch WindowSearch; |
598 struct WindowSearch /* for handling class 'KAHL', event 'SRCH', keyDirectObject typeChar*/ | 599 struct WindowSearch // for handling class 'KAHL', event 'SRCH', keyDirectObject typeChar |
599 { | 600 { |
600 FSSpec theFile; // identifies the file | 601 FSSpec theFile; // identifies the file |
601 long *theDate; // where to put the modification date/time | 602 long *theDate; // where to put the modification date/time |
602 }; | 603 }; |
603 | 604 |
666 * each open file that has been modified. | 667 * each open file that has been modified. |
667 * | 668 * |
668 */ | 669 */ |
669 | 670 |
670 typedef struct ModificationInfo ModificationInfo; | 671 typedef struct ModificationInfo ModificationInfo; |
671 struct ModificationInfo /* for replying to class 'KAHL', event 'MOD ', keyDirectObject typeAEList*/ | 672 struct ModificationInfo // for replying to class 'KAHL', event 'MOD ', keyDirectObject typeAEList |
672 { | 673 { |
673 FSSpec theFile; // identifies the file | 674 FSSpec theFile; // identifies the file |
674 long theDate; // the date/time the file was last modified | 675 long theDate; // the date/time the file was last modified |
675 short saved; // set this to zero when replying, unused | 676 short saved; // set this to zero when replying, unused |
676 }; | 677 }; |
691 | 692 |
692 error = HandleUnusedParms(theAEvent); | 693 error = HandleUnusedParms(theAEvent); |
693 if (error) | 694 if (error) |
694 return error; | 695 return error; |
695 | 696 |
696 /* Send the reply */ | 697 // Send the reply |
697 /* replyObject.descriptorType = typeNull; | 698 // replyObject.descriptorType = typeNull; |
698 replyObject.dataHandle = nil;*/ | 699 // replyObject.dataHandle = nil; |
699 | 700 |
700 /* AECreateDesc(typeChar, (Ptr)&title[1], title[0], &data) */ | 701 // AECreateDesc(typeChar, (Ptr)&title[1], title[0], &data) |
701 error = AECreateList(nil, 0, false, &replyList); | 702 error = AECreateList(nil, 0, false, &replyList); |
702 if (error) | 703 if (error) |
703 return error; | 704 return error; |
704 | 705 |
705 #if 0 | 706 #if 0 |
706 error = AECountItems(&replyList, &numFiles); | 707 error = AECountItems(&replyList, &numFiles); |
707 | 708 |
708 /* AEPutKeyDesc(&replyList, keyAEPnject, &aDesc) | 709 // AEPutKeyDesc(&replyList, keyAEPnject, &aDesc) |
709 * AEPutKeyPtr(&replyList, keyAEPosition, typeChar, (Ptr)&theType, | 710 // AEPutKeyPtr(&replyList, keyAEPosition, typeChar, (Ptr)&theType, |
710 * sizeof(DescType)) | 711 // sizeof(DescType)) |
711 */ | 712 |
712 | 713 // AEPutDesc |
713 /* AEPutDesc */ | |
714 #endif | 714 #endif |
715 | 715 |
716 numFiles = 0; | 716 numFiles = 0; |
717 FOR_ALL_BUFFERS(buf) | 717 FOR_ALL_BUFFERS(buf) |
718 if (buf->b_ml.ml_mfp != NULL) | 718 if (buf->b_ml.ml_mfp != NULL) |
719 { | 719 { |
720 /* Add this file to the list */ | 720 // Add this file to the list |
721 theFile.theFile = buf->b_FSSpec; | 721 theFile.theFile = buf->b_FSSpec; |
722 theFile.theDate = buf->b_mtime; | 722 theFile.theDate = buf->b_mtime; |
723 /* theFile.theDate = time(NULL) & (time_t) 0xFFFFFFF0; */ | 723 // theFile.theDate = time(NULL) & (time_t) 0xFFFFFFF0; |
724 error = AEPutPtr(&replyList, numFiles, typeChar, (Ptr) &theFile, sizeof(theFile)); | 724 error = AEPutPtr(&replyList, numFiles, typeChar, (Ptr) &theFile, sizeof(theFile)); |
725 }; | 725 }; |
726 | 726 |
727 #if 0 | 727 #if 0 |
728 error = AECountItems(&replyList, &numFiles); | 728 error = AECountItems(&replyList, &numFiles); |
729 #endif | 729 #endif |
730 | 730 |
731 /* We can add data only if something to reply */ | 731 // We can add data only if something to reply |
732 error = AEPutParamDesc(theReply, keyDirectObject, &replyList); | 732 error = AEPutParamDesc(theReply, keyDirectObject, &replyList); |
733 | 733 |
734 if (replyList.dataHandle) | 734 if (replyList.dataHandle) |
735 AEDisposeDesc(&replyList); | 735 AEDisposeDesc(&replyList); |
736 | 736 |
762 * theText. | 762 * theText. |
763 * | 763 * |
764 */ | 764 */ |
765 | 765 |
766 typedef struct CW_GetText CW_GetText; | 766 typedef struct CW_GetText CW_GetText; |
767 struct CW_GetText /* for handling class 'KAHL', event 'GTTX', keyDirectObject typeChar*/ | 767 struct CW_GetText // for handling class 'KAHL', event 'GTTX', keyDirectObject typeChar |
768 { | 768 { |
769 FSSpec theFile; /* identifies the file */ | 769 FSSpec theFile; // identifies the file |
770 Handle theText; /* the location where you return the text (must be resized properly) */ | 770 Handle theText; // the location where you return the text (must be resized properly) |
771 long *unused; /* 0 (not used) */ | 771 long *unused; // 0 (not used) |
772 long *theDate; /* where to put the modification date/time */ | 772 long *theDate; // where to put the modification date/time |
773 }; | 773 }; |
774 | 774 |
775 pascal OSErr | 775 pascal OSErr |
776 Handle_KAHL_GTTX_AE( | 776 Handle_KAHL_GTTX_AE( |
777 const AppleEvent *theAEvent, | 777 const AppleEvent *theAEvent, |
804 break; | 804 break; |
805 } | 805 } |
806 | 806 |
807 if (foundFile) | 807 if (foundFile) |
808 { | 808 { |
809 BufferSize = 0; /* GetHandleSize(GetTextData.theText); */ | 809 BufferSize = 0; // GetHandleSize(GetTextData.theText); |
810 for (lineno = 0; lineno <= buf->b_ml.ml_line_count; lineno++) | 810 for (lineno = 0; lineno <= buf->b_ml.ml_line_count; lineno++) |
811 { | 811 { |
812 /* Must use the right buffer */ | 812 // Must use the right buffer |
813 line = ml_get_buf(buf, (linenr_T) lineno, FALSE); | 813 line = ml_get_buf(buf, (linenr_T) lineno, FALSE); |
814 linesize = STRLEN(line) + 1; | 814 linesize = STRLEN(line) + 1; |
815 lineStart = BufferSize; | 815 lineStart = BufferSize; |
816 BufferSize += linesize; | 816 BufferSize += linesize; |
817 /* Resize handle to linesize+1 to include the linefeed */ | 817 // Resize handle to linesize+1 to include the linefeed |
818 SetHandleSize(GetTextData.theText, BufferSize); | 818 SetHandleSize(GetTextData.theText, BufferSize); |
819 if (GetHandleSize(GetTextData.theText) != BufferSize) | 819 if (GetHandleSize(GetTextData.theText) != BufferSize) |
820 { | 820 { |
821 break; /* Simple handling for now */ | 821 break; // Simple handling for now |
822 } | 822 } |
823 else | 823 else |
824 { | 824 { |
825 HLock(GetTextData.theText); | 825 HLock(GetTextData.theText); |
826 fullbuffer = (char_u *) *GetTextData.theText; | 826 fullbuffer = (char_u *) *GetTextData.theText; |
836 HUnlock(GetTextData.theText); | 836 HUnlock(GetTextData.theText); |
837 } | 837 } |
838 if (foundFile == false) | 838 if (foundFile == false) |
839 *GetTextData.theDate = fnfErr; | 839 *GetTextData.theDate = fnfErr; |
840 else | 840 else |
841 /* *GetTextData.theDate = time(NULL) & (time_t) 0xFFFFFFF0;*/ | 841 // *GetTextData.theDate = time(NULL) & (time_t) 0xFFFFFFF0; |
842 *GetTextData.theDate = buf->b_mtime; | 842 *GetTextData.theDate = buf->b_mtime; |
843 } | 843 } |
844 | 844 |
845 error = HandleUnusedParms(theAEvent); | 845 error = HandleUnusedParms(theAEvent); |
846 | 846 |
849 | 849 |
850 /* | 850 /* |
851 * | 851 * |
852 */ | 852 */ |
853 | 853 |
854 /* Taken from MoreAppleEvents:ProcessHelpers*/ | 854 /* |
855 * Taken from MoreAppleEvents:ProcessHelpers | |
856 */ | |
855 pascal OSErr | 857 pascal OSErr |
856 FindProcessBySignature( | 858 FindProcessBySignature( |
857 const OSType targetType, | 859 const OSType targetType, |
858 const OSType targetCreator, | 860 const OSType targetCreator, |
859 ProcessSerialNumberPtr psnPtr) | 861 ProcessSerialNumberPtr psnPtr) |
913 kAutoGenerateReturnID, kAnyTransactionID, &theEvent); | 915 kAutoGenerateReturnID, kAnyTransactionID, &theEvent); |
914 } | 916 } |
915 | 917 |
916 AEDisposeDesc(&targetAppDesc); | 918 AEDisposeDesc(&targetAppDesc); |
917 | 919 |
918 /* Add the parms */ | 920 // Add the parms |
919 ModData.theFile = buf->b_FSSpec; | 921 ModData.theFile = buf->b_FSSpec; |
920 ModData.theDate = buf->b_mtime; | 922 ModData.theDate = buf->b_mtime; |
921 | 923 |
922 if (anErr == noErr) | 924 if (anErr == noErr) |
923 anErr = AEPutParamPtr(&theEvent, keyDirectObject, typeChar, &ModData, sizeof(ModData)); | 925 anErr = AEPutParamPtr(&theEvent, keyDirectObject, typeChar, &ModData, sizeof(ModData)); |
929 | 931 |
930 if (anErr == noErr) | 932 if (anErr == noErr) |
931 anErr = AESend(&theEvent, &theReply, sendMode, kAENormalPriority, kNoTimeOut, idleProcUPP, nil); | 933 anErr = AESend(&theEvent, &theReply, sendMode, kAENormalPriority, kNoTimeOut, idleProcUPP, nil); |
932 if (anErr == noErr && sendMode == kAEWaitReply) | 934 if (anErr == noErr && sendMode == kAEWaitReply) |
933 { | 935 { |
934 /* anErr = AEHGetHandlerError(&theReply);*/ | 936 // anErr = AEHGetHandlerError(&theReply); |
935 } | 937 } |
936 (void) AEDisposeDesc(&theReply); | 938 (void) AEDisposeDesc(&theReply); |
937 } | 939 } |
938 } | 940 } |
939 #endif /* FEAT_CW_EDITOR */ | 941 #endif // FEAT_CW_EDITOR |
940 | 942 |
941 /* | 943 /* |
942 * ------------------------------------------------------------ | 944 * ------------------------------------------------------------ |
943 * Apple Event Handling procedure | 945 * Apple Event Handling procedure |
944 * ------------------------------------------------------------ | 946 * ------------------------------------------------------------ |
955 OSErr error; | 957 OSErr error; |
956 long actualSize; | 958 long actualSize; |
957 DescType dummyType; | 959 DescType dummyType; |
958 AEKeyword missedKeyword; | 960 AEKeyword missedKeyword; |
959 | 961 |
960 /* Get the "missed keyword" attribute from the AppleEvent. */ | 962 // Get the "missed keyword" attribute from the AppleEvent. |
961 error = AEGetAttributePtr(theAEvent, keyMissedKeywordAttr, | 963 error = AEGetAttributePtr(theAEvent, keyMissedKeywordAttr, |
962 typeKeyword, &dummyType, | 964 typeKeyword, &dummyType, |
963 (Ptr)&missedKeyword, sizeof(missedKeyword), | 965 (Ptr)&missedKeyword, sizeof(missedKeyword), |
964 &actualSize); | 966 &actualSize); |
965 | 967 |
966 /* If the descriptor isn't found, then we got the required parameters. */ | 968 // If the descriptor isn't found, then we got the required parameters. |
967 if (error == errAEDescNotFound) | 969 if (error == errAEDescNotFound) |
968 { | 970 { |
969 error = noErr; | 971 error = noErr; |
970 } | 972 } |
971 else | 973 else |
972 { | 974 { |
973 #if 0 | 975 #if 0 |
974 /* Why is this removed? */ | 976 // Why is this removed? |
975 error = errAEEventNotHandled; | 977 error = errAEEventNotHandled; |
976 #endif | 978 #endif |
977 } | 979 } |
978 | 980 |
979 return error; | 981 return error; |
986 * Deals with all files dragged to the application icon. | 988 * Deals with all files dragged to the application icon. |
987 * | 989 * |
988 */ | 990 */ |
989 | 991 |
990 typedef struct SelectionRange SelectionRange; | 992 typedef struct SelectionRange SelectionRange; |
991 struct SelectionRange /* for handling kCoreClassEvent:kOpenDocuments:keyAEPosition typeChar */ | 993 struct SelectionRange // for handling kCoreClassEvent:kOpenDocuments:keyAEPosition typeChar |
992 { | 994 { |
993 short unused1; // 0 (not used) | 995 short unused1; // 0 (not used) |
994 short lineNum; // line to select (<0 to specify range) | 996 short lineNum; // line to select (<0 to specify range) |
995 long startRange; // start of selection range (if line < 0) | 997 long startRange; // start of selection range (if line < 0) |
996 long endRange; // end of selection range (if line < 0) | 998 long endRange; // end of selection range (if line < 0) |
1003 static SelectionRange drop_thePosition; | 1005 static SelectionRange drop_thePosition; |
1004 | 1006 |
1005 static void | 1007 static void |
1006 drop_callback(void *cookie UNUSED) | 1008 drop_callback(void *cookie UNUSED) |
1007 { | 1009 { |
1008 /* TODO: Handle the goto/select line more cleanly */ | 1010 // TODO: Handle the goto/select line more cleanly |
1009 if ((drop_numFiles == 1) & (drop_gotPosition)) | 1011 if ((drop_numFiles == 1) & (drop_gotPosition)) |
1010 { | 1012 { |
1011 if (drop_thePosition.lineNum >= 0) | 1013 if (drop_thePosition.lineNum >= 0) |
1012 { | 1014 { |
1013 lnum = drop_thePosition.lineNum + 1; | 1015 lnum = drop_thePosition.lineNum + 1; |
1014 /* oap->motion_type = MLINE; | 1016 // oap->motion_type = MLINE; |
1015 setpcmark();*/ | 1017 // setpcmark(); |
1016 if (lnum < 1L) | 1018 if (lnum < 1L) |
1017 lnum = 1L; | 1019 lnum = 1L; |
1018 else if (lnum > curbuf->b_ml.ml_line_count) | 1020 else if (lnum > curbuf->b_ml.ml_line_count) |
1019 lnum = curbuf->b_ml.ml_line_count; | 1021 lnum = curbuf->b_ml.ml_line_count; |
1020 curwin->w_cursor.lnum = lnum; | 1022 curwin->w_cursor.lnum = lnum; |
1021 curwin->w_cursor.col = 0; | 1023 curwin->w_cursor.col = 0; |
1022 /* beginline(BL_SOL | BL_FIX);*/ | 1024 // beginline(BL_SOL | BL_FIX); |
1023 } | 1025 } |
1024 else | 1026 else |
1025 goto_byte(drop_thePosition.startRange + 1); | 1027 goto_byte(drop_thePosition.startRange + 1); |
1026 } | 1028 } |
1027 | 1029 |
1028 /* Update the screen display */ | 1030 // Update the screen display |
1029 update_screen(NOT_VALID); | 1031 update_screen(NOT_VALID); |
1030 | 1032 |
1031 /* Select the text if possible */ | 1033 // Select the text if possible |
1032 if (drop_gotPosition) | 1034 if (drop_gotPosition) |
1033 { | 1035 { |
1034 VIsual_active = TRUE; | 1036 VIsual_active = TRUE; |
1035 VIsual_select = FALSE; | 1037 VIsual_select = FALSE; |
1036 VIsual = curwin->w_cursor; | 1038 VIsual = curwin->w_cursor; |
1045 VIsual.col = 0; | 1047 VIsual.col = 0; |
1046 } | 1048 } |
1047 } | 1049 } |
1048 } | 1050 } |
1049 | 1051 |
1050 /* The IDE uses the optional keyAEPosition parameter to tell the ed- | 1052 /* |
1051 itor the selection range. If lineNum is zero or greater, scroll the text | 1053 * The IDE uses the optional keyAEPosition parameter to tell the ed- |
1052 to the specified line. If lineNum is less than zero, use the values in | 1054 * itor the selection range. If lineNum is zero or greater, scroll the text |
1053 startRange and endRange to select the specified characters. Scroll | 1055 * to the specified line. If lineNum is less than zero, use the values in |
1054 the text to display the selection. If lineNum, startRange, and | 1056 * startRange and endRange to select the specified characters. Scroll |
1055 endRange are all negative, there is no selection range specified. | 1057 * the text to display the selection. If lineNum, startRange, and |
1056 */ | 1058 * endRange are all negative, there is no selection range specified. |
1057 | 1059 */ |
1058 pascal OSErr | 1060 pascal OSErr |
1059 HandleODocAE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) | 1061 HandleODocAE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon) |
1060 { | 1062 { |
1061 /* | 1063 /* |
1062 * TODO: Clean up the code with convert the AppleEvent into | 1064 * TODO: Clean up the code with convert the AppleEvent into |
1074 Size actualSize; | 1076 Size actualSize; |
1075 SelectionRange thePosition; | 1077 SelectionRange thePosition; |
1076 short gotPosition = false; | 1078 short gotPosition = false; |
1077 long lnum; | 1079 long lnum; |
1078 | 1080 |
1079 /* the direct object parameter is the list of aliases to files (one or more) */ | 1081 // the direct object parameter is the list of aliases to files (one or more) |
1080 error = AEGetParamDesc(theAEvent, keyDirectObject, typeAEList, &theList); | 1082 error = AEGetParamDesc(theAEvent, keyDirectObject, typeAEList, &theList); |
1081 if (error) | 1083 if (error) |
1082 return error; | 1084 return error; |
1083 | 1085 |
1084 | 1086 |
1109 reset_VIsual(); | 1111 reset_VIsual(); |
1110 fnames = new_fnames_from_AEDesc(&theList, &numFiles, &error); | 1112 fnames = new_fnames_from_AEDesc(&theList, &numFiles, &error); |
1111 | 1113 |
1112 if (error) | 1114 if (error) |
1113 { | 1115 { |
1114 /* TODO: empty fnames[] first */ | 1116 // TODO: empty fnames[] first |
1115 vim_free(fnames); | 1117 vim_free(fnames); |
1116 return (error); | 1118 return (error); |
1117 } | 1119 } |
1118 | 1120 |
1119 if (starting > 0) | 1121 if (starting > 0) |
1120 { | 1122 { |
1121 int i; | 1123 int i; |
1122 char_u *p; | 1124 char_u *p; |
1123 int fnum = -1; | 1125 int fnum = -1; |
1124 | 1126 |
1125 /* these are the initial files dropped on the Vim icon */ | 1127 // these are the initial files dropped on the Vim icon |
1126 for (i = 0 ; i < numFiles; i++) | 1128 for (i = 0 ; i < numFiles; i++) |
1127 { | 1129 { |
1128 if (ga_grow(&global_alist.al_ga, 1) == FAIL | 1130 if (ga_grow(&global_alist.al_ga, 1) == FAIL |
1129 || (p = vim_strsave(fnames[i])) == NULL) | 1131 || (p = vim_strsave(fnames[i])) == NULL) |
1130 mch_exit(2); | 1132 mch_exit(2); |
1132 alist_add(&global_alist, p, 2); | 1134 alist_add(&global_alist, p, 2); |
1133 if (fnum == -1) | 1135 if (fnum == -1) |
1134 fnum = GARGLIST[GARGCOUNT - 1].ae_fnum; | 1136 fnum = GARGLIST[GARGCOUNT - 1].ae_fnum; |
1135 } | 1137 } |
1136 | 1138 |
1137 /* If the file name was already in the buffer list we need to switch | 1139 // If the file name was already in the buffer list we need to switch |
1138 * to it. */ | 1140 // to it. |
1139 if (curbuf->b_fnum != fnum) | 1141 if (curbuf->b_fnum != fnum) |
1140 { | 1142 { |
1141 char_u cmd[30]; | 1143 char_u cmd[30]; |
1142 | 1144 |
1143 vim_snprintf((char *)cmd, 30, "silent %dbuffer", fnum); | 1145 vim_snprintf((char *)cmd, 30, "silent %dbuffer", fnum); |
1144 do_cmdline_cmd(cmd); | 1146 do_cmdline_cmd(cmd); |
1145 } | 1147 } |
1146 | 1148 |
1147 /* Change directory to the location of the first file. */ | 1149 // Change directory to the location of the first file. |
1148 if (GARGCOUNT > 0 | 1150 if (GARGCOUNT > 0 |
1149 && vim_chdirfile(alist_name(&GARGLIST[0]), "drop") == OK) | 1151 && vim_chdirfile(alist_name(&GARGLIST[0]), "drop") == OK) |
1150 shorten_fnames(TRUE); | 1152 shorten_fnames(TRUE); |
1151 | 1153 |
1152 goto finished; | 1154 goto finished; |
1153 } | 1155 } |
1154 | 1156 |
1155 /* Handle the drop, :edit to get to the file */ | 1157 // Handle the drop, :edit to get to the file |
1156 drop_numFiles = numFiles; | 1158 drop_numFiles = numFiles; |
1157 drop_gotPosition = gotPosition; | 1159 drop_gotPosition = gotPosition; |
1158 drop_thePosition = thePosition; | 1160 drop_thePosition = thePosition; |
1159 handle_drop(numFiles, fnames, FALSE, drop_callback, NULL); | 1161 handle_drop(numFiles, fnames, FALSE, drop_callback, NULL); |
1160 | 1162 |
1161 setcursor(); | 1163 setcursor(); |
1162 out_flush(); | 1164 out_flush(); |
1163 | 1165 |
1164 /* Fake mouse event to wake from stall */ | 1166 // Fake mouse event to wake from stall |
1165 PostEvent(mouseUp, 0); | 1167 PostEvent(mouseUp, 0); |
1166 | 1168 |
1167 finished: | 1169 finished: |
1168 AEDisposeDesc(&theList); /* dispose what we allocated */ | 1170 AEDisposeDesc(&theList); // dispose what we allocated |
1169 | 1171 |
1170 error = HandleUnusedParms(theAEvent); | 1172 error = HandleUnusedParms(theAEvent); |
1171 return error; | 1173 return error; |
1172 } | 1174 } |
1173 | 1175 |
1174 /* | 1176 /* |
1175 * | 1177 * |
1176 */ | 1178 */ |
1177 | |
1178 pascal OSErr | 1179 pascal OSErr |
1179 Handle_aevt_oapp_AE( | 1180 Handle_aevt_oapp_AE( |
1180 const AppleEvent *theAEvent, | 1181 const AppleEvent *theAEvent, |
1181 AppleEvent *theReply, | 1182 AppleEvent *theReply, |
1182 long refCon) | 1183 long refCon) |
1188 } | 1189 } |
1189 | 1190 |
1190 /* | 1191 /* |
1191 * | 1192 * |
1192 */ | 1193 */ |
1193 | |
1194 pascal OSErr | 1194 pascal OSErr |
1195 Handle_aevt_quit_AE( | 1195 Handle_aevt_quit_AE( |
1196 const AppleEvent *theAEvent, | 1196 const AppleEvent *theAEvent, |
1197 AppleEvent *theReply, | 1197 AppleEvent *theReply, |
1198 long refCon) | 1198 long refCon) |
1201 | 1201 |
1202 error = HandleUnusedParms(theAEvent); | 1202 error = HandleUnusedParms(theAEvent); |
1203 if (error) | 1203 if (error) |
1204 return error; | 1204 return error; |
1205 | 1205 |
1206 /* Need to fake a :confirm qa */ | 1206 // Need to fake a :confirm qa |
1207 do_cmdline_cmd((char_u *)"confirm qa"); | 1207 do_cmdline_cmd((char_u *)"confirm qa"); |
1208 | 1208 |
1209 return error; | 1209 return error; |
1210 } | 1210 } |
1211 | 1211 |
1212 /* | 1212 /* |
1213 * | 1213 * |
1214 */ | 1214 */ |
1215 | |
1216 pascal OSErr | 1215 pascal OSErr |
1217 Handle_aevt_pdoc_AE( | 1216 Handle_aevt_pdoc_AE( |
1218 const AppleEvent *theAEvent, | 1217 const AppleEvent *theAEvent, |
1219 AppleEvent *theReply, | 1218 AppleEvent *theReply, |
1220 long refCon) | 1219 long refCon) |
1251 OSErr | 1250 OSErr |
1252 InstallAEHandlers(void) | 1251 InstallAEHandlers(void) |
1253 { | 1252 { |
1254 OSErr error; | 1253 OSErr error; |
1255 | 1254 |
1256 /* install open application handler */ | 1255 // install open application handler |
1257 error = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, | 1256 error = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, |
1258 NewAEEventHandlerUPP(Handle_aevt_oapp_AE), 0, false); | 1257 NewAEEventHandlerUPP(Handle_aevt_oapp_AE), 0, false); |
1259 if (error) | 1258 if (error) |
1260 return error; | 1259 return error; |
1261 | 1260 |
1262 /* install quit application handler */ | 1261 // install quit application handler |
1263 error = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, | 1262 error = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, |
1264 NewAEEventHandlerUPP(Handle_aevt_quit_AE), 0, false); | 1263 NewAEEventHandlerUPP(Handle_aevt_quit_AE), 0, false); |
1265 if (error) | 1264 if (error) |
1266 return error; | 1265 return error; |
1267 | 1266 |
1268 /* install open document handler */ | 1267 // install open document handler |
1269 error = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, | 1268 error = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, |
1270 NewAEEventHandlerUPP(HandleODocAE), 0, false); | 1269 NewAEEventHandlerUPP(HandleODocAE), 0, false); |
1271 if (error) | 1270 if (error) |
1272 return error; | 1271 return error; |
1273 | 1272 |
1274 /* install print document handler */ | 1273 // install print document handler |
1275 error = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, | 1274 error = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, |
1276 NewAEEventHandlerUPP(Handle_aevt_pdoc_AE), 0, false); | 1275 NewAEEventHandlerUPP(Handle_aevt_pdoc_AE), 0, false); |
1277 | 1276 |
1278 /* Install Core Suite */ | 1277 // Install Core Suite |
1279 /* error = AEInstallEventHandler(kAECoreSuite, kAEClone, | 1278 #if 0 |
1279 error = AEInstallEventHandler(kAECoreSuite, kAEClone, | |
1280 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false); | 1280 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false); |
1281 | 1281 |
1282 error = AEInstallEventHandler(kAECoreSuite, kAEClose, | 1282 error = AEInstallEventHandler(kAECoreSuite, kAEClose, |
1283 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false); | 1283 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false); |
1284 | 1284 |
1312 error = AEInstallEventHandler(kAECoreSuite, kAESave, | 1312 error = AEInstallEventHandler(kAECoreSuite, kAESave, |
1313 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false); | 1313 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false); |
1314 | 1314 |
1315 error = AEInstallEventHandler(kAECoreSuite, kAESetData, | 1315 error = AEInstallEventHandler(kAECoreSuite, kAESetData, |
1316 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false); | 1316 NewAEEventHandlerUPP(Handle_unknown_AE), nil, false); |
1317 */ | 1317 #endif |
1318 | 1318 |
1319 #ifdef FEAT_CW_EDITOR | 1319 #ifdef FEAT_CW_EDITOR |
1320 /* | 1320 /* |
1321 * Bind codewarrior support handlers | 1321 * Bind codewarrior support handlers |
1322 */ | 1322 */ |
1333 #endif | 1333 #endif |
1334 | 1334 |
1335 return error; | 1335 return error; |
1336 | 1336 |
1337 } | 1337 } |
1338 #endif /* USE_AEVENT */ | 1338 #endif // USE_AEVENT |
1339 | 1339 |
1340 | 1340 |
1341 /* | 1341 /* |
1342 * Callback function, installed by InstallFontPanelHandler(), below, | 1342 * Callback function, installed by InstallFontPanelHandler(), below, |
1343 * to handle Font Panel events. | 1343 * to handle Font Panel events. |
1359 OSStatus status; | 1359 OSStatus status; |
1360 FMFontFamily newFamily; | 1360 FMFontFamily newFamily; |
1361 FMFontSize newSize; | 1361 FMFontSize newSize; |
1362 FMFontStyle newStyle; | 1362 FMFontStyle newStyle; |
1363 | 1363 |
1364 /* Retrieve the font family ID number. */ | 1364 // Retrieve the font family ID number. |
1365 status = GetEventParameter(inEvent, kEventParamFMFontFamily, | 1365 status = GetEventParameter(inEvent, kEventParamFMFontFamily, |
1366 /*inDesiredType=*/typeFMFontFamily, /*outActualType=*/NULL, | 1366 /*inDesiredType=*/typeFMFontFamily, /*outActualType=*/NULL, |
1367 /*inBufferSize=*/sizeof(FMFontFamily), /*outActualSize=*/NULL, | 1367 /*inBufferSize=*/sizeof(FMFontFamily), /*outActualSize=*/NULL, |
1368 &newFamily); | 1368 &newFamily); |
1369 if (status == noErr) | 1369 if (status == noErr) |
1370 gFontPanelInfo.family = newFamily; | 1370 gFontPanelInfo.family = newFamily; |
1371 | 1371 |
1372 /* Retrieve the font size. */ | 1372 // Retrieve the font size. |
1373 status = GetEventParameter(inEvent, kEventParamFMFontSize, | 1373 status = GetEventParameter(inEvent, kEventParamFMFontSize, |
1374 typeFMFontSize, NULL, sizeof(FMFontSize), NULL, &newSize); | 1374 typeFMFontSize, NULL, sizeof(FMFontSize), NULL, &newSize); |
1375 if (status == noErr) | 1375 if (status == noErr) |
1376 gFontPanelInfo.size = newSize; | 1376 gFontPanelInfo.size = newSize; |
1377 | 1377 |
1378 /* Retrieve the font style (bold, etc.). Currently unused. */ | 1378 // Retrieve the font style (bold, etc.). Currently unused. |
1379 status = GetEventParameter(inEvent, kEventParamFMFontStyle, | 1379 status = GetEventParameter(inEvent, kEventParamFMFontStyle, |
1380 typeFMFontStyle, NULL, sizeof(FMFontStyle), NULL, &newStyle); | 1380 typeFMFontStyle, NULL, sizeof(FMFontStyle), NULL, &newStyle); |
1381 if (status == noErr) | 1381 if (status == noErr) |
1382 gFontPanelInfo.style = newStyle; | 1382 gFontPanelInfo.style = newStyle; |
1383 } | 1383 } |
1388 static void | 1388 static void |
1389 InstallFontPanelHandler(void) | 1389 InstallFontPanelHandler(void) |
1390 { | 1390 { |
1391 EventTypeSpec eventTypes[2]; | 1391 EventTypeSpec eventTypes[2]; |
1392 EventHandlerUPP handlerUPP; | 1392 EventHandlerUPP handlerUPP; |
1393 /* EventHandlerRef handlerRef; */ | 1393 // EventHandlerRef handlerRef; |
1394 | 1394 |
1395 eventTypes[0].eventClass = kEventClassFont; | 1395 eventTypes[0].eventClass = kEventClassFont; |
1396 eventTypes[0].eventKind = kEventFontSelection; | 1396 eventTypes[0].eventKind = kEventFontSelection; |
1397 eventTypes[1].eventClass = kEventClassFont; | 1397 eventTypes[1].eventClass = kEventClassFont; |
1398 eventTypes[1].eventKind = kEventFontPanelClosed; | 1398 eventTypes[1].eventKind = kEventFontPanelClosed; |
1420 if (!outName) | 1420 if (!outName) |
1421 return; | 1421 return; |
1422 | 1422 |
1423 if (FMGetFontFamilyName(gFontPanelInfo.family, buf) == noErr) | 1423 if (FMGetFontFamilyName(gFontPanelInfo.family, buf) == noErr) |
1424 { | 1424 { |
1425 /* Canonicalize localized font names */ | 1425 // Canonicalize localized font names |
1426 if (FMGetFontFromFontFamilyInstance(gFontPanelInfo.family, | 1426 if (FMGetFontFromFontFamilyInstance(gFontPanelInfo.family, |
1427 gFontPanelInfo.style, &fid, NULL) != noErr) | 1427 gFontPanelInfo.style, &fid, NULL) != noErr) |
1428 return; | 1428 return; |
1429 | 1429 |
1430 /* Request font name with Mac encoding (otherwise we could | 1430 // Request font name with Mac encoding (otherwise we could |
1431 * get an unwanted utf-16 name) */ | 1431 // get an unwanted utf-16 name) |
1432 if (ATSUFindFontName(fid, kFontFullName, kFontMacintoshPlatform, | 1432 if (ATSUFindFontName(fid, kFontFullName, kFontMacintoshPlatform, |
1433 kFontNoScriptCode, kFontNoLanguageCode, | 1433 kFontNoScriptCode, kFontNoLanguageCode, |
1434 255, (char *)outName, &fontNameLen, NULL) != noErr) | 1434 255, (char *)outName, &fontNameLen, NULL) != noErr) |
1435 return; | 1435 return; |
1436 | 1436 |
1437 /* Only encode font size, because style (bold, italic, etc) is | 1437 // Only encode font size, because style (bold, italic, etc) is |
1438 * already part of the font full name */ | 1438 // already part of the font full name |
1439 vim_snprintf((char *)styleString, FONT_STYLE_BUFFER_SIZE, ":h%d", | 1439 vim_snprintf((char *)styleString, FONT_STYLE_BUFFER_SIZE, ":h%d", |
1440 gFontPanelInfo.size/*, | 1440 gFontPanelInfo.size/*, |
1441 ((gFontPanelInfo.style & bold)!=0 ? ":b" : ""), | 1441 ((gFontPanelInfo.style & bold)!=0 ? ":b" : ""), |
1442 ((gFontPanelInfo.style & italic)!=0 ? ":i" : ""), | 1442 ((gFontPanelInfo.style & italic)!=0 ? ":i" : ""), |
1443 ((gFontPanelInfo.style & underline)!=0 ? ":u" : "")*/); | 1443 ((gFontPanelInfo.style & underline)!=0 ? ":u" : "")*/); |
1461 /* | 1461 /* |
1462 * gui_mac_get_menu_item_index | 1462 * gui_mac_get_menu_item_index |
1463 * | 1463 * |
1464 * Returns the index inside the menu where | 1464 * Returns the index inside the menu where |
1465 */ | 1465 */ |
1466 short /* Should we return MenuItemIndex? */ | 1466 short // Should we return MenuItemIndex? |
1467 gui_mac_get_menu_item_index(vimmenu_T *pMenu) | 1467 gui_mac_get_menu_item_index(vimmenu_T *pMenu) |
1468 { | 1468 { |
1469 short index; | 1469 short index; |
1470 short itemIndex = -1; | 1470 short itemIndex = -1; |
1471 vimmenu_T *pBrother; | 1471 vimmenu_T *pBrother; |
1472 | 1472 |
1473 /* Only menu without parent are the: | 1473 // Only menu without parent are the: |
1474 * -menu in the menubar | 1474 // -menu in the menubar |
1475 * -popup menu | 1475 // -popup menu |
1476 * -toolbar (guess) | 1476 // -toolbar (guess) |
1477 * | 1477 // |
1478 * Which are not items anyway. | 1478 // Which are not items anyway. |
1479 */ | |
1480 if (pMenu->parent) | 1479 if (pMenu->parent) |
1481 { | 1480 { |
1482 /* Start from the Oldest Brother */ | 1481 // Start from the Oldest Brother |
1483 pBrother = pMenu->parent->children; | 1482 pBrother = pMenu->parent->children; |
1484 index = 1; | 1483 index = 1; |
1485 while ((pBrother) && (itemIndex == -1)) | 1484 while ((pBrother) && (itemIndex == -1)) |
1486 { | 1485 { |
1487 if (pBrother == pMenu) | 1486 if (pBrother == pMenu) |
1499 short index; | 1498 short index; |
1500 vimmenu_T *pChildMenu; | 1499 vimmenu_T *pChildMenu; |
1501 vimmenu_T *pElder = pMenu->parent; | 1500 vimmenu_T *pElder = pMenu->parent; |
1502 | 1501 |
1503 | 1502 |
1504 /* Only menu without parent are the: | 1503 // Only menu without parent are the: |
1505 * -menu in the menubar | 1504 // -menu in the menubar |
1506 * -popup menu | 1505 // -popup menu |
1507 * -toolbar (guess) | 1506 // -toolbar (guess) |
1508 * | 1507 // |
1509 * Which are not items anyway. | 1508 // Which are not items anyway. |
1510 */ | |
1511 | 1509 |
1512 if ((pElder) && (pElder->submenu_id == menuID)) | 1510 if ((pElder) && (pElder->submenu_id == menuID)) |
1513 { | 1511 { |
1514 for (index = 1; (index != itemIndex) && (pMenu != NULL); index++) | 1512 for (index = 1; (index != itemIndex) && (pMenu != NULL); index++) |
1515 pMenu = pMenu->next; | 1513 pMenu = pMenu->next; |
1552 sb = gui_find_scrollbar((long) GetControlReference(theControlToUse)); | 1550 sb = gui_find_scrollbar((long) GetControlReference(theControlToUse)); |
1553 | 1551 |
1554 if (sb == NULL) | 1552 if (sb == NULL) |
1555 return; | 1553 return; |
1556 | 1554 |
1557 /* Need to find value by diff between Old Poss New Pos */ | 1555 // Need to find value by diff between Old Poss New Pos |
1558 value = GetControl32BitValue(theControlToUse); | 1556 value = GetControl32BitValue(theControlToUse); |
1559 dragging = (partCode != 0); | 1557 dragging = (partCode != 0); |
1560 | 1558 |
1561 /* When "allow_scrollbar" is FALSE still need to remember the new | 1559 // When "allow_scrollbar" is FALSE still need to remember the new |
1562 * position, but don't actually scroll by setting "dont_scroll". */ | 1560 // position, but don't actually scroll by setting "dont_scroll". |
1563 dont_scroll = !allow_scrollbar; | 1561 dont_scroll = !allow_scrollbar; |
1564 gui_drag_scrollbar(sb, value, dragging); | 1562 gui_drag_scrollbar(sb, value, dragging); |
1565 dont_scroll = dont_scroll_save; | 1563 dont_scroll = dont_scroll_save; |
1566 } | 1564 } |
1567 | 1565 |
1568 pascal | 1566 pascal |
1569 void | 1567 void |
1570 gui_mac_scroll_action(ControlHandle theControl, short partCode) | 1568 gui_mac_scroll_action(ControlHandle theControl, short partCode) |
1571 { | 1569 { |
1572 /* TODO: have live support */ | 1570 // TODO: have live support |
1573 scrollbar_T *sb, *sb_info; | 1571 scrollbar_T *sb, *sb_info; |
1574 long data; | 1572 long data; |
1575 long value; | 1573 long value; |
1576 int page; | 1574 int page; |
1577 int dragging = FALSE; | 1575 int dragging = FALSE; |
1580 sb = gui_find_scrollbar((long)GetControlReference(theControl)); | 1578 sb = gui_find_scrollbar((long)GetControlReference(theControl)); |
1581 | 1579 |
1582 if (sb == NULL) | 1580 if (sb == NULL) |
1583 return; | 1581 return; |
1584 | 1582 |
1585 if (sb->wp != NULL) /* Left or right scrollbar */ | 1583 if (sb->wp != NULL) // Left or right scrollbar |
1586 { | 1584 { |
1587 /* | 1585 /* |
1588 * Careful: need to get scrollbar info out of first (left) scrollbar | 1586 * Careful: need to get scrollbar info out of first (left) scrollbar |
1589 * for window, but keep real scrollbar too because we must pass it to | 1587 * for window, but keep real scrollbar too because we must pass it to |
1590 * gui_drag_scrollbar(). | 1588 * gui_drag_scrollbar(). |
1591 */ | 1589 */ |
1592 sb_info = &sb->wp->w_scrollbars[0]; | 1590 sb_info = &sb->wp->w_scrollbars[0]; |
1593 | 1591 |
1594 if (sb_info->size > 5) | 1592 if (sb_info->size > 5) |
1595 page = sb_info->size - 2; /* use two lines of context */ | 1593 page = sb_info->size - 2; // use two lines of context |
1596 else | 1594 else |
1597 page = sb_info->size; | 1595 page = sb_info->size; |
1598 } | 1596 } |
1599 else /* Bottom scrollbar */ | 1597 else // Bottom scrollbar |
1600 { | 1598 { |
1601 sb_info = sb; | 1599 sb_info = sb; |
1602 page = curwin->w_width - 5; | 1600 page = curwin->w_width - 5; |
1603 } | 1601 } |
1604 | 1602 |
1610 case kControlPageUpPart: data = -page; break; | 1608 case kControlPageUpPart: data = -page; break; |
1611 default: data = 0; break; | 1609 default: data = 0; break; |
1612 } | 1610 } |
1613 | 1611 |
1614 value = sb_info->value + data; | 1612 value = sb_info->value + data; |
1615 /* if (value > sb_info->max) | 1613 // if (value > sb_info->max) |
1616 value = sb_info->max; | 1614 // value = sb_info->max; |
1617 else if (value < 0) | 1615 // else if (value < 0) |
1618 value = 0;*/ | 1616 // value = 0; |
1619 | 1617 |
1620 /* When "allow_scrollbar" is FALSE still need to remember the new | 1618 // When "allow_scrollbar" is FALSE still need to remember the new |
1621 * position, but don't actually scroll by setting "dont_scroll". */ | 1619 // position, but don't actually scroll by setting "dont_scroll". |
1622 dont_scroll = !allow_scrollbar; | 1620 dont_scroll = !allow_scrollbar; |
1623 gui_drag_scrollbar(sb, value, dragging); | 1621 gui_drag_scrollbar(sb, value, dragging); |
1624 dont_scroll = dont_scroll_save; | 1622 dont_scroll = dont_scroll_save; |
1625 | 1623 |
1626 out_flush(); | 1624 out_flush(); |
1627 gui_mch_set_scrollbar_thumb(sb, value, sb_info->size, sb_info->max); | 1625 gui_mch_set_scrollbar_thumb(sb, value, sb_info->size, sb_info->max); |
1628 | 1626 |
1629 /* if (sb_info->wp != NULL) | 1627 #if 0 |
1628 if (sb_info->wp != NULL) | |
1630 { | 1629 { |
1631 win_T *wp; | 1630 win_T *wp; |
1632 int sb_num; | 1631 int sb_num; |
1633 | 1632 |
1634 sb_num = 0; | 1633 sb_num = 0; |
1640 current_scrollbar = sb_num; | 1639 current_scrollbar = sb_num; |
1641 scrollbar_value = value; | 1640 scrollbar_value = value; |
1642 gui_do_scroll(); | 1641 gui_do_scroll(); |
1643 gui_mch_set_scrollbar_thumb(sb, value, sb_info->size, sb_info->max); | 1642 gui_mch_set_scrollbar_thumb(sb, value, sb_info->size, sb_info->max); |
1644 } | 1643 } |
1645 }*/ | 1644 } |
1645 #endif | |
1646 } | 1646 } |
1647 | 1647 |
1648 /* | 1648 /* |
1649 * ------------------------------------------------------------ | 1649 * ------------------------------------------------------------ |
1650 * MacOS Click Handling procedures | 1650 * MacOS Click Handling procedures |
1674 | 1674 |
1675 thePortion = FindControl(thePoint, whichWindow, &theControl); | 1675 thePortion = FindControl(thePoint, whichWindow, &theControl); |
1676 | 1676 |
1677 if (theControl != NUL) | 1677 if (theControl != NUL) |
1678 { | 1678 { |
1679 /* We hit a scrollbar */ | 1679 // We hit a scrollbar |
1680 | 1680 |
1681 if (thePortion != kControlIndicatorPart) | 1681 if (thePortion != kControlIndicatorPart) |
1682 { | 1682 { |
1683 dragged_sb = theControl; | 1683 dragged_sb = theControl; |
1684 TrackControl(theControl, thePoint, gScrollAction); | 1684 TrackControl(theControl, thePoint, gScrollAction); |
1690 #if 1 | 1690 #if 1 |
1691 TrackControl(theControl, thePoint, gScrollDrag); | 1691 TrackControl(theControl, thePoint, gScrollDrag); |
1692 #else | 1692 #else |
1693 TrackControl(theControl, thePoint, NULL); | 1693 TrackControl(theControl, thePoint, NULL); |
1694 #endif | 1694 #endif |
1695 /* pass 0 as the part to tell gui_mac_drag_thumb, that the mouse | 1695 // pass 0 as the part to tell gui_mac_drag_thumb, that the mouse |
1696 * button has been released */ | 1696 // button has been released |
1697 gui_mac_drag_thumb(theControl, 0); /* Should it be thePortion ? (Dany) */ | 1697 gui_mac_drag_thumb(theControl, 0); // Should it be thePortion ? (Dany) |
1698 dragged_sb = NULL; | 1698 dragged_sb = NULL; |
1699 } | 1699 } |
1700 } | 1700 } |
1701 else | 1701 else |
1702 { | 1702 { |
1703 /* We are inside the contents */ | 1703 // We are inside the contents |
1704 | 1704 |
1705 /* Convert the CTRL, OPTION, SHIFT and CMD key */ | 1705 // Convert the CTRL, OPTION, SHIFT and CMD key |
1706 vimModifiers = EventModifiers2VimMouseModifiers(theEvent->modifiers); | 1706 vimModifiers = EventModifiers2VimMouseModifiers(theEvent->modifiers); |
1707 | 1707 |
1708 /* Defaults to MOUSE_LEFT as there's only one mouse button */ | 1708 // Defaults to MOUSE_LEFT as there's only one mouse button |
1709 vimMouseButton = MOUSE_LEFT; | 1709 vimMouseButton = MOUSE_LEFT; |
1710 | 1710 |
1711 /* Convert the CTRL_MOUSE_LEFT to MOUSE_RIGHT */ | 1711 // Convert the CTRL_MOUSE_LEFT to MOUSE_RIGHT |
1712 /* TODO: NEEDED? */ | 1712 // TODO: NEEDED? |
1713 clickIsPopup = FALSE; | 1713 clickIsPopup = FALSE; |
1714 | 1714 |
1715 if (mouse_model_popup() && IsShowContextualMenuClick(theEvent)) | 1715 if (mouse_model_popup() && IsShowContextualMenuClick(theEvent)) |
1716 { | 1716 { |
1717 vimMouseButton = MOUSE_RIGHT; | 1717 vimMouseButton = MOUSE_RIGHT; |
1718 vimModifiers &= ~MOUSE_CTRL; | 1718 vimModifiers &= ~MOUSE_CTRL; |
1719 clickIsPopup = TRUE; | 1719 clickIsPopup = TRUE; |
1720 } | 1720 } |
1721 | 1721 |
1722 /* Is it a double click ? */ | 1722 // Is it a double click ? |
1723 dblClick = ((theEvent->when - lastMouseTick) < GetDblTime()); | 1723 dblClick = ((theEvent->when - lastMouseTick) < GetDblTime()); |
1724 | 1724 |
1725 /* Send the mouse click to Vim */ | 1725 // Send the mouse click to Vim |
1726 gui_send_mouse_event(vimMouseButton, thePoint.h, | 1726 gui_send_mouse_event(vimMouseButton, thePoint.h, |
1727 thePoint.v, dblClick, vimModifiers); | 1727 thePoint.v, dblClick, vimModifiers); |
1728 | 1728 |
1729 /* Create the rectangle around the cursor to detect | 1729 // Create the rectangle around the cursor to detect |
1730 * the mouse dragging | 1730 // the mouse dragging |
1731 */ | |
1732 #if 0 | 1731 #if 0 |
1733 /* TODO: Do we need to this even for the contextual menu? | 1732 // TODO: Do we need to this even for the contextual menu? |
1734 * It may be require for popup_setpos, but for popup? | 1733 // It may be require for popup_setpos, but for popup? |
1735 */ | |
1736 if (vimMouseButton == MOUSE_LEFT) | 1734 if (vimMouseButton == MOUSE_LEFT) |
1737 #endif | 1735 #endif |
1738 { | 1736 { |
1739 SetRect(&dragRect, FILL_X(X_2_COL(thePoint.h)), | 1737 SetRect(&dragRect, FILL_X(X_2_COL(thePoint.h)), |
1740 FILL_Y(Y_2_ROW(thePoint.v)), | 1738 FILL_Y(Y_2_ROW(thePoint.v)), |
1754 gui_mac_doInDragClick(Point where, WindowPtr whichWindow) | 1752 gui_mac_doInDragClick(Point where, WindowPtr whichWindow) |
1755 { | 1753 { |
1756 Rect movingLimits; | 1754 Rect movingLimits; |
1757 Rect *movingLimitsPtr = &movingLimits; | 1755 Rect *movingLimitsPtr = &movingLimits; |
1758 | 1756 |
1759 /* TODO: may try to prevent move outside screen? */ | 1757 // TODO: may try to prevent move outside screen? |
1760 movingLimitsPtr = GetRegionBounds(GetGrayRgn(), &movingLimits); | 1758 movingLimitsPtr = GetRegionBounds(GetGrayRgn(), &movingLimits); |
1761 DragWindow(whichWindow, where, movingLimitsPtr); | 1759 DragWindow(whichWindow, where, movingLimitsPtr); |
1762 } | 1760 } |
1763 | 1761 |
1764 /* | 1762 /* |
1775 Rect *resizeLimitsPtr = &resizeLimits; | 1773 Rect *resizeLimitsPtr = &resizeLimits; |
1776 Rect NewContentRect; | 1774 Rect NewContentRect; |
1777 | 1775 |
1778 resizeLimitsPtr = GetRegionBounds(GetGrayRgn(), &resizeLimits); | 1776 resizeLimitsPtr = GetRegionBounds(GetGrayRgn(), &resizeLimits); |
1779 | 1777 |
1780 /* Set the minimum size */ | 1778 // Set the minimum size |
1781 /* TODO: Should this come from Vim? */ | 1779 // TODO: Should this come from Vim? |
1782 resizeLimits.top = 100; | 1780 resizeLimits.top = 100; |
1783 resizeLimits.left = 100; | 1781 resizeLimits.left = 100; |
1784 | 1782 |
1785 newSize = ResizeWindow(whichWindow, where, &resizeLimits, &NewContentRect); | 1783 newSize = ResizeWindow(whichWindow, where, &resizeLimits, &NewContentRect); |
1786 newWidth = NewContentRect.right - NewContentRect.left; | 1784 newWidth = NewContentRect.right - NewContentRect.left; |
1798 { | 1796 { |
1799 Rect r; | 1797 Rect r; |
1800 Point p; | 1798 Point p; |
1801 short thePart; | 1799 short thePart; |
1802 | 1800 |
1803 /* ideal width is current */ | 1801 // ideal width is current |
1804 p.h = Columns * gui.char_width + 2 * gui.border_offset; | 1802 p.h = Columns * gui.char_width + 2 * gui.border_offset; |
1805 if (gui.which_scrollbars[SBAR_LEFT]) | 1803 if (gui.which_scrollbars[SBAR_LEFT]) |
1806 p.h += gui.scrollbar_width; | 1804 p.h += gui.scrollbar_width; |
1807 if (gui.which_scrollbars[SBAR_RIGHT]) | 1805 if (gui.which_scrollbars[SBAR_RIGHT]) |
1808 p.h += gui.scrollbar_width; | 1806 p.h += gui.scrollbar_width; |
1809 /* ideal height is as high as we can get */ | 1807 // ideal height is as high as we can get |
1810 p.v = 15 * 1024; | 1808 p.v = 15 * 1024; |
1811 | 1809 |
1812 thePart = IsWindowInStandardState(whichWindow, &p, &r) | 1810 thePart = IsWindowInStandardState(whichWindow, &p, &r) |
1813 ? inZoomIn : inZoomOut; | 1811 ? inZoomIn : inZoomOut; |
1814 | 1812 |
1815 if (!TrackBox(whichWindow, theEvent->where, thePart)) | 1813 if (!TrackBox(whichWindow, theEvent->where, thePart)) |
1816 return; | 1814 return; |
1817 | 1815 |
1818 /* use returned width */ | 1816 // use returned width |
1819 p.h = r.right - r.left; | 1817 p.h = r.right - r.left; |
1820 /* adjust returned height */ | 1818 // adjust returned height |
1821 p.v = r.bottom - r.top - 2 * gui.border_offset; | 1819 p.v = r.bottom - r.top - 2 * gui.border_offset; |
1822 if (gui.which_scrollbars[SBAR_BOTTOM]) | 1820 if (gui.which_scrollbars[SBAR_BOTTOM]) |
1823 p.v -= gui.scrollbar_height; | 1821 p.v -= gui.scrollbar_height; |
1824 p.v -= p.v % gui.char_height; | 1822 p.v -= p.v % gui.char_height; |
1825 p.v += 2 * gui.border_width; | 1823 p.v += 2 * gui.border_width; |
1859 | 1857 |
1860 updateRgn = NewRgn(); | 1858 updateRgn = NewRgn(); |
1861 if (updateRgn == NULL) | 1859 if (updateRgn == NULL) |
1862 return; | 1860 return; |
1863 | 1861 |
1864 /* This could be done by the caller as we | 1862 // This could be done by the caller as we |
1865 * don't require anything else out of the event | 1863 // don't require anything else out of the event |
1866 */ | |
1867 whichWindow = (WindowPtr) event->message; | 1864 whichWindow = (WindowPtr) event->message; |
1868 | 1865 |
1869 /* Save Current Port */ | 1866 // Save Current Port |
1870 GetPort(&savePort); | 1867 GetPort(&savePort); |
1871 | 1868 |
1872 /* Select the Window's Port */ | 1869 // Select the Window's Port |
1873 SetPortWindowPort(whichWindow); | 1870 SetPortWindowPort(whichWindow); |
1874 | 1871 |
1875 /* Let's update the window */ | 1872 // Let's update the window |
1876 BeginUpdate(whichWindow); | 1873 BeginUpdate(whichWindow); |
1877 /* Redraw the biggest rectangle covering the area | 1874 // Redraw the biggest rectangle covering the area |
1878 * to be updated. | 1875 // to be updated. |
1879 */ | |
1880 GetPortVisibleRegion(GetWindowPort(whichWindow), updateRgn); | 1876 GetPortVisibleRegion(GetWindowPort(whichWindow), updateRgn); |
1881 # if 0 | 1877 # if 0 |
1882 /* Would be more appropriate to use the following but doesn't | 1878 // Would be more appropriate to use the following but doesn't |
1883 * seem to work under MacOS X (Dany) | 1879 // seem to work under MacOS X (Dany) |
1884 */ | |
1885 GetWindowRegion(whichWindow, kWindowUpdateRgn, updateRgn); | 1880 GetWindowRegion(whichWindow, kWindowUpdateRgn, updateRgn); |
1886 # endif | 1881 # endif |
1887 | 1882 |
1888 /* Use the HLock useless in Carbon? Is it harmful?*/ | 1883 // Use the HLock useless in Carbon? Is it harmful? |
1889 HLock((Handle) updateRgn); | 1884 HLock((Handle) updateRgn); |
1890 | 1885 |
1891 updateRectPtr = GetRegionBounds(updateRgn, &updateRect); | 1886 updateRectPtr = GetRegionBounds(updateRgn, &updateRect); |
1892 # if 0 | 1887 # if 0 |
1893 /* Code from original Carbon Port (using GetWindowRegion. | 1888 // Code from original Carbon Port (using GetWindowRegion. |
1894 * I believe the UpdateRgn is already in local (Dany) | 1889 // I believe the UpdateRgn is already in local (Dany) |
1895 */ | 1890 GlobalToLocal(&topLeft(updateRect)); // preCarbon? |
1896 GlobalToLocal(&topLeft(updateRect)); /* preCarbon? */ | |
1897 GlobalToLocal(&botRight(updateRect)); | 1891 GlobalToLocal(&botRight(updateRect)); |
1898 # endif | 1892 # endif |
1899 /* Update the content (i.e. the text) */ | 1893 // Update the content (i.e. the text) |
1900 gui_redraw(updateRectPtr->left, updateRectPtr->top, | 1894 gui_redraw(updateRectPtr->left, updateRectPtr->top, |
1901 updateRectPtr->right - updateRectPtr->left, | 1895 updateRectPtr->right - updateRectPtr->left, |
1902 updateRectPtr->bottom - updateRectPtr->top); | 1896 updateRectPtr->bottom - updateRectPtr->top); |
1903 /* Clear the border areas if needed */ | 1897 // Clear the border areas if needed |
1904 gui_mch_set_bg_color(gui.back_pixel); | 1898 gui_mch_set_bg_color(gui.back_pixel); |
1905 if (updateRectPtr->left < FILL_X(0)) | 1899 if (updateRectPtr->left < FILL_X(0)) |
1906 { | 1900 { |
1907 SetRect(&rc, 0, 0, FILL_X(0), FILL_Y(Rows)); | 1901 SetRect(&rc, 0, 0, FILL_X(0), FILL_Y(Rows)); |
1908 EraseRect(&rc); | 1902 EraseRect(&rc); |
1925 EraseRect(&rc); | 1919 EraseRect(&rc); |
1926 } | 1920 } |
1927 HUnlock((Handle) updateRgn); | 1921 HUnlock((Handle) updateRgn); |
1928 DisposeRgn(updateRgn); | 1922 DisposeRgn(updateRgn); |
1929 | 1923 |
1930 /* Update scrollbars */ | 1924 // Update scrollbars |
1931 DrawControls(whichWindow); | 1925 DrawControls(whichWindow); |
1932 | 1926 |
1933 /* Update the GrowBox */ | 1927 // Update the GrowBox |
1934 /* Taken from FAQ 33-27 */ | 1928 // Taken from FAQ 33-27 |
1935 saveRgn = NewRgn(); | 1929 saveRgn = NewRgn(); |
1936 GetWindowBounds(whichWindow, kWindowGrowRgn, &growRect); | 1930 GetWindowBounds(whichWindow, kWindowGrowRgn, &growRect); |
1937 GetClip(saveRgn); | 1931 GetClip(saveRgn); |
1938 ClipRect(&growRect); | 1932 ClipRect(&growRect); |
1939 DrawGrowIcon(whichWindow); | 1933 DrawGrowIcon(whichWindow); |
1940 SetClip(saveRgn); | 1934 SetClip(saveRgn); |
1941 DisposeRgn(saveRgn); | 1935 DisposeRgn(saveRgn); |
1942 EndUpdate(whichWindow); | 1936 EndUpdate(whichWindow); |
1943 | 1937 |
1944 /* Restore original Port */ | 1938 // Restore original Port |
1945 SetPort(savePort); | 1939 SetPort(savePort); |
1946 } | 1940 } |
1947 | 1941 |
1948 /* | 1942 /* |
1949 * Handle the activate/deactivate event | 1943 * Handle the activate/deactivate event |
1953 gui_mac_doActivateEvent(EventRecord *event) | 1947 gui_mac_doActivateEvent(EventRecord *event) |
1954 { | 1948 { |
1955 WindowPtr whichWindow; | 1949 WindowPtr whichWindow; |
1956 | 1950 |
1957 whichWindow = (WindowPtr) event->message; | 1951 whichWindow = (WindowPtr) event->message; |
1958 /* Dim scrollbars */ | 1952 // Dim scrollbars |
1959 if (whichWindow == gui.VimWindow) | 1953 if (whichWindow == gui.VimWindow) |
1960 { | 1954 { |
1961 ControlRef rootControl; | 1955 ControlRef rootControl; |
1962 GetRootControl(gui.VimWindow, &rootControl); | 1956 GetRootControl(gui.VimWindow, &rootControl); |
1963 if ((event->modifiers) & activeFlag) | 1957 if ((event->modifiers) & activeFlag) |
1964 ActivateControl(rootControl); | 1958 ActivateControl(rootControl); |
1965 else | 1959 else |
1966 DeactivateControl(rootControl); | 1960 DeactivateControl(rootControl); |
1967 } | 1961 } |
1968 | 1962 |
1969 /* Activate */ | 1963 // Activate |
1970 gui_focus_change((event->modifiers) & activeFlag); | 1964 gui_focus_change((event->modifiers) & activeFlag); |
1971 } | 1965 } |
1972 | 1966 |
1973 | 1967 |
1974 /* | 1968 /* |
1976 * (apply to the application) | 1970 * (apply to the application) |
1977 */ | 1971 */ |
1978 void | 1972 void |
1979 gui_mac_doSuspendEvent(EventRecord *event) | 1973 gui_mac_doSuspendEvent(EventRecord *event) |
1980 { | 1974 { |
1981 /* The frontmost application just changed */ | 1975 // The frontmost application just changed |
1982 | 1976 |
1983 /* NOTE: the suspend may happen before the deactivate | 1977 // NOTE: the suspend may happen before the deactivate |
1984 * seen on MacOS X | 1978 // seen on MacOS X |
1985 */ | 1979 |
1986 | 1980 // May not need to change focus as the window will |
1987 /* May not need to change focus as the window will | 1981 // get an activate/deactivate event |
1988 * get an activate/deactivate event | |
1989 */ | |
1990 if (event->message & 1) | 1982 if (event->message & 1) |
1991 /* Resume */ | 1983 // Resume |
1992 gui_focus_change(TRUE); | 1984 gui_focus_change(TRUE); |
1993 else | 1985 else |
1994 /* Suspend */ | 1986 // Suspend |
1995 gui_focus_change(FALSE); | 1987 gui_focus_change(FALSE); |
1996 } | 1988 } |
1997 | 1989 |
1998 /* | 1990 /* |
1999 * Handle the key | 1991 * Handle the key |
2066 EventRef theEvent) | 2058 EventRef theEvent) |
2067 { | 2059 { |
2068 return eventNotHandledErr; | 2060 return eventNotHandledErr; |
2069 } | 2061 } |
2070 | 2062 |
2071 static int dialog_busy = FALSE; /* TRUE when gui_mch_dialog() wants the | 2063 static int dialog_busy = FALSE; // TRUE when gui_mch_dialog() wants the |
2072 keys */ | 2064 // keys |
2073 | 2065 |
2074 # define INLINE_KEY_BUFFER_SIZE 80 | 2066 # define INLINE_KEY_BUFFER_SIZE 80 |
2075 static pascal OSStatus | 2067 static pascal OSStatus |
2076 gui_mac_unicode_key_event( | 2068 gui_mac_unicode_key_event( |
2077 EventHandlerCallRef nextHandler, | 2069 EventHandlerCallRef nextHandler, |
2078 EventRef theEvent) | 2070 EventRef theEvent) |
2079 { | 2071 { |
2080 /* Multibyte-friendly key event handler */ | 2072 // Multibyte-friendly key event handler |
2081 OSStatus err = -1; | 2073 OSStatus err = -1; |
2082 UInt32 actualSize; | 2074 UInt32 actualSize; |
2083 UniChar *text; | 2075 UniChar *text; |
2084 char_u result[INLINE_KEY_BUFFER_SIZE]; | 2076 char_u result[INLINE_KEY_BUFFER_SIZE]; |
2085 short len = 0; | 2077 short len = 0; |
2091 char_u *to = NULL; | 2083 char_u *to = NULL; |
2092 Boolean isSpecial = FALSE; | 2084 Boolean isSpecial = FALSE; |
2093 int i; | 2085 int i; |
2094 EventRef keyEvent; | 2086 EventRef keyEvent; |
2095 | 2087 |
2096 /* Mask the mouse (as per user setting) */ | 2088 // Mask the mouse (as per user setting) |
2097 if (p_mh) | 2089 if (p_mh) |
2098 ObscureCursor(); | 2090 ObscureCursor(); |
2099 | 2091 |
2100 /* Don't use the keys when the dialog wants them. */ | 2092 // Don't use the keys when the dialog wants them. |
2101 if (dialog_busy) | 2093 if (dialog_busy) |
2102 return eventNotHandledErr; | 2094 return eventNotHandledErr; |
2103 | 2095 |
2104 if (noErr != GetEventParameter(theEvent, kEventParamTextInputSendText, | 2096 if (noErr != GetEventParameter(theEvent, kEventParamTextInputSendText, |
2105 typeUnicodeText, NULL, 0, &actualSize, NULL)) | 2097 typeUnicodeText, NULL, 0, &actualSize, NULL)) |
2129 typeChar, NULL, sizeof(char), NULL, &charcode); | 2121 typeChar, NULL, sizeof(char), NULL, &charcode); |
2130 require_noerr(err, done); | 2122 require_noerr(err, done); |
2131 | 2123 |
2132 #ifndef USE_CMD_KEY | 2124 #ifndef USE_CMD_KEY |
2133 if (modifiers & cmdKey) | 2125 if (modifiers & cmdKey) |
2134 goto done; /* Let system handle Cmd+... */ | 2126 goto done; // Let system handle Cmd+... |
2135 #endif | 2127 #endif |
2136 | 2128 |
2137 key_char = charcode; | 2129 key_char = charcode; |
2138 vimModifiers = EventModifiers2VimModifiers(modifiers); | 2130 vimModifiers = EventModifiers2VimModifiers(modifiers); |
2139 | 2131 |
2140 /* Find the special key (eg., for cursor keys) */ | 2132 // Find the special key (eg., for cursor keys) |
2141 if (actualSize <= sizeof(UniChar) && | 2133 if (actualSize <= sizeof(UniChar) && |
2142 ((text[0] < 0x20) || (text[0] == 0x7f))) | 2134 ((text[0] < 0x20) || (text[0] == 0x7f))) |
2143 { | 2135 { |
2144 for (i = 0; special_keys[i].key_sym != (KeySym)0; ++i) | 2136 for (i = 0; special_keys[i].key_sym != (KeySym)0; ++i) |
2145 if (special_keys[i].key_sym == key_sym) | 2137 if (special_keys[i].key_sym == key_sym) |
2151 isSpecial = TRUE; | 2143 isSpecial = TRUE; |
2152 break; | 2144 break; |
2153 } | 2145 } |
2154 } | 2146 } |
2155 | 2147 |
2156 /* Intercept CMD-. and CTRL-c */ | 2148 // Intercept CMD-. and CTRL-c |
2157 if (((modifiers & controlKey) && key_char == 'c') || | 2149 if (((modifiers & controlKey) && key_char == 'c') || |
2158 ((modifiers & cmdKey) && key_char == '.')) | 2150 ((modifiers & cmdKey) && key_char == '.')) |
2159 got_int = TRUE; | 2151 got_int = TRUE; |
2160 | 2152 |
2161 if (!isSpecial) | 2153 if (!isSpecial) |
2162 { | 2154 { |
2163 /* remove SHIFT for keys that are already shifted, e.g., | 2155 // remove SHIFT for keys that are already shifted, e.g., |
2164 * '(' and '*' */ | 2156 // '(' and '*' |
2165 if (key_char < 0x100 && !isalpha(key_char) && isprint(key_char)) | 2157 if (key_char < 0x100 && !isalpha(key_char) && isprint(key_char)) |
2166 vimModifiers &= ~MOD_MASK_SHIFT; | 2158 vimModifiers &= ~MOD_MASK_SHIFT; |
2167 | 2159 |
2168 /* remove CTRL from keys that already have it */ | 2160 // remove CTRL from keys that already have it |
2169 if (key_char < 0x20) | 2161 if (key_char < 0x20) |
2170 vimModifiers &= ~MOD_MASK_CTRL; | 2162 vimModifiers &= ~MOD_MASK_CTRL; |
2171 | 2163 |
2172 /* don't process unicode characters here */ | 2164 // don't process unicode characters here |
2173 if (!IS_SPECIAL(key_char)) | 2165 if (!IS_SPECIAL(key_char)) |
2174 { | 2166 { |
2175 /* Following code to simplify and consolidate vimModifiers | 2167 // Following code to simplify and consolidate vimModifiers |
2176 * taken liberally from gui_w48.c */ | 2168 // taken liberally from gui_w48.c |
2177 key_char = simplify_key(key_char, (int *)&vimModifiers); | 2169 key_char = simplify_key(key_char, (int *)&vimModifiers); |
2178 | 2170 |
2179 /* Interpret META, include SHIFT, etc. */ | 2171 // Interpret META, include SHIFT, etc. |
2180 key_char = extract_modifiers(key_char, (int *)&vimModifiers, | 2172 key_char = extract_modifiers(key_char, (int *)&vimModifiers, |
2181 TRUE, NULL); | 2173 TRUE, NULL); |
2182 if (key_char == CSI) | 2174 if (key_char == CSI) |
2183 key_char = K_CSI; | 2175 key_char = K_CSI; |
2184 | 2176 |
2204 { | 2196 { |
2205 encLen = actualSize; | 2197 encLen = actualSize; |
2206 to = mac_utf16_to_enc(text, actualSize, &encLen); | 2198 to = mac_utf16_to_enc(text, actualSize, &encLen); |
2207 if (to) | 2199 if (to) |
2208 { | 2200 { |
2209 /* This is basically add_to_input_buf_csi() */ | 2201 // This is basically add_to_input_buf_csi() |
2210 for (i = 0; i < encLen && len < (INLINE_KEY_BUFFER_SIZE-1); ++i) | 2202 for (i = 0; i < encLen && len < (INLINE_KEY_BUFFER_SIZE-1); ++i) |
2211 { | 2203 { |
2212 result[len++] = to[i]; | 2204 result[len++] = to[i]; |
2213 if (to[i] == CSI) | 2205 if (to[i] == CSI) |
2214 { | 2206 { |
2225 | 2217 |
2226 done: | 2218 done: |
2227 vim_free(text); | 2219 vim_free(text); |
2228 if (err == noErr) | 2220 if (err == noErr) |
2229 { | 2221 { |
2230 /* Fake event to wake up WNE (required to get | 2222 // Fake event to wake up WNE (required to get |
2231 * key repeat working */ | 2223 // key repeat working |
2232 PostEvent(keyUp, 0); | 2224 PostEvent(keyUp, 0); |
2233 return noErr; | 2225 return noErr; |
2234 } | 2226 } |
2235 | 2227 |
2236 return eventNotHandledErr; | 2228 return eventNotHandledErr; |
2237 } | 2229 } |
2238 #else | 2230 #else |
2239 void | 2231 void |
2240 gui_mac_doKeyEvent(EventRecord *theEvent) | 2232 gui_mac_doKeyEvent(EventRecord *theEvent) |
2241 { | 2233 { |
2242 /* TODO: add support for COMMAND KEY */ | 2234 // TODO: add support for COMMAND KEY |
2243 long menu; | 2235 long menu; |
2244 unsigned char string[20]; | 2236 unsigned char string[20]; |
2245 short num, i; | 2237 short num, i; |
2246 short len = 0; | 2238 short len = 0; |
2247 KeySym key_sym; | 2239 KeySym key_sym; |
2248 int key_char; | 2240 int key_char; |
2249 int modifiers; | 2241 int modifiers; |
2250 int simplify = FALSE; | 2242 int simplify = FALSE; |
2251 | 2243 |
2252 /* Mask the mouse (as per user setting) */ | 2244 // Mask the mouse (as per user setting) |
2253 if (p_mh) | 2245 if (p_mh) |
2254 ObscureCursor(); | 2246 ObscureCursor(); |
2255 | 2247 |
2256 /* Get the key code and its ASCII representation */ | 2248 // Get the key code and its ASCII representation |
2257 key_sym = ((theEvent->message & keyCodeMask) >> 8); | 2249 key_sym = ((theEvent->message & keyCodeMask) >> 8); |
2258 key_char = theEvent->message & charCodeMask; | 2250 key_char = theEvent->message & charCodeMask; |
2259 num = 1; | 2251 num = 1; |
2260 | 2252 |
2261 /* Intercept CTRL-C */ | 2253 // Intercept CTRL-C |
2262 if (theEvent->modifiers & controlKey) | 2254 if (theEvent->modifiers & controlKey) |
2263 { | 2255 { |
2264 if (key_char == Ctrl_C && ctrl_c_interrupts) | 2256 if (key_char == Ctrl_C && ctrl_c_interrupts) |
2265 got_int = TRUE; | 2257 got_int = TRUE; |
2266 else if ((theEvent->modifiers & ~(controlKey|shiftKey)) == 0 | 2258 else if ((theEvent->modifiers & ~(controlKey|shiftKey)) == 0 |
2267 && (key_char == '2' || key_char == '6')) | 2259 && (key_char == '2' || key_char == '6')) |
2268 { | 2260 { |
2269 /* CTRL-^ and CTRL-@ don't work in the normal way. */ | 2261 // CTRL-^ and CTRL-@ don't work in the normal way. |
2270 if (key_char == '2') | 2262 if (key_char == '2') |
2271 key_char = Ctrl_AT; | 2263 key_char = Ctrl_AT; |
2272 else | 2264 else |
2273 key_char = Ctrl_HAT; | 2265 key_char = Ctrl_HAT; |
2274 theEvent->modifiers = 0; | 2266 theEvent->modifiers = 0; |
2275 } | 2267 } |
2276 } | 2268 } |
2277 | 2269 |
2278 /* Intercept CMD-. */ | 2270 // Intercept CMD-. |
2279 if (theEvent->modifiers & cmdKey) | 2271 if (theEvent->modifiers & cmdKey) |
2280 if (key_char == '.') | 2272 if (key_char == '.') |
2281 got_int = TRUE; | 2273 got_int = TRUE; |
2282 | 2274 |
2283 /* Handle command key as per menu */ | 2275 // Handle command key as per menu |
2284 /* TODO: should override be allowed? Require YAO or could use 'winaltkey' */ | 2276 // TODO: should override be allowed? Require YAO or could use 'winaltkey' |
2285 if (theEvent->modifiers & cmdKey) | 2277 if (theEvent->modifiers & cmdKey) |
2286 /* Only accept CMD alone or with CAPLOCKS and the mouse button. | 2278 // Only accept CMD alone or with CAPLOCKS and the mouse button. |
2287 * Why the mouse button? */ | 2279 // Why the mouse button? |
2288 if ((theEvent->modifiers & (~(cmdKey | btnState | alphaLock))) == 0) | 2280 if ((theEvent->modifiers & (~(cmdKey | btnState | alphaLock))) == 0) |
2289 { | 2281 { |
2290 menu = MenuKey(key_char); | 2282 menu = MenuKey(key_char); |
2291 if (HiWord(menu)) | 2283 if (HiWord(menu)) |
2292 { | 2284 { |
2293 gui_mac_handle_menu(menu); | 2285 gui_mac_handle_menu(menu); |
2294 return; | 2286 return; |
2295 } | 2287 } |
2296 } | 2288 } |
2297 | 2289 |
2298 /* Convert the modifiers */ | 2290 // Convert the modifiers |
2299 modifiers = EventModifiers2VimModifiers(theEvent->modifiers); | 2291 modifiers = EventModifiers2VimModifiers(theEvent->modifiers); |
2300 | 2292 |
2301 | 2293 |
2302 /* Handle special keys. */ | 2294 // Handle special keys. |
2303 #if 0 | 2295 #if 0 |
2304 /* Why has this been removed? */ | 2296 // Why has this been removed? |
2305 if (!(theEvent->modifiers & (cmdKey | controlKey | rightControlKey))) | 2297 if (!(theEvent->modifiers & (cmdKey | controlKey | rightControlKey))) |
2306 #endif | 2298 #endif |
2307 { | 2299 { |
2308 /* Find the special key (for non-printable keyt_char) */ | 2300 // Find the special key (for non-printable keyt_char) |
2309 if ((key_char < 0x20) || (key_char == 0x7f)) | 2301 if ((key_char < 0x20) || (key_char == 0x7f)) |
2310 for (i = 0; special_keys[i].key_sym != (KeySym)0; i++) | 2302 for (i = 0; special_keys[i].key_sym != (KeySym)0; i++) |
2311 if (special_keys[i].key_sym == key_sym) | 2303 if (special_keys[i].key_sym == key_sym) |
2312 { | 2304 { |
2313 # if 0 | 2305 # if 0 |
2314 /* We currently don't have not so special key */ | 2306 // We currently don't have not so special key |
2315 if (special_keys[i].vim_code1 == NUL) | 2307 if (special_keys[i].vim_code1 == NUL) |
2316 key_char = special_keys[i].vim_code0; | 2308 key_char = special_keys[i].vim_code0; |
2317 else | 2309 else |
2318 # endif | 2310 # endif |
2319 key_char = TO_SPECIAL(special_keys[i].vim_code0, | 2311 key_char = TO_SPECIAL(special_keys[i].vim_code0, |
2321 simplify = TRUE; | 2313 simplify = TRUE; |
2322 break; | 2314 break; |
2323 } | 2315 } |
2324 } | 2316 } |
2325 | 2317 |
2326 /* For some keys the modifier is included in the char itself. */ | 2318 // For some keys the modifier is included in the char itself. |
2327 if (simplify || key_char == TAB || key_char == ' ') | 2319 if (simplify || key_char == TAB || key_char == ' ') |
2328 key_char = simplify_key(key_char, &modifiers); | 2320 key_char = simplify_key(key_char, &modifiers); |
2329 | 2321 |
2330 /* Add the modifier to the input bu if needed */ | 2322 // Add the modifier to the input bu if needed |
2331 /* Do not want SHIFT-A or CTRL-A with modifier */ | 2323 // Do not want SHIFT-A or CTRL-A with modifier |
2332 if (!IS_SPECIAL(key_char) | 2324 if (!IS_SPECIAL(key_char) |
2333 && key_sym != vk_Space | 2325 && key_sym != vk_Space |
2334 && key_sym != vk_Tab | 2326 && key_sym != vk_Tab |
2335 && key_sym != vk_Return | 2327 && key_sym != vk_Return |
2336 && key_sym != vk_Enter | 2328 && key_sym != vk_Enter |
2337 && key_sym != vk_Esc) | 2329 && key_sym != vk_Esc) |
2338 { | 2330 { |
2339 #if 1 | 2331 #if 1 |
2340 /* Clear modifiers when only one modifier is set */ | 2332 // Clear modifiers when only one modifier is set |
2341 if ((modifiers == MOD_MASK_SHIFT) | 2333 if ((modifiers == MOD_MASK_SHIFT) |
2342 || (modifiers == MOD_MASK_CTRL) | 2334 || (modifiers == MOD_MASK_CTRL) |
2343 || (modifiers == MOD_MASK_ALT)) | 2335 || (modifiers == MOD_MASK_ALT)) |
2344 modifiers = 0; | 2336 modifiers = 0; |
2345 #else | 2337 #else |
2364 string[len++] = K_SECOND(key_char); | 2356 string[len++] = K_SECOND(key_char); |
2365 string[len++] = K_THIRD(key_char); | 2357 string[len++] = K_THIRD(key_char); |
2366 } | 2358 } |
2367 else | 2359 else |
2368 { | 2360 { |
2369 /* Convert characters when needed (e.g., from MacRoman to latin1). | 2361 // Convert characters when needed (e.g., from MacRoman to latin1). |
2370 * This doesn't work for the NUL byte. */ | 2362 // This doesn't work for the NUL byte. |
2371 if (input_conv.vc_type != CONV_NONE && key_char > 0) | 2363 if (input_conv.vc_type != CONV_NONE && key_char > 0) |
2372 { | 2364 { |
2373 char_u from[2], *to; | 2365 char_u from[2], *to; |
2374 int l; | 2366 int l; |
2375 | 2367 |
2398 string[len++] = key_char; | 2390 string[len++] = key_char; |
2399 } | 2391 } |
2400 | 2392 |
2401 if (len == 1 && string[0] == CSI) | 2393 if (len == 1 && string[0] == CSI) |
2402 { | 2394 { |
2403 /* Turn CSI into K_CSI. */ | 2395 // Turn CSI into K_CSI. |
2404 string[ len++ ] = KS_EXTRA; | 2396 string[ len++ ] = KS_EXTRA; |
2405 string[ len++ ] = KE_CSI; | 2397 string[ len++ ] = KE_CSI; |
2406 } | 2398 } |
2407 | 2399 |
2408 add_to_input_buf(string, len); | 2400 add_to_input_buf(string, len); |
2419 WindowPtr whichWindow; | 2411 WindowPtr whichWindow; |
2420 | 2412 |
2421 thePart = FindWindow(theEvent->where, &whichWindow); | 2413 thePart = FindWindow(theEvent->where, &whichWindow); |
2422 | 2414 |
2423 #ifdef FEAT_GUI_TABLINE | 2415 #ifdef FEAT_GUI_TABLINE |
2424 /* prevent that the vim window size changes if it's activated by a | 2416 // prevent that the vim window size changes if it's activated by a |
2425 click into the tab pane */ | 2417 // click into the tab pane |
2426 if (whichWindow == drawer) | 2418 if (whichWindow == drawer) |
2427 return; | 2419 return; |
2428 #endif | 2420 #endif |
2429 | 2421 |
2430 switch (thePart) | 2422 switch (thePart) |
2431 { | 2423 { |
2432 case (inDesk): | 2424 case (inDesk): |
2433 /* TODO: what to do? */ | 2425 // TODO: what to do? |
2434 break; | 2426 break; |
2435 | 2427 |
2436 case (inMenuBar): | 2428 case (inMenuBar): |
2437 gui_mac_handle_menu(MenuSelect(theEvent->where)); | 2429 gui_mac_handle_menu(MenuSelect(theEvent->where)); |
2438 break; | 2430 break; |
2480 else | 2472 else |
2481 if (!clickIsPopup) | 2473 if (!clickIsPopup) |
2482 gui_send_mouse_event(MOUSE_DRAG, thePoint.h, | 2474 gui_send_mouse_event(MOUSE_DRAG, thePoint.h, |
2483 thePoint.v, FALSE, vimModifiers); | 2475 thePoint.v, FALSE, vimModifiers); |
2484 | 2476 |
2485 /* Reset the region from which we move in and out */ | 2477 // Reset the region from which we move in and out |
2486 SetRect(&dragRect, FILL_X(X_2_COL(thePoint.h)), | 2478 SetRect(&dragRect, FILL_X(X_2_COL(thePoint.h)), |
2487 FILL_Y(Y_2_ROW(thePoint.v)), | 2479 FILL_Y(Y_2_ROW(thePoint.v)), |
2488 FILL_X(X_2_COL(thePoint.h)+1), | 2480 FILL_X(X_2_COL(thePoint.h)+1), |
2489 FILL_Y(Y_2_ROW(thePoint.v)+1)); | 2481 FILL_Y(Y_2_ROW(thePoint.v)+1)); |
2490 | 2482 |
2500 gui_mac_doMouseUpEvent(EventRecord *theEvent) | 2492 gui_mac_doMouseUpEvent(EventRecord *theEvent) |
2501 { | 2493 { |
2502 Point thePoint; | 2494 Point thePoint; |
2503 int_u vimModifiers; | 2495 int_u vimModifiers; |
2504 | 2496 |
2505 /* TODO: Properly convert the Contextual menu mouse-up */ | 2497 // TODO: Properly convert the Contextual menu mouse-up |
2506 /* Potential source of the double menu */ | 2498 // Potential source of the double menu |
2507 lastMouseTick = theEvent->when; | 2499 lastMouseTick = theEvent->when; |
2508 dragRectEnbl = FALSE; | 2500 dragRectEnbl = FALSE; |
2509 dragRectControl = kCreateEmpty; | 2501 dragRectControl = kCreateEmpty; |
2510 thePoint = theEvent->where; | 2502 thePoint = theEvent->where; |
2511 GlobalToLocal(&thePoint); | 2503 GlobalToLocal(&thePoint); |
2531 EventMouseWheelAxis axis; | 2523 EventMouseWheelAxis axis; |
2532 | 2524 |
2533 if (noErr == GetEventParameter(theEvent, kEventParamMouseWheelAxis, | 2525 if (noErr == GetEventParameter(theEvent, kEventParamMouseWheelAxis, |
2534 typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis) | 2526 typeMouseWheelAxis, NULL, sizeof(axis), NULL, &axis) |
2535 && axis != kEventMouseWheelAxisY) | 2527 && axis != kEventMouseWheelAxisY) |
2536 goto bail; /* Vim only does up-down scrolling */ | 2528 goto bail; // Vim only does up-down scrolling |
2537 | 2529 |
2538 if (noErr != GetEventParameter(theEvent, kEventParamMouseWheelDelta, | 2530 if (noErr != GetEventParameter(theEvent, kEventParamMouseWheelDelta, |
2539 typeSInt32, NULL, sizeof(SInt32), NULL, &delta)) | 2531 typeSInt32, NULL, sizeof(SInt32), NULL, &delta)) |
2540 goto bail; | 2532 goto bail; |
2541 if (noErr != GetEventParameter(theEvent, kEventParamMouseLocation, | 2533 if (noErr != GetEventParameter(theEvent, kEventParamMouseLocation, |
2560 } | 2552 } |
2561 | 2553 |
2562 gui_send_mouse_event((delta > 0) ? MOUSE_4 : MOUSE_5, | 2554 gui_send_mouse_event((delta > 0) ? MOUSE_4 : MOUSE_5, |
2563 point.h, point.v, FALSE, vim_mod); | 2555 point.h, point.v, FALSE, vim_mod); |
2564 | 2556 |
2565 /* post a bogus event to wake up WaitNextEvent */ | 2557 // post a bogus event to wake up WaitNextEvent |
2566 PostEvent(keyUp, 0); | 2558 PostEvent(keyUp, 0); |
2567 | 2559 |
2568 return noErr; | 2560 return noErr; |
2569 | 2561 |
2570 bail: | 2562 bail: |
2576 } | 2568 } |
2577 | 2569 |
2578 void | 2570 void |
2579 gui_mch_mousehide(int hide) | 2571 gui_mch_mousehide(int hide) |
2580 { | 2572 { |
2581 /* TODO */ | 2573 // TODO |
2582 } | 2574 } |
2583 | 2575 |
2584 #if 0 | 2576 #if 0 |
2585 | 2577 |
2586 /* | 2578 /* |
2603 if (status != noErr) | 2595 if (status != noErr) |
2604 return; | 2596 return; |
2605 | 2597 |
2606 if (CntxType == kCMMenuItemSelected) | 2598 if (CntxType == kCMMenuItemSelected) |
2607 { | 2599 { |
2608 /* Handle the menu CntxMenuID, CntxMenuItem */ | 2600 // Handle the menu CntxMenuID, CntxMenuItem |
2609 /* The submenu can be handle directly by gui_mac_handle_menu */ | 2601 // The submenu can be handle directly by gui_mac_handle_menu |
2610 /* But what about the current menu, is the many changed by ContextualMenuSelect */ | 2602 // But what about the current menu, is the many changed by ContextualMenuSelect |
2611 gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem); | 2603 gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem); |
2612 } | 2604 } |
2613 else if (CntxMenuID == kCMShowHelpSelected) | 2605 else if (CntxMenuID == kCMShowHelpSelected) |
2614 { | 2606 { |
2615 /* Should come up with the help */ | 2607 // Should come up with the help |
2616 } | 2608 } |
2617 | 2609 |
2618 } | 2610 } |
2619 #endif | 2611 #endif |
2620 | 2612 |
2626 { | 2618 { |
2627 short menu = HiWord(menuChoice); | 2619 short menu = HiWord(menuChoice); |
2628 short item = LoWord(menuChoice); | 2620 short item = LoWord(menuChoice); |
2629 vimmenu_T *theVimMenu = root_menu; | 2621 vimmenu_T *theVimMenu = root_menu; |
2630 | 2622 |
2631 if (menu == 256) /* TODO: use constant or gui.xyz */ | 2623 if (menu == 256) // TODO: use constant or gui.xyz |
2632 { | 2624 { |
2633 if (item == 1) | 2625 if (item == 1) |
2634 gui_mch_beep(); /* TODO: Popup dialog or do :intro */ | 2626 gui_mch_beep(); // TODO: Popup dialog or do :intro |
2635 } | 2627 } |
2636 else if (item != 0) | 2628 else if (item != 0) |
2637 { | 2629 { |
2638 theVimMenu = gui_mac_get_vim_menu(menu, item, root_menu); | 2630 theVimMenu = gui_mac_get_vim_menu(menu, item, root_menu); |
2639 | 2631 |
2650 void | 2642 void |
2651 gui_mac_handle_event(EventRecord *event) | 2643 gui_mac_handle_event(EventRecord *event) |
2652 { | 2644 { |
2653 OSErr error; | 2645 OSErr error; |
2654 | 2646 |
2655 /* Handle contextual menu right now (if needed) */ | 2647 // Handle contextual menu right now (if needed) |
2656 if (IsShowContextualMenuClick(event)) | 2648 if (IsShowContextualMenuClick(event)) |
2657 { | 2649 { |
2658 # if 0 | 2650 # if 0 |
2659 gui_mac_handle_contextual_menu(event); | 2651 gui_mac_handle_contextual_menu(event); |
2660 # else | 2652 # else |
2661 gui_mac_doMouseDownEvent(event); | 2653 gui_mac_doMouseDownEvent(event); |
2662 # endif | 2654 # endif |
2663 return; | 2655 return; |
2664 } | 2656 } |
2665 | 2657 |
2666 /* Handle normal event */ | 2658 // Handle normal event |
2667 switch (event->what) | 2659 switch (event->what) |
2668 { | 2660 { |
2669 #ifndef USE_CARBONKEYHANDLER | 2661 #ifndef USE_CARBONKEYHANDLER |
2670 case (keyDown): | 2662 case (keyDown): |
2671 case (autoKey): | 2663 case (autoKey): |
2672 gui_mac_doKeyEvent(event); | 2664 gui_mac_doKeyEvent(event); |
2673 break; | 2665 break; |
2674 #endif | 2666 #endif |
2675 case (keyUp): | 2667 case (keyUp): |
2676 /* We don't care about when the key is released */ | 2668 // We don't care about when the key is released |
2677 break; | 2669 break; |
2678 | 2670 |
2679 case (mouseDown): | 2671 case (mouseDown): |
2680 gui_mac_doMouseDownEvent(event); | 2672 gui_mac_doMouseDownEvent(event); |
2681 break; | 2673 break; |
2687 case (updateEvt): | 2679 case (updateEvt): |
2688 gui_mac_doUpdateEvent(event); | 2680 gui_mac_doUpdateEvent(event); |
2689 break; | 2681 break; |
2690 | 2682 |
2691 case (diskEvt): | 2683 case (diskEvt): |
2692 /* We don't need special handling for disk insertion */ | 2684 // We don't need special handling for disk insertion |
2693 break; | 2685 break; |
2694 | 2686 |
2695 case (activateEvt): | 2687 case (activateEvt): |
2696 gui_mac_doActivateEvent(event); | 2688 gui_mac_doActivateEvent(event); |
2697 break; | 2689 break; |
2698 | 2690 |
2699 case (osEvt): | 2691 case (osEvt): |
2700 switch ((event->message >> 24) & 0xFF) | 2692 switch ((event->message >> 24) & 0xFF) |
2701 { | 2693 { |
2702 case (0xFA): /* mouseMovedMessage */ | 2694 case (0xFA): // mouseMovedMessage |
2703 gui_mac_doMouseMovedEvent(event); | 2695 gui_mac_doMouseMovedEvent(event); |
2704 break; | 2696 break; |
2705 case (0x01): /* suspendResumeMessage */ | 2697 case (0x01): // suspendResumeMessage |
2706 gui_mac_doSuspendEvent(event); | 2698 gui_mac_doSuspendEvent(event); |
2707 break; | 2699 break; |
2708 } | 2700 } |
2709 break; | 2701 break; |
2710 | 2702 |
2711 #ifdef USE_AEVENT | 2703 #ifdef USE_AEVENT |
2712 case (kHighLevelEvent): | 2704 case (kHighLevelEvent): |
2713 /* Someone's talking to us, through AppleEvents */ | 2705 // Someone's talking to us, through AppleEvents |
2714 error = AEProcessAppleEvent(event); /* TODO: Error Handling */ | 2706 error = AEProcessAppleEvent(event); // TODO: Error Handling |
2715 break; | 2707 break; |
2716 #endif | 2708 #endif |
2717 } | 2709 } |
2718 } | 2710 } |
2719 | 2711 |
2747 #if 1 | 2739 #if 1 |
2748 STRCPY(&pFontName[1], font_name); | 2740 STRCPY(&pFontName[1], font_name); |
2749 pFontName[0] = STRLEN(font_name); | 2741 pFontName[0] = STRLEN(font_name); |
2750 *p = c; | 2742 *p = c; |
2751 | 2743 |
2752 /* Get the font name, minus the style suffix (:h, etc) */ | 2744 // Get the font name, minus the style suffix (:h, etc) |
2753 char_u fontName[256]; | 2745 char_u fontName[256]; |
2754 char_u *styleStart = vim_strchr(font_name, ':'); | 2746 char_u *styleStart = vim_strchr(font_name, ':'); |
2755 size_t fontNameLen = styleStart ? styleStart - font_name : STRLEN(fontName); | 2747 size_t fontNameLen = styleStart ? styleStart - font_name : STRLEN(fontName); |
2756 vim_strncpy(fontName, font_name, fontNameLen); | 2748 vim_strncpy(fontName, font_name, fontNameLen); |
2757 | 2749 |
2793 font_id = 0; | 2785 font_id = 0; |
2794 } | 2786 } |
2795 } | 2787 } |
2796 | 2788 |
2797 #else | 2789 #else |
2798 /* name = C2Pascal_save(menu->dname); */ | 2790 // name = C2Pascal_save(menu->dname); |
2799 fontNamePtr = C2Pascal_save_and_remove_backslash(font_name); | 2791 fontNamePtr = C2Pascal_save_and_remove_backslash(font_name); |
2800 | 2792 |
2801 GetFNum(fontNamePtr, &font_id); | 2793 GetFNum(fontNamePtr, &font_id); |
2802 #endif | 2794 #endif |
2803 | 2795 |
2804 | 2796 |
2805 if (font_id == 0) | 2797 if (font_id == 0) |
2806 { | 2798 { |
2807 /* Oups, the system font was it the one the user want */ | 2799 // Oups, the system font was it the one the user want |
2808 | 2800 |
2809 if (FMGetFontFamilyName(systemFont, systemFontname) != noErr) | 2801 if (FMGetFontFamilyName(systemFont, systemFontname) != noErr) |
2810 return NOFONT; | 2802 return NOFONT; |
2811 if (!EqualString(pFontName, systemFontname, false, false)) | 2803 if (!EqualString(pFontName, systemFontname, false, false)) |
2812 return NOFONT; | 2804 return NOFONT; |
2813 } | 2805 } |
2814 if (*p == ':') | 2806 if (*p == ':') |
2815 { | 2807 { |
2816 p++; | 2808 p++; |
2817 /* Set the values found after ':' */ | 2809 // Set the values found after ':' |
2818 while (*p) | 2810 while (*p) |
2819 { | 2811 { |
2820 switch (*p++) | 2812 switch (*p++) |
2821 { | 2813 { |
2822 case 'h': | 2814 case 'h': |
2830 p++; | 2822 p++; |
2831 } | 2823 } |
2832 } | 2824 } |
2833 | 2825 |
2834 if (size < 1) | 2826 if (size < 1) |
2835 size = 1; /* Avoid having a size of 0 with system font */ | 2827 size = 1; // Avoid having a size of 0 with system font |
2836 | 2828 |
2837 font = (size << 16) + ((long) font_id & 0xFFFF); | 2829 font = (size << 16) + ((long) font_id & 0xFFFF); |
2838 | 2830 |
2839 return font; | 2831 return font; |
2840 } | 2832 } |
2851 * when vim is started, whether or not the GUI has been started. | 2843 * when vim is started, whether or not the GUI has been started. |
2852 */ | 2844 */ |
2853 void | 2845 void |
2854 gui_mch_prepare(int *argc, char **argv) | 2846 gui_mch_prepare(int *argc, char **argv) |
2855 { | 2847 { |
2856 /* TODO: Move most of this stuff toward gui_mch_init */ | 2848 // TODO: Move most of this stuff toward gui_mch_init |
2857 #ifdef USE_EXE_NAME | 2849 #ifdef USE_EXE_NAME |
2858 FSSpec applDir; | 2850 FSSpec applDir; |
2859 # ifndef USE_FIND_BUNDLE_PATH | 2851 # ifndef USE_FIND_BUNDLE_PATH |
2860 short applVRefNum; | 2852 short applVRefNum; |
2861 long applDirID; | 2853 long applDirID; |
2873 | 2865 |
2874 #ifdef USE_AEVENT | 2866 #ifdef USE_AEVENT |
2875 (void) InstallAEHandlers(); | 2867 (void) InstallAEHandlers(); |
2876 #endif | 2868 #endif |
2877 | 2869 |
2878 pomme = NewMenu(256, "\p\024"); /* 0x14= = Apple Menu */ | 2870 pomme = NewMenu(256, "\p\024"); // 0x14= = Apple Menu |
2879 | 2871 |
2880 AppendMenu(pomme, "\pAbout VIM"); | 2872 AppendMenu(pomme, "\pAbout VIM"); |
2881 | 2873 |
2882 InsertMenu(pomme, 0); | 2874 InsertMenu(pomme, 0); |
2883 | 2875 |
2899 gui.char_width = 7; | 2891 gui.char_width = 7; |
2900 gui.char_height = 11; | 2892 gui.char_height = 11; |
2901 gui.char_ascent = 6; | 2893 gui.char_ascent = 6; |
2902 gui.num_rows = 24; | 2894 gui.num_rows = 24; |
2903 gui.num_cols = 80; | 2895 gui.num_cols = 80; |
2904 gui.in_focus = TRUE; /* For the moment -> syn. of front application */ | 2896 gui.in_focus = TRUE; // For the moment -> syn. of front application |
2905 | 2897 |
2906 gScrollAction = NewControlActionUPP(gui_mac_scroll_action); | 2898 gScrollAction = NewControlActionUPP(gui_mac_scroll_action); |
2907 gScrollDrag = NewControlActionUPP(gui_mac_drag_thumb); | 2899 gScrollDrag = NewControlActionUPP(gui_mac_drag_thumb); |
2908 | 2900 |
2909 dragRectEnbl = FALSE; | 2901 dragRectEnbl = FALSE; |
2912 cursorRgn = NewRgn(); | 2904 cursorRgn = NewRgn(); |
2913 #endif | 2905 #endif |
2914 #ifdef USE_EXE_NAME | 2906 #ifdef USE_EXE_NAME |
2915 # ifndef USE_FIND_BUNDLE_PATH | 2907 # ifndef USE_FIND_BUNDLE_PATH |
2916 HGetVol(volName, &applVRefNum, &applDirID); | 2908 HGetVol(volName, &applVRefNum, &applDirID); |
2917 /* TN2015: mention a possible bad VRefNum */ | 2909 // TN2015: mention a possible bad VRefNum |
2918 FSMakeFSSpec(applVRefNum, applDirID, "\p", &applDir); | 2910 FSMakeFSSpec(applVRefNum, applDirID, "\p", &applDir); |
2919 # else | 2911 # else |
2920 /* OSErr GetApplicationBundleFSSpec(FSSpecPtr theFSSpecPtr) | 2912 // OSErr GetApplicationBundleFSSpec(FSSpecPtr theFSSpecPtr) |
2921 * of TN2015 | 2913 // of TN2015 |
2922 */ | |
2923 (void)GetCurrentProcess(&psn); | 2914 (void)GetCurrentProcess(&psn); |
2924 /* if (err != noErr) return err; */ | 2915 // if (err != noErr) return err; |
2925 | 2916 |
2926 (void)GetProcessBundleLocation(&psn, &applFSRef); | 2917 (void)GetProcessBundleLocation(&psn, &applFSRef); |
2927 /* if (err != noErr) return err; */ | 2918 // if (err != noErr) return err; |
2928 | 2919 |
2929 (void)FSGetCatalogInfo(&applFSRef, kFSCatInfoNone, NULL, NULL, &applDir, NULL); | 2920 (void)FSGetCatalogInfo(&applFSRef, kFSCatInfoNone, NULL, NULL, &applDir, NULL); |
2930 | 2921 |
2931 /* This technic return NIL when we disallow_gui */ | 2922 // This technic return NIL when we disallow_gui |
2932 # endif | 2923 # endif |
2933 exe_name = FullPathFromFSSpec_save(applDir); | 2924 exe_name = FullPathFromFSSpec_save(applDir); |
2934 #endif | 2925 #endif |
2935 } | 2926 } |
2936 | 2927 |
2940 * Return OK or FAIL. | 2931 * Return OK or FAIL. |
2941 */ | 2932 */ |
2942 int | 2933 int |
2943 gui_mch_init_check(void) | 2934 gui_mch_init_check(void) |
2944 { | 2935 { |
2945 /* TODO: For MacOS X find a way to return FAIL, if the user logged in | 2936 // TODO: For MacOS X find a way to return FAIL, if the user logged in |
2946 * using the >console | 2937 // using the >console |
2947 */ | 2938 if (disallow_gui) // see main.c for reason to disallow |
2948 if (disallow_gui) /* see main.c for reason to disallow */ | |
2949 return FAIL; | 2939 return FAIL; |
2950 return OK; | 2940 return OK; |
2951 } | 2941 } |
2952 #endif | 2942 #endif |
2953 | 2943 |
2958 int_u modifiers; | 2948 int_u modifiers; |
2959 char_u **fnames = NULL; | 2949 char_u **fnames = NULL; |
2960 int count; | 2950 int count; |
2961 int i, j; | 2951 int i, j; |
2962 | 2952 |
2963 /* Get drop position, modifiers and count of items */ | 2953 // Get drop position, modifiers and count of items |
2964 { | 2954 { |
2965 Point point; | 2955 Point point; |
2966 SInt16 mouseUpModifiers; | 2956 SInt16 mouseUpModifiers; |
2967 UInt16 countItem; | 2957 UInt16 countItem; |
2968 | 2958 |
2978 | 2968 |
2979 fnames = ALLOC_MULT(char_u *, count); | 2969 fnames = ALLOC_MULT(char_u *, count); |
2980 if (fnames == NULL) | 2970 if (fnames == NULL) |
2981 return dragNotAcceptedErr; | 2971 return dragNotAcceptedErr; |
2982 | 2972 |
2983 /* Get file names dropped */ | 2973 // Get file names dropped |
2984 for (i = j = 0; i < count; ++i) | 2974 for (i = j = 0; i < count; ++i) |
2985 { | 2975 { |
2986 DragItemRef item; | 2976 DragItemRef item; |
2987 OSErr err; | 2977 OSErr err; |
2988 Size size; | 2978 Size size; |
3001 } | 2991 } |
3002 count = j; | 2992 count = j; |
3003 | 2993 |
3004 gui_handle_drop(x, y, modifiers, fnames, count); | 2994 gui_handle_drop(x, y, modifiers, fnames, count); |
3005 | 2995 |
3006 /* Fake mouse event to wake from stall */ | 2996 // Fake mouse event to wake from stall |
3007 PostEvent(mouseUp, 0); | 2997 PostEvent(mouseUp, 0); |
3008 | 2998 |
3009 return noErr; | 2999 return noErr; |
3010 } | 3000 } |
3011 | 3001 |
3014 * etc. | 3004 * etc. |
3015 */ | 3005 */ |
3016 int | 3006 int |
3017 gui_mch_init(void) | 3007 gui_mch_init(void) |
3018 { | 3008 { |
3019 /* TODO: Move most of this stuff toward gui_mch_init */ | 3009 // TODO: Move most of this stuff toward gui_mch_init |
3020 Rect windRect; | 3010 Rect windRect; |
3021 MenuHandle pomme; | 3011 MenuHandle pomme; |
3022 EventHandlerRef mouseWheelHandlerRef; | 3012 EventHandlerRef mouseWheelHandlerRef; |
3023 EventTypeSpec eventTypeSpec; | 3013 EventTypeSpec eventTypeSpec; |
3024 ControlRef rootControl; | 3014 ControlRef rootControl; |
3025 | 3015 |
3026 if (Gestalt(gestaltSystemVersion, &gMacSystemVersion) != noErr) | 3016 if (Gestalt(gestaltSystemVersion, &gMacSystemVersion) != noErr) |
3027 gMacSystemVersion = 0x1000; /* TODO: Default to minimum sensible value */ | 3017 gMacSystemVersion = 0x1000; // TODO: Default to minimum sensible value |
3028 | 3018 |
3029 #if 1 | 3019 #if 1 |
3030 InitCursor(); | 3020 InitCursor(); |
3031 | 3021 |
3032 RegisterAppearanceClient(); | 3022 RegisterAppearanceClient(); |
3033 | 3023 |
3034 #ifdef USE_AEVENT | 3024 #ifdef USE_AEVENT |
3035 (void) InstallAEHandlers(); | 3025 (void) InstallAEHandlers(); |
3036 #endif | 3026 #endif |
3037 | 3027 |
3038 pomme = NewMenu(256, "\p\024"); /* 0x14= = Apple Menu */ | 3028 pomme = NewMenu(256, "\p\024"); // 0x14= = Apple Menu |
3039 | 3029 |
3040 AppendMenu(pomme, "\pAbout VIM"); | 3030 AppendMenu(pomme, "\pAbout VIM"); |
3041 | 3031 |
3042 InsertMenu(pomme, 0); | 3032 InsertMenu(pomme, 0); |
3043 | 3033 |
3061 gui.char_width = 7; | 3051 gui.char_width = 7; |
3062 gui.char_height = 11; | 3052 gui.char_height = 11; |
3063 gui.char_ascent = 6; | 3053 gui.char_ascent = 6; |
3064 gui.num_rows = 24; | 3054 gui.num_rows = 24; |
3065 gui.num_cols = 80; | 3055 gui.num_cols = 80; |
3066 gui.in_focus = TRUE; /* For the moment -> syn. of front application */ | 3056 gui.in_focus = TRUE; // For the moment -> syn. of front application |
3067 | 3057 |
3068 gScrollAction = NewControlActionUPP(gui_mac_scroll_action); | 3058 gScrollAction = NewControlActionUPP(gui_mac_scroll_action); |
3069 gScrollDrag = NewControlActionUPP(gui_mac_drag_thumb); | 3059 gScrollDrag = NewControlActionUPP(gui_mac_drag_thumb); |
3070 | 3060 |
3071 /* Install Carbon event callbacks. */ | 3061 // Install Carbon event callbacks. |
3072 (void)InstallFontPanelHandler(); | 3062 (void)InstallFontPanelHandler(); |
3073 | 3063 |
3074 dragRectEnbl = FALSE; | 3064 dragRectEnbl = FALSE; |
3075 dragRgn = NULL; | 3065 dragRgn = NULL; |
3076 dragRectControl = kCreateEmpty; | 3066 dragRectControl = kCreateEmpty; |
3077 cursorRgn = NewRgn(); | 3067 cursorRgn = NewRgn(); |
3078 #endif | 3068 #endif |
3079 /* Display any pending error messages */ | 3069 // Display any pending error messages |
3080 display_errors(); | 3070 display_errors(); |
3081 | 3071 |
3082 /* Get background/foreground colors from system */ | 3072 // Get background/foreground colors from system |
3083 /* TODO: do the appropriate call to get real defaults */ | 3073 // TODO: do the appropriate call to get real defaults |
3084 gui.norm_pixel = 0x00000000; | 3074 gui.norm_pixel = 0x00000000; |
3085 gui.back_pixel = 0x00FFFFFF; | 3075 gui.back_pixel = 0x00FFFFFF; |
3086 | 3076 |
3087 /* Get the colors from the "Normal" group (set in syntax.c or in a vimrc | 3077 // Get the colors from the "Normal" group (set in syntax.c or in a vimrc |
3088 * file). */ | 3078 // file). |
3089 set_normal_colors(); | 3079 set_normal_colors(); |
3090 | 3080 |
3091 /* | 3081 /* |
3092 * Check that none of the colors are the same as the background color. | 3082 * Check that none of the colors are the same as the background color. |
3093 * Then store the current values as the defaults. | 3083 * Then store the current values as the defaults. |
3094 */ | 3084 */ |
3095 gui_check_colors(); | 3085 gui_check_colors(); |
3096 gui.def_norm_pixel = gui.norm_pixel; | 3086 gui.def_norm_pixel = gui.norm_pixel; |
3097 gui.def_back_pixel = gui.back_pixel; | 3087 gui.def_back_pixel = gui.back_pixel; |
3098 | 3088 |
3099 /* Get the colors for the highlight groups (gui_check_colors() might have | 3089 // Get the colors for the highlight groups (gui_check_colors() might have |
3100 * changed them) */ | 3090 // changed them) |
3101 highlight_gui_started(); | 3091 highlight_gui_started(); |
3102 | 3092 |
3103 /* | 3093 /* |
3104 * Setting the gui constants | 3094 * Setting the gui constants |
3105 */ | 3095 */ |
3106 #ifdef FEAT_MENU | 3096 #ifdef FEAT_MENU |
3107 gui.menu_height = 0; | 3097 gui.menu_height = 0; |
3108 #endif | 3098 #endif |
3109 gui.scrollbar_height = gui.scrollbar_width = 15; /* cheat 1 overlap */ | 3099 gui.scrollbar_height = gui.scrollbar_width = 15; // cheat 1 overlap |
3110 gui.border_offset = gui.border_width = 2; | 3100 gui.border_offset = gui.border_width = 2; |
3111 | 3101 |
3112 /* If Quartz-style text anti aliasing is available (see | 3102 // If Quartz-style text anti aliasing is available (see |
3113 gui_mch_draw_string() below), enable it for all font sizes. */ | 3103 // gui_mch_draw_string() below), enable it for all font sizes. |
3114 vim_setenv((char_u *)"QDTEXT_MINSIZE", (char_u *)"1"); | 3104 vim_setenv((char_u *)"QDTEXT_MINSIZE", (char_u *)"1"); |
3115 | 3105 |
3116 eventTypeSpec.eventClass = kEventClassMouse; | 3106 eventTypeSpec.eventClass = kEventClassMouse; |
3117 eventTypeSpec.eventKind = kEventMouseWheelMoved; | 3107 eventTypeSpec.eventKind = kEventMouseWheelMoved; |
3118 mouseWheelHandlerUPP = NewEventHandlerUPP(gui_mac_mouse_wheel); | 3108 mouseWheelHandlerUPP = NewEventHandlerUPP(gui_mac_mouse_wheel); |
3126 | 3116 |
3127 #ifdef USE_CARBONKEYHANDLER | 3117 #ifdef USE_CARBONKEYHANDLER |
3128 InterfaceTypeList supportedServices = { kUnicodeDocument }; | 3118 InterfaceTypeList supportedServices = { kUnicodeDocument }; |
3129 NewTSMDocument(1, supportedServices, &gTSMDocument, 0); | 3119 NewTSMDocument(1, supportedServices, &gTSMDocument, 0); |
3130 | 3120 |
3131 /* We don't support inline input yet, use input window by default */ | 3121 // We don't support inline input yet, use input window by default |
3132 UseInputWindow(gTSMDocument, TRUE); | 3122 UseInputWindow(gTSMDocument, TRUE); |
3133 | 3123 |
3134 /* Should we activate the document by default? */ | 3124 // Should we activate the document by default? |
3135 // ActivateTSMDocument(gTSMDocument); | 3125 // ActivateTSMDocument(gTSMDocument); |
3136 | 3126 |
3137 EventTypeSpec textEventTypes[] = { | 3127 EventTypeSpec textEventTypes[] = { |
3138 { kEventClassTextInput, kEventTextInputUpdateActiveInputArea }, | 3128 { kEventClassTextInput, kEventTextInputUpdateActiveInputArea }, |
3139 { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent }, | 3129 { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent }, |
3153 EventTypeSpec windowEventTypes[] = { | 3143 EventTypeSpec windowEventTypes[] = { |
3154 { kEventClassWindow, kEventWindowActivated }, | 3144 { kEventClassWindow, kEventWindowActivated }, |
3155 { kEventClassWindow, kEventWindowDeactivated }, | 3145 { kEventClassWindow, kEventWindowDeactivated }, |
3156 }; | 3146 }; |
3157 | 3147 |
3158 /* Install window event handler to support TSMDocument activate and | 3148 // Install window event handler to support TSMDocument activate and |
3159 * deactivate */ | 3149 // deactivate |
3160 winEventHandlerUPP = NewEventHandlerUPP(gui_mac_handle_window_activate); | 3150 winEventHandlerUPP = NewEventHandlerUPP(gui_mac_handle_window_activate); |
3161 if (noErr != InstallWindowEventHandler(gui.VimWindow, | 3151 if (noErr != InstallWindowEventHandler(gui.VimWindow, |
3162 winEventHandlerUPP, | 3152 winEventHandlerUPP, |
3163 NR_ELEMS(windowEventTypes), | 3153 NR_ELEMS(windowEventTypes), |
3164 windowEventTypes, NULL, NULL)) | 3154 windowEventTypes, NULL, NULL)) |
3173 * Create the tabline | 3163 * Create the tabline |
3174 */ | 3164 */ |
3175 initialise_tabline(); | 3165 initialise_tabline(); |
3176 #endif | 3166 #endif |
3177 | 3167 |
3178 /* TODO: Load bitmap if using TOOLBAR */ | 3168 // TODO: Load bitmap if using TOOLBAR |
3179 return OK; | 3169 return OK; |
3180 } | 3170 } |
3181 | 3171 |
3182 /* | 3172 /* |
3183 * Called when the foreground or background color has been changed. | 3173 * Called when the foreground or background color has been changed. |
3184 */ | 3174 */ |
3185 void | 3175 void |
3186 gui_mch_new_colors(void) | 3176 gui_mch_new_colors(void) |
3187 { | 3177 { |
3188 /* TODO: | 3178 // TODO: |
3189 * This proc is called when Normal is set to a value | 3179 // This proc is called when Normal is set to a value |
3190 * so what must be done? I don't know | 3180 // so what must be done? I don't know |
3191 */ | |
3192 } | 3181 } |
3193 | 3182 |
3194 /* | 3183 /* |
3195 * Open the GUI window which was created by a call to gui_mch_init(). | 3184 * Open the GUI window which was created by a call to gui_mch_init(). |
3196 */ | 3185 */ |
3227 #endif | 3216 #endif |
3228 | 3217 |
3229 void | 3218 void |
3230 gui_mch_exit(int rc) | 3219 gui_mch_exit(int rc) |
3231 { | 3220 { |
3232 /* TODO: find out all what is missing here? */ | 3221 // TODO: find out all what is missing here? |
3233 DisposeRgn(cursorRgn); | 3222 DisposeRgn(cursorRgn); |
3234 | 3223 |
3235 #ifdef USE_CARBONKEYHANDLER | 3224 #ifdef USE_CARBONKEYHANDLER |
3236 if (keyEventHandlerUPP) | 3225 if (keyEventHandlerUPP) |
3237 DisposeEventHandlerUPP(keyEventHandlerUPP); | 3226 DisposeEventHandlerUPP(keyEventHandlerUPP); |
3248 FixTSMDocument(gTSMDocument); | 3237 FixTSMDocument(gTSMDocument); |
3249 DeactivateTSMDocument(gTSMDocument); | 3238 DeactivateTSMDocument(gTSMDocument); |
3250 DeleteTSMDocument(gTSMDocument); | 3239 DeleteTSMDocument(gTSMDocument); |
3251 #endif | 3240 #endif |
3252 | 3241 |
3253 /* Exit to shell? */ | 3242 // Exit to shell? |
3254 exit(rc); | 3243 exit(rc); |
3255 } | 3244 } |
3256 | 3245 |
3257 /* | 3246 /* |
3258 * Get the position of the top left corner of the window. | 3247 * Get the position of the top left corner of the window. |
3259 */ | 3248 */ |
3260 int | 3249 int |
3261 gui_mch_get_winpos(int *x, int *y) | 3250 gui_mch_get_winpos(int *x, int *y) |
3262 { | 3251 { |
3263 /* TODO */ | 3252 // TODO |
3264 Rect bounds; | 3253 Rect bounds; |
3265 OSStatus status; | 3254 OSStatus status; |
3266 | 3255 |
3267 /* Carbon >= 1.0.2, MacOS >= 8.5 */ | 3256 // Carbon >= 1.0.2, MacOS >= 8.5 |
3268 status = GetWindowBounds(gui.VimWindow, kWindowStructureRgn, &bounds); | 3257 status = GetWindowBounds(gui.VimWindow, kWindowStructureRgn, &bounds); |
3269 | 3258 |
3270 if (status != noErr) | 3259 if (status != noErr) |
3271 return FAIL; | 3260 return FAIL; |
3272 *x = bounds.left; | 3261 *x = bounds.left; |
3279 * coordinates. | 3268 * coordinates. |
3280 */ | 3269 */ |
3281 void | 3270 void |
3282 gui_mch_set_winpos(int x, int y) | 3271 gui_mch_set_winpos(int x, int y) |
3283 { | 3272 { |
3284 /* TODO: Should make sure the window is move within range | 3273 // TODO: Should make sure the window is move within range |
3285 * e.g.: y > ~16 [Menu bar], x > 0, x < screen width | 3274 // e.g.: y > ~16 [Menu bar], x > 0, x < screen width |
3286 */ | |
3287 MoveWindowStructure(gui.VimWindow, x, y); | 3275 MoveWindowStructure(gui.VimWindow, x, y); |
3288 } | 3276 } |
3289 | 3277 |
3290 void | 3278 void |
3291 gui_mch_set_shellsize( | 3279 gui_mch_set_shellsize( |
3302 | 3290 |
3303 if (gui.which_scrollbars[SBAR_LEFT]) | 3291 if (gui.which_scrollbars[SBAR_LEFT]) |
3304 { | 3292 { |
3305 VimPort = GetWindowPort(gui.VimWindow); | 3293 VimPort = GetWindowPort(gui.VimWindow); |
3306 GetPortBounds(VimPort, &VimBound); | 3294 GetPortBounds(VimPort, &VimBound); |
3307 VimBound.left = -gui.scrollbar_width; /* + 1;*/ | 3295 VimBound.left = -gui.scrollbar_width; // + 1; |
3308 SetPortBounds(VimPort, &VimBound); | 3296 SetPortBounds(VimPort, &VimBound); |
3309 /* GetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &winPortRect); ??*/ | 3297 // GetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &winPortRect); ?? |
3310 } | 3298 } |
3311 else | 3299 else |
3312 { | 3300 { |
3313 VimPort = GetWindowPort(gui.VimWindow); | 3301 VimPort = GetWindowPort(gui.VimWindow); |
3314 GetPortBounds(VimPort, &VimBound); | 3302 GetPortBounds(VimPort, &VimBound); |
3349 { | 3337 { |
3350 GuiFont selected_font = NOFONT; | 3338 GuiFont selected_font = NOFONT; |
3351 OSStatus status; | 3339 OSStatus status; |
3352 FontSelectionQDStyle curr_font; | 3340 FontSelectionQDStyle curr_font; |
3353 | 3341 |
3354 /* Initialize the Font Panel with the current font. */ | 3342 // Initialize the Font Panel with the current font. |
3355 curr_font.instance.fontFamily = gui.norm_font & 0xFFFF; | 3343 curr_font.instance.fontFamily = gui.norm_font & 0xFFFF; |
3356 curr_font.size = (gui.norm_font >> 16); | 3344 curr_font.size = (gui.norm_font >> 16); |
3357 /* TODO: set fontStyle once styles are supported in gui_mac_find_font() */ | 3345 // TODO: set fontStyle once styles are supported in gui_mac_find_font() |
3358 curr_font.instance.fontStyle = 0; | 3346 curr_font.instance.fontStyle = 0; |
3359 curr_font.hasColor = false; | 3347 curr_font.hasColor = false; |
3360 curr_font.version = 0; /* version number of the style structure */ | 3348 curr_font.version = 0; // version number of the style structure |
3361 status = SetFontInfoForSelection(kFontSelectionQDType, | 3349 status = SetFontInfoForSelection(kFontSelectionQDType, |
3362 /*numStyles=*/1, &curr_font, /*eventTarget=*/NULL); | 3350 /*numStyles=*/1, &curr_font, /*eventTarget=*/NULL); |
3363 | 3351 |
3364 gFontPanelInfo.family = curr_font.instance.fontFamily; | 3352 gFontPanelInfo.family = curr_font.instance.fontFamily; |
3365 gFontPanelInfo.style = curr_font.instance.fontStyle; | 3353 gFontPanelInfo.style = curr_font.instance.fontStyle; |
3366 gFontPanelInfo.size = curr_font.size; | 3354 gFontPanelInfo.size = curr_font.size; |
3367 | 3355 |
3368 /* Pop up the Font Panel. */ | 3356 // Pop up the Font Panel. |
3369 status = FPShowHideFontPanel(); | 3357 status = FPShowHideFontPanel(); |
3370 if (status == noErr) | 3358 if (status == noErr) |
3371 { | 3359 { |
3372 /* | 3360 /* |
3373 * The Font Panel is modeless. We really need it to be modal, | 3361 * The Font Panel is modeless. We really need it to be modal, |
3410 * could not be loaded, OK otherwise. | 3398 * could not be loaded, OK otherwise. |
3411 */ | 3399 */ |
3412 int | 3400 int |
3413 gui_mch_init_font(char_u *font_name, int fontset) | 3401 gui_mch_init_font(char_u *font_name, int fontset) |
3414 { | 3402 { |
3415 /* TODO: Add support for bold italic underline proportional etc... */ | 3403 // TODO: Add support for bold italic underline proportional etc... |
3416 Str255 suggestedFont = "\pMonaco"; | 3404 Str255 suggestedFont = "\pMonaco"; |
3417 int suggestedSize = 10; | 3405 int suggestedSize = 10; |
3418 FontInfo font_info; | 3406 FontInfo font_info; |
3419 short font_id; | 3407 short font_id; |
3420 GuiFont font; | 3408 GuiFont font; |
3424 gui_mac_create_atsui_style(); | 3412 gui_mac_create_atsui_style(); |
3425 #endif | 3413 #endif |
3426 | 3414 |
3427 if (font_name == NULL) | 3415 if (font_name == NULL) |
3428 { | 3416 { |
3429 /* First try to get the suggested font */ | 3417 // First try to get the suggested font |
3430 GetFNum(suggestedFont, &font_id); | 3418 GetFNum(suggestedFont, &font_id); |
3431 | 3419 |
3432 if (font_id == 0) | 3420 if (font_id == 0) |
3433 { | 3421 { |
3434 /* Then pickup the standard application font */ | 3422 // Then pickup the standard application font |
3435 font_id = GetAppFont(); | 3423 font_id = GetAppFont(); |
3436 STRCPY(used_font_name, "default"); | 3424 STRCPY(used_font_name, "default"); |
3437 } | 3425 } |
3438 else | 3426 else |
3439 STRCPY(used_font_name, "Monaco"); | 3427 STRCPY(used_font_name, "Monaco"); |
3445 | 3433 |
3446 font = gui_mac_select_font(used_font_name); | 3434 font = gui_mac_select_font(used_font_name); |
3447 if (font == NOFONT) | 3435 if (font == NOFONT) |
3448 return FAIL; | 3436 return FAIL; |
3449 | 3437 |
3450 /* Set guifont to the name of the selected font. */ | 3438 // Set guifont to the name of the selected font. |
3451 new_p_guifont = alloc(STRLEN(used_font_name) + 1); | 3439 new_p_guifont = alloc(STRLEN(used_font_name) + 1); |
3452 if (new_p_guifont != NULL) | 3440 if (new_p_guifont != NULL) |
3453 { | 3441 { |
3454 STRCPY(new_p_guifont, used_font_name); | 3442 STRCPY(new_p_guifont, used_font_name); |
3455 vim_free(p_guifont); | 3443 vim_free(p_guifont); |
3456 p_guifont = new_p_guifont; | 3444 p_guifont = new_p_guifont; |
3457 /* Replace spaces in the font name with underscores. */ | 3445 // Replace spaces in the font name with underscores. |
3458 for ( ; *new_p_guifont; ++new_p_guifont) | 3446 for ( ; *new_p_guifont; ++new_p_guifont) |
3459 { | 3447 { |
3460 if (*new_p_guifont == ' ') | 3448 if (*new_p_guifont == ' ') |
3461 *new_p_guifont = '_'; | 3449 *new_p_guifont = '_'; |
3462 } | 3450 } |
3585 gFontStyle = NULL; | 3573 gFontStyle = NULL; |
3586 } | 3574 } |
3587 | 3575 |
3588 if (has_mbyte) | 3576 if (has_mbyte) |
3589 { | 3577 { |
3590 /* FIXME: we should use a more mbyte sensitive way to support | 3578 // FIXME: we should use a more mbyte sensitive way to support |
3591 * wide font drawing */ | 3579 // wide font drawing |
3592 fontWidth = Long2Fix(gui.char_width * 2); | 3580 fontWidth = Long2Fix(gui.char_width * 2); |
3593 | 3581 |
3594 if (ATSUSetAttributes(gWideFontStyle, | 3582 if (ATSUSetAttributes(gWideFontStyle, |
3595 (sizeof attribTags) / sizeof(ATSUAttributeTag), | 3583 (sizeof attribTags) / sizeof(ATSUAttributeTag), |
3596 attribTags, attribSizes, attribValues) != noErr) | 3584 attribTags, attribSizes, attribValues) != noErr) |
3613 GuiFont currFont; | 3601 GuiFont currFont; |
3614 ByteCount actualFontByteCount; | 3602 ByteCount actualFontByteCount; |
3615 | 3603 |
3616 if (p_macatsui && gFontStyle) | 3604 if (p_macatsui && gFontStyle) |
3617 { | 3605 { |
3618 /* Avoid setting same font again */ | 3606 // Avoid setting same font again |
3619 if (ATSUGetAttribute(gFontStyle, kATSUMaxATSUITagValue + 1, | 3607 if (ATSUGetAttribute(gFontStyle, kATSUMaxATSUITagValue + 1, |
3620 sizeof(font), &currFont, &actualFontByteCount) == noErr | 3608 sizeof(font), &currFont, &actualFontByteCount) == noErr |
3621 && actualFontByteCount == (sizeof font)) | 3609 && actualFontByteCount == (sizeof font)) |
3622 { | 3610 { |
3623 if (currFont == font) | 3611 if (currFont == font) |
3627 gui_mac_set_font_attributes(font); | 3615 gui_mac_set_font_attributes(font); |
3628 } | 3616 } |
3629 | 3617 |
3630 if (p_macatsui && !gIsFontFallbackSet) | 3618 if (p_macatsui && !gIsFontFallbackSet) |
3631 { | 3619 { |
3632 /* Setup automatic font substitution. The user's guifontwide | 3620 // Setup automatic font substitution. The user's guifontwide |
3633 * is tried first, then the system tries other fonts. */ | 3621 // is tried first, then the system tries other fonts. |
3634 /* | 3622 #if 0 |
3635 ATSUAttributeTag fallbackTags[] = { kATSULineFontFallbacksTag }; | 3623 ATSUAttributeTag fallbackTags[] = { kATSULineFontFallbacksTag }; |
3636 ByteCount fallbackSizes[] = { sizeof(ATSUFontFallbacks) }; | 3624 ByteCount fallbackSizes[] = { sizeof(ATSUFontFallbacks) }; |
3637 ATSUCreateFontFallbacks(&gFontFallbacks); | 3625 ATSUCreateFontFallbacks(&gFontFallbacks); |
3638 ATSUSetObjFontFallbacks(gFontFallbacks, ); | 3626 ATSUSetObjFontFallbacks(gFontFallbacks, ); |
3639 */ | 3627 #endif |
3640 if (gui.wide_font) | 3628 if (gui.wide_font) |
3641 { | 3629 { |
3642 ATSUFontID fallbackFonts; | 3630 ATSUFontID fallbackFonts; |
3643 gIsFontFallbackSet = TRUE; | 3631 gIsFontFallbackSet = TRUE; |
3644 | 3632 |
3650 { | 3638 { |
3651 ATSUSetFontFallbacks((sizeof fallbackFonts)/sizeof(ATSUFontID), | 3639 ATSUSetFontFallbacks((sizeof fallbackFonts)/sizeof(ATSUFontID), |
3652 &fallbackFonts, | 3640 &fallbackFonts, |
3653 kATSUSequentialFallbacksPreferred); | 3641 kATSUSequentialFallbacksPreferred); |
3654 } | 3642 } |
3655 /* | 3643 // ATSUAttributeValuePtr fallbackValues[] = { }; |
3656 ATSUAttributeValuePtr fallbackValues[] = { }; | |
3657 */ | |
3658 } | 3644 } |
3659 } | 3645 } |
3660 #endif | 3646 #endif |
3661 TextSize(font >> 16); | 3647 TextSize(font >> 16); |
3662 TextFont(font & 0xFFFF); | 3648 TextFont(font & 0xFFFF); |
3682 * Return INVALCOLOR when failed. | 3668 * Return INVALCOLOR when failed. |
3683 */ | 3669 */ |
3684 guicolor_T | 3670 guicolor_T |
3685 gui_mch_get_color(char_u *name) | 3671 gui_mch_get_color(char_u *name) |
3686 { | 3672 { |
3687 /* TODO: Add support for the new named color of MacOS 8 | 3673 // TODO: Add support for the new named color of MacOS 8 |
3688 */ | |
3689 RGBColor MacColor; | 3674 RGBColor MacColor; |
3690 | 3675 |
3691 if (STRICMP(name, "hilite") == 0) | 3676 if (STRICMP(name, "hilite") == 0) |
3692 { | 3677 { |
3693 LMGetHiliteRGB(&MacColor); | 3678 LMGetHiliteRGB(&MacColor); |
3784 /* | 3769 /* |
3785 * On OS X, try using Quartz-style text antialiasing. | 3770 * On OS X, try using Quartz-style text antialiasing. |
3786 */ | 3771 */ |
3787 if (gMacSystemVersion >= 0x1020) | 3772 if (gMacSystemVersion >= 0x1020) |
3788 { | 3773 { |
3789 /* Quartz antialiasing is available only in OS 10.2 and later. */ | 3774 // Quartz antialiasing is available only in OS 10.2 and later. |
3790 UInt32 qd_flags = (p_antialias ? | 3775 UInt32 qd_flags = (p_antialias ? |
3791 kQDUseCGTextRendering | kQDUseCGTextMetrics : 0); | 3776 kQDUseCGTextRendering | kQDUseCGTextMetrics : 0); |
3792 QDSwapTextFlags(qd_flags); | 3777 QDSwapTextFlags(qd_flags); |
3793 } | 3778 } |
3794 | 3779 |
3806 { | 3791 { |
3807 Rect rc; | 3792 Rect rc; |
3808 | 3793 |
3809 rc.left = FILL_X(col); | 3794 rc.left = FILL_X(col); |
3810 rc.top = FILL_Y(row); | 3795 rc.top = FILL_Y(row); |
3811 /* Multibyte computation taken from gui_w32.c */ | 3796 // Multibyte computation taken from gui_w32.c |
3812 if (has_mbyte) | 3797 if (has_mbyte) |
3813 { | 3798 { |
3814 /* Compute the length in display cells. */ | 3799 // Compute the length in display cells. |
3815 rc.right = FILL_X(col + mb_string2cells(s, len)); | 3800 rc.right = FILL_X(col + mb_string2cells(s, len)); |
3816 } | 3801 } |
3817 else | 3802 else |
3818 rc.right = FILL_X(col + len) + (col + len == Columns); | 3803 rc.right = FILL_X(col + len) + (col + len == Columns); |
3819 rc.bottom = FILL_Y(row + 1); | 3804 rc.bottom = FILL_Y(row + 1); |
3829 face |= bold; | 3814 face |= bold; |
3830 if (flags & DRAW_UNDERL) | 3815 if (flags & DRAW_UNDERL) |
3831 face |= underline; | 3816 face |= underline; |
3832 TextFace(face); | 3817 TextFace(face); |
3833 | 3818 |
3834 /* Quartz antialiasing works only in srcOr transfer mode. */ | 3819 // Quartz antialiasing works only in srcOr transfer mode. |
3835 TextMode(srcOr); | 3820 TextMode(srcOr); |
3836 | 3821 |
3837 MoveTo(TEXT_X(col), TEXT_Y(row)); | 3822 MoveTo(TEXT_X(col), TEXT_Y(row)); |
3838 DrawText((char*)s, 0, len); | 3823 DrawText((char*)s, 0, len); |
3839 } | 3824 } |
3840 else | 3825 else |
3841 { | 3826 { |
3842 /* Use old-style, non-antialiased QuickDraw text rendering. */ | 3827 // Use old-style, non-antialiased QuickDraw text rendering. |
3843 TextMode(srcCopy); | 3828 TextMode(srcCopy); |
3844 TextFace(normal); | 3829 TextFace(normal); |
3845 | 3830 |
3846 /* SelectFont(hdc, gui.currFont); */ | 3831 // SelectFont(hdc, gui.currFont); |
3847 | 3832 |
3848 if (flags & DRAW_TRANSP) | 3833 if (flags & DRAW_TRANSP) |
3849 TextMode(srcOr); | 3834 TextMode(srcOr); |
3850 | 3835 |
3851 MoveTo(TEXT_X(col), TEXT_Y(row)); | 3836 MoveTo(TEXT_X(col), TEXT_Y(row)); |
3879 #ifdef USE_ATSUI_DRAWING | 3864 #ifdef USE_ATSUI_DRAWING |
3880 | 3865 |
3881 static void | 3866 static void |
3882 draw_string_ATSUI(int row, int col, char_u *s, int len, int flags) | 3867 draw_string_ATSUI(int row, int col, char_u *s, int len, int flags) |
3883 { | 3868 { |
3884 /* ATSUI requires utf-16 strings */ | 3869 // ATSUI requires utf-16 strings |
3885 UniCharCount utf16_len; | 3870 UniCharCount utf16_len; |
3886 UniChar *tofree = mac_enc_to_utf16(s, len, (size_t *)&utf16_len); | 3871 UniChar *tofree = mac_enc_to_utf16(s, len, (size_t *)&utf16_len); |
3887 utf16_len /= sizeof(UniChar); | 3872 utf16_len /= sizeof(UniChar); |
3888 | 3873 |
3889 /* - ATSUI automatically antialiases text (Someone) | 3874 // - ATSUI automatically antialiases text (Someone) |
3890 * - for some reason it does not work... (Jussi) */ | 3875 // - for some reason it does not work... (Jussi) |
3891 #ifdef MAC_ATSUI_DEBUG | 3876 #ifdef MAC_ATSUI_DEBUG |
3892 fprintf(stderr, "row = %d, col = %d, len = %d: '%c'\n", | 3877 fprintf(stderr, "row = %d, col = %d, len = %d: '%c'\n", |
3893 row, col, len, len == 1 ? s[0] : ' '); | 3878 row, col, len, len == 1 ? s[0] : ' '); |
3894 #endif | 3879 #endif |
3895 /* | 3880 /* |
3905 { | 3890 { |
3906 Rect rc; | 3891 Rect rc; |
3907 | 3892 |
3908 rc.left = FILL_X(col); | 3893 rc.left = FILL_X(col); |
3909 rc.top = FILL_Y(row); | 3894 rc.top = FILL_Y(row); |
3910 /* Multibyte computation taken from gui_w32.c */ | 3895 // Multibyte computation taken from gui_w32.c |
3911 if (has_mbyte) | 3896 if (has_mbyte) |
3912 { | 3897 { |
3913 /* Compute the length in display cells. */ | 3898 // Compute the length in display cells. |
3914 rc.right = FILL_X(col + mb_string2cells(s, len)); | 3899 rc.right = FILL_X(col + mb_string2cells(s, len)); |
3915 } | 3900 } |
3916 else | 3901 else |
3917 rc.right = FILL_X(col + len) + (col + len == Columns); | 3902 rc.right = FILL_X(col + len) + (col + len == Columns); |
3918 | 3903 |
3922 | 3907 |
3923 { | 3908 { |
3924 TextMode(srcCopy); | 3909 TextMode(srcCopy); |
3925 TextFace(normal); | 3910 TextFace(normal); |
3926 | 3911 |
3927 /* SelectFont(hdc, gui.currFont); */ | 3912 // SelectFont(hdc, gui.currFont); |
3928 if (flags & DRAW_TRANSP) | 3913 if (flags & DRAW_TRANSP) |
3929 TextMode(srcOr); | 3914 TextMode(srcOr); |
3930 | 3915 |
3931 MoveTo(TEXT_X(col), TEXT_Y(row)); | 3916 MoveTo(TEXT_X(col), TEXT_Y(row)); |
3932 | 3917 |
3973 kATSUToTextEnd, utf16_len); | 3958 kATSUToTextEnd, utf16_len); |
3974 /* | 3959 /* |
3975 ATSUSetRunStyle(textLayout, gFontStyle, | 3960 ATSUSetRunStyle(textLayout, gFontStyle, |
3976 kATSUFromTextBeginning, kATSUToTextEnd); */ | 3961 kATSUFromTextBeginning, kATSUToTextEnd); */ |
3977 | 3962 |
3978 /* Compute the length in display cells. */ | 3963 // Compute the length in display cells. |
3979 for (n = 0; n < len; n += MB_BYTE2LEN(s[n])) | 3964 for (n = 0; n < len; n += MB_BYTE2LEN(s[n])) |
3980 { | 3965 { |
3981 width_in_cell = (*mb_ptr2cells)(s + n); | 3966 width_in_cell = (*mb_ptr2cells)(s + n); |
3982 | 3967 |
3983 /* probably we are switching from single byte character | 3968 // probably we are switching from single byte character |
3984 * to multibyte characters (which requires more than one | 3969 // to multibyte characters (which requires more than one |
3985 * cell to draw) */ | 3970 // cell to draw) |
3986 if (width_in_cell != last_width_in_cell) | 3971 if (width_in_cell != last_width_in_cell) |
3987 { | 3972 { |
3988 #ifdef MAC_ATSUI_DEBUG | 3973 #ifdef MAC_ATSUI_DEBUG |
3989 fprintf(stderr, "\tn = %2d, (%d-%d), offset = %d, yet_to_draw = %d\n", | 3974 fprintf(stderr, "\tn = %2d, (%d-%d), offset = %d, yet_to_draw = %d\n", |
3990 n, last_width_in_cell, width_in_cell, offset, yet_to_draw); | 3975 n, last_width_in_cell, width_in_cell, offset, yet_to_draw); |
4005 { | 3990 { |
4006 #ifdef MAC_ATSUI_DEBUG | 3991 #ifdef MAC_ATSUI_DEBUG |
4007 fprintf(stderr, "\tn = %2d, (%d-%d), offset = %d, yet_to_draw = %d\n", | 3992 fprintf(stderr, "\tn = %2d, (%d-%d), offset = %d, yet_to_draw = %d\n", |
4008 n, last_width_in_cell, width_in_cell, offset, yet_to_draw); | 3993 n, last_width_in_cell, width_in_cell, offset, yet_to_draw); |
4009 #endif | 3994 #endif |
4010 /* finish the rest style */ | 3995 // finish the rest style |
4011 textStyle = width_in_cell > 1 ? gWideFontStyle : gFontStyle; | 3996 textStyle = width_in_cell > 1 ? gWideFontStyle : gFontStyle; |
4012 ATSUSetRunStyle(textLayout, textStyle, offset, kATSUToTextEnd); | 3997 ATSUSetRunStyle(textLayout, textStyle, offset, kATSUToTextEnd); |
4013 } | 3998 } |
4014 | 3999 |
4015 ATSUSetTransientFontMatching(textLayout, TRUE); | 4000 ATSUSetTransientFontMatching(textLayout, TRUE); |
4037 | 4022 |
4038 ATSUDisposeTextLayout(textLayout); | 4023 ATSUDisposeTextLayout(textLayout); |
4039 } | 4024 } |
4040 } | 4025 } |
4041 | 4026 |
4042 /* drawing is done, now reset bold to normal */ | 4027 // drawing is done, now reset bold to normal |
4043 if (gFontStyle && flags & DRAW_BOLD) | 4028 if (gFontStyle && flags & DRAW_BOLD) |
4044 { | 4029 { |
4045 Boolean attValue = false; | 4030 Boolean attValue = false; |
4046 | 4031 |
4047 ATSUAttributeTag attribTags[] = { kATSUQDBoldfaceTag }; | 4032 ATSUAttributeTag attribTags[] = { kATSUQDBoldfaceTag }; |
4063 void | 4048 void |
4064 gui_mch_draw_string(int row, int col, char_u *s, int len, int flags) | 4049 gui_mch_draw_string(int row, int col, char_u *s, int len, int flags) |
4065 { | 4050 { |
4066 #if defined(USE_ATSUI_DRAWING) | 4051 #if defined(USE_ATSUI_DRAWING) |
4067 if (p_macatsui == 0 && p_macatsui_last != 0) | 4052 if (p_macatsui == 0 && p_macatsui_last != 0) |
4068 /* switch from macatsui to nomacatsui */ | 4053 // switch from macatsui to nomacatsui |
4069 gui_mac_dispose_atsui_style(); | 4054 gui_mac_dispose_atsui_style(); |
4070 else if (p_macatsui != 0 && p_macatsui_last == 0) | 4055 else if (p_macatsui != 0 && p_macatsui_last == 0) |
4071 /* switch from nomacatsui to macatsui */ | 4056 // switch from nomacatsui to macatsui |
4072 gui_mac_create_atsui_style(); | 4057 gui_mac_create_atsui_style(); |
4073 | 4058 |
4074 if (p_macatsui) | 4059 if (p_macatsui) |
4075 draw_string_ATSUI(row, col, s, len, flags); | 4060 draw_string_ATSUI(row, col, s, len, flags); |
4076 else | 4061 else |
4094 } | 4079 } |
4095 | 4080 |
4096 void | 4081 void |
4097 gui_mch_beep(void) | 4082 gui_mch_beep(void) |
4098 { | 4083 { |
4099 SysBeep(1); /* Should this be 0? (????) */ | 4084 SysBeep(1); // Should this be 0? (????) |
4100 } | 4085 } |
4101 | 4086 |
4102 void | 4087 void |
4103 gui_mch_flash(int msec) | 4088 gui_mch_flash(int msec) |
4104 { | 4089 { |
4105 /* Do a visual beep by reversing the foreground and background colors */ | 4090 // Do a visual beep by reversing the foreground and background colors |
4106 Rect rc; | 4091 Rect rc; |
4107 | 4092 |
4108 /* | 4093 /* |
4109 * Note: InvertRect() excludes right and bottom of rectangle. | 4094 * Note: InvertRect() excludes right and bottom of rectangle. |
4110 */ | 4095 */ |
4112 rc.top = 0; | 4097 rc.top = 0; |
4113 rc.right = gui.num_cols * gui.char_width; | 4098 rc.right = gui.num_cols * gui.char_width; |
4114 rc.bottom = gui.num_rows * gui.char_height; | 4099 rc.bottom = gui.num_rows * gui.char_height; |
4115 InvertRect(&rc); | 4100 InvertRect(&rc); |
4116 | 4101 |
4117 ui_delay((long)msec, TRUE); /* wait for some msec */ | 4102 ui_delay((long)msec, TRUE); // wait for some msec |
4118 | 4103 |
4119 InvertRect(&rc); | 4104 InvertRect(&rc); |
4120 } | 4105 } |
4121 | 4106 |
4122 /* | 4107 /* |
4141 * Iconify the GUI window. | 4126 * Iconify the GUI window. |
4142 */ | 4127 */ |
4143 void | 4128 void |
4144 gui_mch_iconify(void) | 4129 gui_mch_iconify(void) |
4145 { | 4130 { |
4146 /* TODO: find out what could replace iconify | 4131 // TODO: find out what could replace iconify |
4147 * -window shade? | 4132 // -window shade? |
4148 * -hide application? | 4133 // -hide application? |
4149 */ | |
4150 } | 4134 } |
4151 | 4135 |
4152 #if defined(FEAT_EVAL) || defined(PROTO) | 4136 #if defined(FEAT_EVAL) || defined(PROTO) |
4153 /* | 4137 /* |
4154 * Bring the Vim window to the foreground. | 4138 * Bring the Vim window to the foreground. |
4155 */ | 4139 */ |
4156 void | 4140 void |
4157 gui_mch_set_foreground(void) | 4141 gui_mch_set_foreground(void) |
4158 { | 4142 { |
4159 /* TODO */ | 4143 // TODO |
4160 } | 4144 } |
4161 #endif | 4145 #endif |
4162 | 4146 |
4163 /* | 4147 /* |
4164 * Draw a cursor without focus. | 4148 * Draw a cursor without focus. |
4190 gui_mch_draw_part_cursor(int w, int h, guicolor_T color) | 4174 gui_mch_draw_part_cursor(int w, int h, guicolor_T color) |
4191 { | 4175 { |
4192 Rect rc; | 4176 Rect rc; |
4193 | 4177 |
4194 #ifdef FEAT_RIGHTLEFT | 4178 #ifdef FEAT_RIGHTLEFT |
4195 /* vertical line should be on the right of current point */ | 4179 // vertical line should be on the right of current point |
4196 if (CURSOR_BAR_RIGHT) | 4180 if (CURSOR_BAR_RIGHT) |
4197 rc.left = FILL_X(gui.col + 1) - w; | 4181 rc.left = FILL_X(gui.col + 1) - w; |
4198 else | 4182 else |
4199 #endif | 4183 #endif |
4200 rc.left = FILL_X(gui.col); | 4184 rc.left = FILL_X(gui.col); |
4217 * immediately. | 4201 * immediately. |
4218 */ | 4202 */ |
4219 void | 4203 void |
4220 gui_mch_update(void) | 4204 gui_mch_update(void) |
4221 { | 4205 { |
4222 /* TODO: find what to do | 4206 // TODO: find what to do |
4223 * maybe call gui_mch_wait_for_chars (0) | 4207 // maybe call gui_mch_wait_for_chars (0) |
4224 * more like look at EventQueue then | 4208 // more like look at EventQueue then |
4225 * call heart of gui_mch_wait_for_chars; | 4209 // call heart of gui_mch_wait_for_chars; |
4226 * | 4210 // |
4227 * if (eventther) | 4211 // if (eventther) |
4228 * gui_mac_handle_event(&event); | 4212 // gui_mac_handle_event(&event); |
4229 */ | |
4230 EventRecord theEvent; | 4213 EventRecord theEvent; |
4231 | 4214 |
4232 if (EventAvail(everyEvent, &theEvent)) | 4215 if (EventAvail(everyEvent, &theEvent)) |
4233 if (theEvent.what != nullEvent) | 4216 if (theEvent.what != nullEvent) |
4234 gui_mch_wait_for_chars(0); | 4217 gui_mch_wait_for_chars(0); |
4264 EventRecord event; | 4247 EventRecord event; |
4265 long entryTick; | 4248 long entryTick; |
4266 long currentTick; | 4249 long currentTick; |
4267 long sleeppyTick; | 4250 long sleeppyTick; |
4268 | 4251 |
4269 /* If we are providing life feedback with the scrollbar, | 4252 // If we are providing life feedback with the scrollbar, |
4270 * we don't want to try to wait for an event, or else | 4253 // we don't want to try to wait for an event, or else |
4271 * there won't be any life feedback. | 4254 // there won't be any life feedback. |
4272 */ | |
4273 if (dragged_sb != NULL) | 4255 if (dragged_sb != NULL) |
4274 return FAIL; | 4256 return FAIL; |
4275 /* TODO: Check if FAIL is the proper return code */ | 4257 // TODO: Check if FAIL is the proper return code |
4276 | 4258 |
4277 entryTick = TickCount(); | 4259 entryTick = TickCount(); |
4278 | 4260 |
4279 allow_scrollbar = TRUE; | 4261 allow_scrollbar = TRUE; |
4280 | 4262 |
4281 do | 4263 do |
4282 { | 4264 { |
4283 /* if (dragRectControl == kCreateEmpty) | 4265 #if 0 |
4266 if (dragRectControl == kCreateEmpty) | |
4284 { | 4267 { |
4285 dragRgn = NULL; | 4268 dragRgn = NULL; |
4286 dragRectControl = kNothing; | 4269 dragRectControl = kNothing; |
4287 } | 4270 } |
4288 else*/ if (dragRectControl == kCreateRect) | 4271 else |
4272 #endif | |
4273 if (dragRectControl == kCreateRect) | |
4289 { | 4274 { |
4290 dragRgn = cursorRgn; | 4275 dragRgn = cursorRgn; |
4291 RectRgn(dragRgn, &dragRect); | 4276 RectRgn(dragRgn, &dragRect); |
4292 dragRectControl = kNothing; | 4277 dragRectControl = kNothing; |
4293 } | 4278 } |
4295 * Don't use gui_mch_update() because then we will spin-lock until a | 4280 * Don't use gui_mch_update() because then we will spin-lock until a |
4296 * char arrives, instead we use WaitNextEventWrp() to hang until an | 4281 * char arrives, instead we use WaitNextEventWrp() to hang until an |
4297 * event arrives. No need to check for input_buf_full because we are | 4282 * event arrives. No need to check for input_buf_full because we are |
4298 * returning as soon as it contains a single char. | 4283 * returning as soon as it contains a single char. |
4299 */ | 4284 */ |
4300 /* TODO: reduce wtime accordingly??? */ | 4285 // TODO: reduce wtime accordingly??? |
4301 if (wtime > -1) | 4286 if (wtime > -1) |
4302 sleeppyTick = 60 * wtime / 1000; | 4287 sleeppyTick = 60 * wtime / 1000; |
4303 else | 4288 else |
4304 sleeppyTick = 32767; | 4289 sleeppyTick = 32767; |
4305 | 4290 |
4322 | 4307 |
4323 /* | 4308 /* |
4324 * Output routines. | 4309 * Output routines. |
4325 */ | 4310 */ |
4326 | 4311 |
4327 /* Flush any output to the screen */ | 4312 /* |
4313 * Flush any output to the screen | |
4314 */ | |
4328 void | 4315 void |
4329 gui_mch_flush(void) | 4316 gui_mch_flush(void) |
4330 { | 4317 { |
4331 /* TODO: Is anything needed here? */ | 4318 // TODO: Is anything needed here? |
4332 } | 4319 } |
4333 | 4320 |
4334 /* | 4321 /* |
4335 * Clear a rectangular region of the screen from text pos (row1, col1) to | 4322 * Clear a rectangular region of the screen from text pos (row1, col1) to |
4336 * (row2, col2) inclusive. | 4323 * (row2, col2) inclusive. |
4366 rc.right = Columns * gui.char_width + 2 * gui.border_width; | 4353 rc.right = Columns * gui.char_width + 2 * gui.border_width; |
4367 rc.bottom = Rows * gui.char_height + 2 * gui.border_width; | 4354 rc.bottom = Rows * gui.char_height + 2 * gui.border_width; |
4368 | 4355 |
4369 gui_mch_set_bg_color(gui.back_pixel); | 4356 gui_mch_set_bg_color(gui.back_pixel); |
4370 EraseRect(&rc); | 4357 EraseRect(&rc); |
4371 /* gui_mch_set_fg_color(gui.norm_pixel); | 4358 // gui_mch_set_fg_color(gui.norm_pixel); |
4372 FrameRect(&rc); | 4359 // FrameRect(&rc); |
4373 */ | |
4374 } | 4360 } |
4375 | 4361 |
4376 /* | 4362 /* |
4377 * Delete the given number of lines from the given row, scrolling up any | 4363 * Delete the given number of lines from the given row, scrolling up any |
4378 * text further down within the scroll region. | 4364 * text further down within the scroll region. |
4380 void | 4366 void |
4381 gui_mch_delete_lines(int row, int num_lines) | 4367 gui_mch_delete_lines(int row, int num_lines) |
4382 { | 4368 { |
4383 Rect rc; | 4369 Rect rc; |
4384 | 4370 |
4385 /* changed without checking! */ | 4371 // changed without checking! |
4386 rc.left = FILL_X(gui.scroll_region_left); | 4372 rc.left = FILL_X(gui.scroll_region_left); |
4387 rc.right = FILL_X(gui.scroll_region_right + 1); | 4373 rc.right = FILL_X(gui.scroll_region_right + 1); |
4388 rc.top = FILL_Y(row); | 4374 rc.top = FILL_Y(row); |
4389 rc.bottom = FILL_Y(gui.scroll_region_bot + 1); | 4375 rc.bottom = FILL_Y(gui.scroll_region_bot + 1); |
4390 | 4376 |
4412 | 4398 |
4413 gui_mch_set_bg_color(gui.back_pixel); | 4399 gui_mch_set_bg_color(gui.back_pixel); |
4414 | 4400 |
4415 ScrollRect(&rc, 0, gui.char_height * num_lines, (RgnHandle) nil); | 4401 ScrollRect(&rc, 0, gui.char_height * num_lines, (RgnHandle) nil); |
4416 | 4402 |
4417 /* Update gui.cursor_row if the cursor scrolled or copied over */ | 4403 // Update gui.cursor_row if the cursor scrolled or copied over |
4418 if (gui.cursor_row >= gui.row | 4404 if (gui.cursor_row >= gui.row |
4419 && gui.cursor_col >= gui.scroll_region_left | 4405 && gui.cursor_col >= gui.scroll_region_left |
4420 && gui.cursor_col <= gui.scroll_region_right) | 4406 && gui.cursor_col <= gui.scroll_region_right) |
4421 { | 4407 { |
4422 if (gui.cursor_row <= gui.scroll_region_bot - num_lines) | 4408 if (gui.cursor_row <= gui.scroll_region_bot - num_lines) |
4472 return; | 4458 return; |
4473 } | 4459 } |
4474 | 4460 |
4475 ReserveMem(scrapSize); | 4461 ReserveMem(scrapSize); |
4476 | 4462 |
4477 /* In CARBON we don't need a Handle, a pointer is good */ | 4463 // In CARBON we don't need a Handle, a pointer is good |
4478 textOfClip = NewHandle(scrapSize); | 4464 textOfClip = NewHandle(scrapSize); |
4479 | 4465 |
4480 /* tempclip = alloc(scrapSize+1); */ | 4466 // tempclip = alloc(scrapSize+1); |
4481 HLock(textOfClip); | 4467 HLock(textOfClip); |
4482 error = GetScrapFlavorData(scrap, | 4468 error = GetScrapFlavorData(scrap, |
4483 flavor ? VIMSCRAPFLAVOR : SCRAPTEXTFLAVOR, | 4469 flavor ? VIMSCRAPFLAVOR : SCRAPTEXTFLAVOR, |
4484 &scrapSize, *textOfClip); | 4470 &scrapSize, *textOfClip); |
4485 scrapSize -= flavor; | 4471 scrapSize -= flavor; |
4493 mch_memmove(tempclip, *textOfClip + flavor, scrapSize); | 4479 mch_memmove(tempclip, *textOfClip + flavor, scrapSize); |
4494 tempclip[scrapSize] = 0; | 4480 tempclip[scrapSize] = 0; |
4495 | 4481 |
4496 #ifdef MACOS_CONVERT | 4482 #ifdef MACOS_CONVERT |
4497 { | 4483 { |
4498 /* Convert from utf-16 (clipboard) */ | 4484 // Convert from utf-16 (clipboard) |
4499 size_t encLen = 0; | 4485 size_t encLen = 0; |
4500 char_u *to = mac_utf16_to_enc((UniChar *)tempclip, scrapSize, &encLen); | 4486 char_u *to = mac_utf16_to_enc((UniChar *)tempclip, scrapSize, &encLen); |
4501 | 4487 |
4502 if (to != NULL) | 4488 if (to != NULL) |
4503 { | 4489 { |
4599 void | 4585 void |
4600 gui_mch_set_text_area_pos(int x, int y, int w, int h) | 4586 gui_mch_set_text_area_pos(int x, int y, int w, int h) |
4601 { | 4587 { |
4602 Rect VimBound; | 4588 Rect VimBound; |
4603 | 4589 |
4604 /* HideWindow(gui.VimWindow); */ | 4590 // HideWindow(gui.VimWindow); |
4605 GetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &VimBound); | 4591 GetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &VimBound); |
4606 | 4592 |
4607 if (gui.which_scrollbars[SBAR_LEFT]) | 4593 if (gui.which_scrollbars[SBAR_LEFT]) |
4608 VimBound.left = -gui.scrollbar_width + 1; | 4594 VimBound.left = -gui.scrollbar_width + 1; |
4609 else | 4595 else |
4645 * TODO: use menu->mnemonic and menu->actext | 4631 * TODO: use menu->mnemonic and menu->actext |
4646 * TODO: Try to reuse menu id | 4632 * TODO: Try to reuse menu id |
4647 * Carbon Help suggest to use only id between 1 and 235 | 4633 * Carbon Help suggest to use only id between 1 and 235 |
4648 */ | 4634 */ |
4649 static long next_avail_id = 128; | 4635 static long next_avail_id = 128; |
4650 long menu_after_me = 0; /* Default to the end */ | 4636 long menu_after_me = 0; // Default to the end |
4651 CFStringRef name; | 4637 CFStringRef name; |
4652 short index; | 4638 short index; |
4653 vimmenu_T *parent = menu->parent; | 4639 vimmenu_T *parent = menu->parent; |
4654 vimmenu_T *brother = menu->next; | 4640 vimmenu_T *brother = menu->next; |
4655 | 4641 |
4656 /* Cannot add a menu if ... */ | 4642 // Cannot add a menu if ... |
4657 if ((parent != NULL && parent->submenu_id == 0)) | 4643 if ((parent != NULL && parent->submenu_id == 0)) |
4658 return; | 4644 return; |
4659 | 4645 |
4660 /* menu ID greater than 1024 are reserved for ??? */ | 4646 // menu ID greater than 1024 are reserved for ??? |
4661 if (next_avail_id == 1024) | 4647 if (next_avail_id == 1024) |
4662 return; | 4648 return; |
4663 | 4649 |
4664 /* My brother could be the PopUp, find my real brother */ | 4650 // My brother could be the PopUp, find my real brother |
4665 while ((brother != NULL) && (!menu_is_menubar(brother->name))) | 4651 while ((brother != NULL) && (!menu_is_menubar(brother->name))) |
4666 brother = brother->next; | 4652 brother = brother->next; |
4667 | 4653 |
4668 /* Find where to insert the menu (for MenuBar) */ | 4654 // Find where to insert the menu (for MenuBar) |
4669 if ((parent == NULL) && (brother != NULL)) | 4655 if ((parent == NULL) && (brother != NULL)) |
4670 menu_after_me = brother->submenu_id; | 4656 menu_after_me = brother->submenu_id; |
4671 | 4657 |
4672 /* If the menu is not part of the menubar (and its submenus), add it 'nowhere' */ | 4658 // If the menu is not part of the menubar (and its submenus), add it 'nowhere' |
4673 if (!menu_is_menubar(menu->name)) | 4659 if (!menu_is_menubar(menu->name)) |
4674 menu_after_me = hierMenu; | 4660 menu_after_me = hierMenu; |
4675 | 4661 |
4676 /* Convert the name */ | 4662 // Convert the name |
4677 #ifdef MACOS_CONVERT | 4663 #ifdef MACOS_CONVERT |
4678 name = menu_title_removing_mnemonic(menu); | 4664 name = menu_title_removing_mnemonic(menu); |
4679 #else | 4665 #else |
4680 name = C2Pascal_save(menu->dname); | 4666 name = C2Pascal_save(menu->dname); |
4681 #endif | 4667 #endif |
4682 if (name == NULL) | 4668 if (name == NULL) |
4683 return; | 4669 return; |
4684 | 4670 |
4685 /* Create the menu unless it's the help menu */ | 4671 // Create the menu unless it's the help menu |
4686 { | 4672 { |
4687 /* Carbon suggest use of | 4673 // Carbon suggest use of |
4688 * OSStatus CreateNewMenu(MenuID, MenuAttributes, MenuRef *); | 4674 // OSStatus CreateNewMenu(MenuID, MenuAttributes, MenuRef *); |
4689 * OSStatus SetMenuTitle(MenuRef, ConstStr255Param title); | 4675 // OSStatus SetMenuTitle(MenuRef, ConstStr255Param title); |
4690 */ | |
4691 menu->submenu_id = next_avail_id; | 4676 menu->submenu_id = next_avail_id; |
4692 if (CreateNewMenu(menu->submenu_id, 0, (MenuRef *)&menu->submenu_handle) == noErr) | 4677 if (CreateNewMenu(menu->submenu_id, 0, (MenuRef *)&menu->submenu_handle) == noErr) |
4693 SetMenuTitleWithCFString((MenuRef)menu->submenu_handle, name); | 4678 SetMenuTitleWithCFString((MenuRef)menu->submenu_handle, name); |
4694 next_avail_id++; | 4679 next_avail_id++; |
4695 } | 4680 } |
4696 | 4681 |
4697 if (parent == NULL) | 4682 if (parent == NULL) |
4698 { | 4683 { |
4699 /* Adding a menu to the menubar, or in the no mans land (for PopUp) */ | 4684 // Adding a menu to the menubar, or in the no mans land (for PopUp) |
4700 | 4685 |
4701 /* TODO: Verify if we could only Insert Menu if really part of the | 4686 // TODO: Verify if we could only Insert Menu if really part of the |
4702 * menubar The Inserted menu are scanned or the Command-key combos | 4687 // menubar The Inserted menu are scanned or the Command-key combos |
4703 */ | 4688 |
4704 | 4689 // Insert the menu |
4705 /* Insert the menu */ | 4690 InsertMenu(menu->submenu_handle, menu_after_me); // insert before |
4706 InsertMenu(menu->submenu_handle, menu_after_me); /* insert before */ | |
4707 #if 1 | 4691 #if 1 |
4708 /* Vim should normally update it. TODO: verify */ | 4692 // Vim should normally update it. TODO: verify |
4709 DrawMenuBar(); | 4693 DrawMenuBar(); |
4710 #endif | 4694 #endif |
4711 } | 4695 } |
4712 else | 4696 else |
4713 { | 4697 { |
4714 /* Adding as a submenu */ | 4698 // Adding as a submenu |
4715 | 4699 |
4716 index = gui_mac_get_menu_item_index(menu); | 4700 index = gui_mac_get_menu_item_index(menu); |
4717 | 4701 |
4718 /* Call InsertMenuItem followed by SetMenuItemText | 4702 // Call InsertMenuItem followed by SetMenuItemText |
4719 * to avoid special character recognition by InsertMenuItem | 4703 // to avoid special character recognition by InsertMenuItem |
4720 */ | 4704 InsertMenuItem(parent->submenu_handle, "\p ", idx); // afterItem |
4721 InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */ | |
4722 SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name); | 4705 SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name); |
4723 SetItemCmd(parent->submenu_handle, idx+1, 0x1B); | 4706 SetItemCmd(parent->submenu_handle, idx+1, 0x1B); |
4724 SetItemMark(parent->submenu_handle, idx+1, menu->submenu_id); | 4707 SetItemMark(parent->submenu_handle, idx+1, menu->submenu_id); |
4725 InsertMenu(menu->submenu_handle, hierMenu); | 4708 InsertMenu(menu->submenu_handle, hierMenu); |
4726 } | 4709 } |
4727 | 4710 |
4728 CFRelease(name); | 4711 CFRelease(name); |
4729 | 4712 |
4730 #if 0 | 4713 #if 0 |
4731 /* Done by Vim later on */ | 4714 // Done by Vim later on |
4732 DrawMenuBar(); | 4715 DrawMenuBar(); |
4733 #endif | 4716 #endif |
4734 } | 4717 } |
4735 | 4718 |
4736 /* | 4719 /* |
4741 { | 4724 { |
4742 CFStringRef name; | 4725 CFStringRef name; |
4743 vimmenu_T *parent = menu->parent; | 4726 vimmenu_T *parent = menu->parent; |
4744 int menu_inserted; | 4727 int menu_inserted; |
4745 | 4728 |
4746 /* Cannot add item, if the menu have not been created */ | 4729 // Cannot add item, if the menu have not been created |
4747 if (parent->submenu_id == 0) | 4730 if (parent->submenu_id == 0) |
4748 return; | 4731 return; |
4749 | 4732 |
4750 /* Could call SetMenuRefCon [CARBON] to associate with the Menu, | 4733 // Could call SetMenuRefCon [CARBON] to associate with the Menu, |
4751 for older OS call GetMenuItemData (menu, item, isCommandID?, data) */ | 4734 // for older OS call GetMenuItemData (menu, item, isCommandID?, data) |
4752 | 4735 |
4753 /* Convert the name */ | 4736 // Convert the name |
4754 #ifdef MACOS_CONVERT | 4737 #ifdef MACOS_CONVERT |
4755 name = menu_title_removing_mnemonic(menu); | 4738 name = menu_title_removing_mnemonic(menu); |
4756 #else | 4739 #else |
4757 name = C2Pascal_save(menu->dname); | 4740 name = C2Pascal_save(menu->dname); |
4758 #endif | 4741 #endif |
4759 | 4742 |
4760 /* Where are just a menu item, so no handle, no id */ | 4743 // Where are just a menu item, so no handle, no id |
4761 menu->submenu_id = 0; | 4744 menu->submenu_id = 0; |
4762 menu->submenu_handle = NULL; | 4745 menu->submenu_handle = NULL; |
4763 | 4746 |
4764 menu_inserted = 0; | 4747 menu_inserted = 0; |
4765 if (menu->actext) | 4748 if (menu->actext) |
4766 { | 4749 { |
4767 /* If the accelerator text for the menu item looks like it describes | 4750 // If the accelerator text for the menu item looks like it describes |
4768 * a command key (e.g., "<D-S-t>" or "<C-7>"), display it as the | 4751 // a command key (e.g., "<D-S-t>" or "<C-7>"), display it as the |
4769 * item's command equivalent. | 4752 // item's command equivalent. |
4770 */ | |
4771 int key = 0; | 4753 int key = 0; |
4772 int modifiers = 0; | 4754 int modifiers = 0; |
4773 char_u *p_actext; | 4755 char_u *p_actext; |
4774 | 4756 |
4775 p_actext = menu->actext; | 4757 p_actext = menu->actext; |
4776 key = find_special_key(&p_actext, &modifiers, FALSE, FALSE, FALSE, | 4758 key = find_special_key(&p_actext, &modifiers, FALSE, FALSE, FALSE, |
4777 TRUE, NULL); | 4759 TRUE, NULL); |
4778 if (*p_actext != 0) | 4760 if (*p_actext != 0) |
4779 key = 0; /* error: trailing text */ | 4761 key = 0; // error: trailing text |
4780 /* find_special_key() returns a keycode with as many of the | 4762 // find_special_key() returns a keycode with as many of the |
4781 * specified modifiers as appropriate already applied (e.g., for | 4763 // specified modifiers as appropriate already applied (e.g., for |
4782 * "<D-C-x>" it returns Ctrl-X as the keycode and MOD_MASK_CMD | 4764 // "<D-C-x>" it returns Ctrl-X as the keycode and MOD_MASK_CMD |
4783 * as the only modifier). Since we want to display all of the | 4765 // as the only modifier). Since we want to display all of the |
4784 * modifiers, we need to convert the keycode back to a printable | 4766 // modifiers, we need to convert the keycode back to a printable |
4785 * character plus modifiers. | 4767 // character plus modifiers. |
4786 * TODO: Write an alternative find_special_key() that doesn't | 4768 // TODO: Write an alternative find_special_key() that doesn't |
4787 * apply modifiers. | 4769 // apply modifiers. |
4788 */ | |
4789 if (key > 0 && key < 32) | 4770 if (key > 0 && key < 32) |
4790 { | 4771 { |
4791 /* Convert a control key to an uppercase letter. Note that | 4772 // Convert a control key to an uppercase letter. Note that |
4792 * by this point it is no longer possible to distinguish | 4773 // by this point it is no longer possible to distinguish |
4793 * between, e.g., Ctrl-S and Ctrl-Shift-S. | 4774 // between, e.g., Ctrl-S and Ctrl-Shift-S. |
4794 */ | |
4795 modifiers |= MOD_MASK_CTRL; | 4775 modifiers |= MOD_MASK_CTRL; |
4796 key += '@'; | 4776 key += '@'; |
4797 } | 4777 } |
4798 /* If the keycode is an uppercase letter, set the Shift modifier. | 4778 // If the keycode is an uppercase letter, set the Shift modifier. |
4799 * If it is a lowercase letter, don't set the modifier, but convert | 4779 // If it is a lowercase letter, don't set the modifier, but convert |
4800 * the letter to uppercase for display in the menu. | 4780 // the letter to uppercase for display in the menu. |
4801 */ | |
4802 else if (key >= 'A' && key <= 'Z') | 4781 else if (key >= 'A' && key <= 'Z') |
4803 modifiers |= MOD_MASK_SHIFT; | 4782 modifiers |= MOD_MASK_SHIFT; |
4804 else if (key >= 'a' && key <= 'z') | 4783 else if (key >= 'a' && key <= 'z') |
4805 key += 'A' - 'a'; | 4784 key += 'A' - 'a'; |
4806 /* Note: keycodes below 0x22 are reserved by Apple. */ | 4785 // Note: keycodes below 0x22 are reserved by Apple. |
4807 if (key >= 0x22 && vim_isprintc_strict(key)) | 4786 if (key >= 0x22 && vim_isprintc_strict(key)) |
4808 { | 4787 { |
4809 int valid = 1; | 4788 int valid = 1; |
4810 char_u mac_mods = kMenuNoModifiers; | 4789 char_u mac_mods = kMenuNoModifiers; |
4811 /* Convert Vim modifier codes to Menu Manager equivalents. */ | 4790 // Convert Vim modifier codes to Menu Manager equivalents. |
4812 if (modifiers & MOD_MASK_SHIFT) | 4791 if (modifiers & MOD_MASK_SHIFT) |
4813 mac_mods |= kMenuShiftModifier; | 4792 mac_mods |= kMenuShiftModifier; |
4814 if (modifiers & MOD_MASK_CTRL) | 4793 if (modifiers & MOD_MASK_CTRL) |
4815 mac_mods |= kMenuControlModifier; | 4794 mac_mods |= kMenuControlModifier; |
4816 if (!(modifiers & MOD_MASK_CMD)) | 4795 if (!(modifiers & MOD_MASK_CMD)) |
4817 mac_mods |= kMenuNoCommandModifier; | 4796 mac_mods |= kMenuNoCommandModifier; |
4818 if (modifiers & MOD_MASK_ALT || modifiers & MOD_MASK_MULTI_CLICK) | 4797 if (modifiers & MOD_MASK_ALT || modifiers & MOD_MASK_MULTI_CLICK) |
4819 valid = 0; /* TODO: will Alt someday map to Option? */ | 4798 valid = 0; // TODO: will Alt someday map to Option? |
4820 if (valid) | 4799 if (valid) |
4821 { | 4800 { |
4822 char_u item_txt[10]; | 4801 char_u item_txt[10]; |
4823 /* Insert the menu item after idx, with its command key. */ | 4802 // Insert the menu item after idx, with its command key. |
4824 item_txt[0] = 3; item_txt[1] = ' '; item_txt[2] = '/'; | 4803 item_txt[0] = 3; item_txt[1] = ' '; item_txt[2] = '/'; |
4825 item_txt[3] = key; | 4804 item_txt[3] = key; |
4826 InsertMenuItem(parent->submenu_handle, item_txt, idx); | 4805 InsertMenuItem(parent->submenu_handle, item_txt, idx); |
4827 /* Set the modifier keys. */ | 4806 // Set the modifier keys. |
4828 SetMenuItemModifiers(parent->submenu_handle, idx+1, mac_mods); | 4807 SetMenuItemModifiers(parent->submenu_handle, idx+1, mac_mods); |
4829 menu_inserted = 1; | 4808 menu_inserted = 1; |
4830 } | 4809 } |
4831 } | 4810 } |
4832 } | 4811 } |
4833 /* Call InsertMenuItem followed by SetMenuItemText | 4812 // Call InsertMenuItem followed by SetMenuItemText |
4834 * to avoid special character recognition by InsertMenuItem | 4813 // to avoid special character recognition by InsertMenuItem |
4835 */ | |
4836 if (!menu_inserted) | 4814 if (!menu_inserted) |
4837 InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */ | 4815 InsertMenuItem(parent->submenu_handle, "\p ", idx); // afterItem |
4838 /* Set the menu item name. */ | 4816 // Set the menu item name. |
4839 SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name); | 4817 SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name); |
4840 | 4818 |
4841 #if 0 | 4819 #if 0 |
4842 /* Called by Vim */ | 4820 // Called by Vim |
4843 DrawMenuBar(); | 4821 DrawMenuBar(); |
4844 #endif | 4822 #endif |
4845 | 4823 |
4846 CFRelease(name); | 4824 CFRelease(name); |
4847 } | 4825 } |
4848 | 4826 |
4849 void | 4827 void |
4850 gui_mch_toggle_tearoffs(int enable) | 4828 gui_mch_toggle_tearoffs(int enable) |
4851 { | 4829 { |
4852 /* no tearoff menus */ | 4830 // no tearoff menus |
4853 } | 4831 } |
4854 | 4832 |
4855 /* | 4833 /* |
4856 * Destroy the machine specific menu widget. | 4834 * Destroy the machine specific menu widget. |
4857 */ | 4835 */ |
4863 if (index > 0) | 4841 if (index > 0) |
4864 { | 4842 { |
4865 if (menu->parent) | 4843 if (menu->parent) |
4866 { | 4844 { |
4867 { | 4845 { |
4868 /* For now just don't delete help menu items. (Huh? Dany) */ | 4846 // For now just don't delete help menu items. (Huh? Dany) |
4869 DeleteMenuItem(menu->parent->submenu_handle, index); | 4847 DeleteMenuItem(menu->parent->submenu_handle, index); |
4870 | 4848 |
4871 /* Delete the Menu if it was a hierarchical Menu */ | 4849 // Delete the Menu if it was a hierarchical Menu |
4872 if (menu->submenu_id != 0) | 4850 if (menu->submenu_id != 0) |
4873 { | 4851 { |
4874 DeleteMenu(menu->submenu_id); | 4852 DeleteMenu(menu->submenu_id); |
4875 DisposeMenu(menu->submenu_handle); | 4853 DisposeMenu(menu->submenu_handle); |
4876 } | 4854 } |
4888 { | 4866 { |
4889 DeleteMenu(menu->submenu_id); | 4867 DeleteMenu(menu->submenu_id); |
4890 DisposeMenu(menu->submenu_handle); | 4868 DisposeMenu(menu->submenu_handle); |
4891 } | 4869 } |
4892 } | 4870 } |
4893 /* Shouldn't this be already done by Vim. TODO: Check */ | 4871 // Shouldn't this be already done by Vim. TODO: Check |
4894 DrawMenuBar(); | 4872 DrawMenuBar(); |
4895 } | 4873 } |
4896 | 4874 |
4897 /* | 4875 /* |
4898 * Make a menu either grey or not grey. | 4876 * Make a menu either grey or not grey. |
4899 */ | 4877 */ |
4900 void | 4878 void |
4901 gui_mch_menu_grey(vimmenu_T *menu, int grey) | 4879 gui_mch_menu_grey(vimmenu_T *menu, int grey) |
4902 { | 4880 { |
4903 /* TODO: Check if menu really exists */ | 4881 // TODO: Check if menu really exists |
4904 short index = gui_mac_get_menu_item_index(menu); | 4882 short index = gui_mac_get_menu_item_index(menu); |
4905 /* | 4883 /* |
4906 index = menu->index; | 4884 index = menu->index; |
4907 */ | 4885 */ |
4908 if (grey) | 4886 if (grey) |
4927 * Make menu item hidden or not hidden | 4905 * Make menu item hidden or not hidden |
4928 */ | 4906 */ |
4929 void | 4907 void |
4930 gui_mch_menu_hidden(vimmenu_T *menu, int hidden) | 4908 gui_mch_menu_hidden(vimmenu_T *menu, int hidden) |
4931 { | 4909 { |
4932 /* There's no hidden mode on MacOS */ | 4910 // There's no hidden mode on MacOS |
4933 gui_mch_menu_grey(menu, hidden); | 4911 gui_mch_menu_grey(menu, hidden); |
4934 } | 4912 } |
4935 | 4913 |
4936 | 4914 |
4937 /* | 4915 /* |
4986 int y, | 4964 int y, |
4987 int w, | 4965 int w, |
4988 int h) | 4966 int h) |
4989 { | 4967 { |
4990 gui_mch_set_bg_color(gui.back_pixel); | 4968 gui_mch_set_bg_color(gui.back_pixel); |
4991 /* if (gui.which_scrollbars[SBAR_LEFT]) | 4969 #if 0 |
4970 if (gui.which_scrollbars[SBAR_LEFT]) | |
4992 { | 4971 { |
4993 MoveControl(sb->id, x-16, y); | 4972 MoveControl(sb->id, x-16, y); |
4994 SizeControl(sb->id, w + 1, h); | 4973 SizeControl(sb->id, w + 1, h); |
4995 } | 4974 } |
4996 else | 4975 else |
4997 { | 4976 { |
4998 MoveControl(sb->id, x, y); | 4977 MoveControl(sb->id, x, y); |
4999 SizeControl(sb->id, w + 1, h); | 4978 SizeControl(sb->id, w + 1, h); |
5000 }*/ | 4979 } |
4980 #endif | |
5001 if (sb == &gui.bottom_sbar) | 4981 if (sb == &gui.bottom_sbar) |
5002 h += 1; | 4982 h += 1; |
5003 else | 4983 else |
5004 w += 1; | 4984 w += 1; |
5005 | 4985 |
5014 } | 4994 } |
5015 | 4995 |
5016 void | 4996 void |
5017 gui_mch_create_scrollbar( | 4997 gui_mch_create_scrollbar( |
5018 scrollbar_T *sb, | 4998 scrollbar_T *sb, |
5019 int orient) /* SBAR_VERT or SBAR_HORIZ */ | 4999 int orient) // SBAR_VERT or SBAR_HORIZ |
5020 { | 5000 { |
5021 Rect bounds; | 5001 Rect bounds; |
5022 | 5002 |
5023 bounds.top = -16; | 5003 bounds.top = -16; |
5024 bounds.bottom = -10; | 5004 bounds.bottom = -10; |
5027 | 5007 |
5028 sb->id = NewControl(gui.VimWindow, | 5008 sb->id = NewControl(gui.VimWindow, |
5029 &bounds, | 5009 &bounds, |
5030 "\pScrollBar", | 5010 "\pScrollBar", |
5031 TRUE, | 5011 TRUE, |
5032 0, /* current*/ | 5012 0, // current |
5033 0, /* top */ | 5013 0, // top |
5034 0, /* bottom */ | 5014 0, // bottom |
5035 kControlScrollBarLiveProc, | 5015 kControlScrollBarLiveProc, |
5036 (long) sb->ident); | 5016 (long) sb->ident); |
5037 #ifdef DEBUG_MAC_SB | 5017 #ifdef DEBUG_MAC_SB |
5038 printf("create_sb (%x) %x\n",sb->id, orient); | 5018 printf("create_sb (%x) %x\n",sb->id, orient); |
5039 #endif | 5019 #endif |
5070 * BLINK_ON blinking, cursor is shown | 5050 * BLINK_ON blinking, cursor is shown |
5071 */ | 5051 */ |
5072 void | 5052 void |
5073 gui_mch_set_blinking(long wait, long on, long off) | 5053 gui_mch_set_blinking(long wait, long on, long off) |
5074 { | 5054 { |
5075 /* TODO: TODO: TODO: TODO: */ | 5055 #if 0 |
5076 /* blink_waittime = wait; | 5056 // TODO: TODO: TODO: TODO: |
5057 blink_waittime = wait; | |
5077 blink_ontime = on; | 5058 blink_ontime = on; |
5078 blink_offtime = off;*/ | 5059 blink_offtime = off; |
5060 #endif | |
5079 } | 5061 } |
5080 | 5062 |
5081 /* | 5063 /* |
5082 * Stop the cursor blinking. Show the cursor if it wasn't shown. | 5064 * Stop the cursor blinking. Show the cursor if it wasn't shown. |
5083 */ | 5065 */ |
5084 void | 5066 void |
5085 gui_mch_stop_blink(int may_call_gui_update_cursor) | 5067 gui_mch_stop_blink(int may_call_gui_update_cursor) |
5086 { | 5068 { |
5087 if (may_call_gui_update_cursor) | 5069 if (may_call_gui_update_cursor) |
5088 gui_update_cursor(TRUE, FALSE); | 5070 gui_update_cursor(TRUE, FALSE); |
5089 /* TODO: TODO: TODO: TODO: */ | 5071 #if 0 |
5090 /* gui_w32_rm_blink_timer(); | 5072 // TODO: TODO: TODO: TODO: |
5073 gui_w32_rm_blink_timer(); | |
5091 if (blink_state == BLINK_OFF) | 5074 if (blink_state == BLINK_OFF) |
5092 gui_update_cursor(TRUE, FALSE); | 5075 gui_update_cursor(TRUE, FALSE); |
5093 blink_state = BLINK_NONE;*/ | 5076 blink_state = BLINK_NONE; |
5077 #endif | |
5094 } | 5078 } |
5095 | 5079 |
5096 /* | 5080 /* |
5097 * Start the cursor blinking. If it was already blinking, this restarts the | 5081 * Start the cursor blinking. If it was already blinking, this restarts the |
5098 * waiting time and shows the cursor. | 5082 * waiting time and shows the cursor. |
5099 */ | 5083 */ |
5100 void | 5084 void |
5101 gui_mch_start_blink(void) | 5085 gui_mch_start_blink(void) |
5102 { | 5086 { |
5103 gui_update_cursor(TRUE, FALSE); | 5087 gui_update_cursor(TRUE, FALSE); |
5104 /* TODO: TODO: TODO: TODO: */ | 5088 // TODO: TODO: TODO: TODO: |
5105 /* gui_w32_rm_blink_timer(); */ | 5089 // gui_w32_rm_blink_timer(); |
5106 | 5090 |
5107 /* Only switch blinking on if none of the times is zero */ | 5091 // Only switch blinking on if none of the times is zero |
5108 /* if (blink_waittime && blink_ontime && blink_offtime) | 5092 #if 0 |
5093 if (blink_waittime && blink_ontime && blink_offtime) | |
5109 { | 5094 { |
5110 blink_timer = SetTimer(NULL, 0, (UINT)blink_waittime, | 5095 blink_timer = SetTimer(NULL, 0, (UINT)blink_waittime, |
5111 (TIMERPROC)_OnBlinkTimer); | 5096 (TIMERPROC)_OnBlinkTimer); |
5112 blink_state = BLINK_ON; | 5097 blink_state = BLINK_ON; |
5113 gui_update_cursor(TRUE, FALSE); | 5098 gui_update_cursor(TRUE, FALSE); |
5114 }*/ | 5099 } |
5100 #endif | |
5115 } | 5101 } |
5116 | 5102 |
5117 /* | 5103 /* |
5118 * Return the RGB value of a pixel as long. | 5104 * Return the RGB value of a pixel as long. |
5119 */ | 5105 */ |
5151 char_u *dflt, | 5137 char_u *dflt, |
5152 char_u *ext, | 5138 char_u *ext, |
5153 char_u *initdir, | 5139 char_u *initdir, |
5154 char_u *filter) | 5140 char_u *filter) |
5155 { | 5141 { |
5156 /* TODO: Add Ammon's safety check (Dany) */ | 5142 // TODO: Add Ammon's safety check (Dany) |
5157 NavReplyRecord reply; | 5143 NavReplyRecord reply; |
5158 char_u *fname = NULL; | 5144 char_u *fname = NULL; |
5159 char_u **fnames = NULL; | 5145 char_u **fnames = NULL; |
5160 long numFiles; | 5146 long numFiles; |
5161 NavDialogOptions navOptions; | 5147 NavDialogOptions navOptions; |
5162 OSErr error; | 5148 OSErr error; |
5163 | 5149 |
5164 /* Get Navigation Service Defaults value */ | 5150 // Get Navigation Service Defaults value |
5165 NavGetDefaultDialogOptions(&navOptions); | 5151 NavGetDefaultDialogOptions(&navOptions); |
5166 | 5152 |
5167 | 5153 |
5168 /* TODO: If we get a :browse args, set the Multiple bit. */ | 5154 // TODO: If we get a :browse args, set the Multiple bit. |
5169 navOptions.dialogOptionFlags = kNavAllowInvisibleFiles | 5155 navOptions.dialogOptionFlags = kNavAllowInvisibleFiles |
5170 | kNavDontAutoTranslate | 5156 | kNavDontAutoTranslate |
5171 | kNavDontAddTranslateItems | 5157 | kNavDontAddTranslateItems |
5172 /* | kNavAllowMultipleFiles */ | 5158 // | kNavAllowMultipleFiles |
5173 | kNavAllowStationery; | 5159 | kNavAllowStationery; |
5174 | 5160 |
5175 (void) C2PascalString(title, &navOptions.message); | 5161 (void) C2PascalString(title, &navOptions.message); |
5176 (void) C2PascalString(dflt, &navOptions.savedFileName); | 5162 (void) C2PascalString(dflt, &navOptions.savedFileName); |
5177 /* Could set clientName? | 5163 // Could set clientName? |
5178 * windowTitle? (there's no title bar?) | 5164 // windowTitle? (there's no title bar?) |
5179 */ | |
5180 | 5165 |
5181 if (saving) | 5166 if (saving) |
5182 { | 5167 { |
5183 /* Change first parm AEDesc (typeFSS) *defaultLocation to match dflt */ | 5168 // Change first parm AEDesc (typeFSS) *defaultLocation to match dflt |
5184 NavPutFile(NULL, &reply, &navOptions, NULL, 'TEXT', 'VIM!', NULL); | 5169 NavPutFile(NULL, &reply, &navOptions, NULL, 'TEXT', 'VIM!', NULL); |
5185 if (!reply.validRecord) | 5170 if (!reply.validRecord) |
5186 return NULL; | 5171 return NULL; |
5187 } | 5172 } |
5188 else | 5173 else |
5189 { | 5174 { |
5190 /* Change first parm AEDesc (typeFSS) *defaultLocation to match dflt */ | 5175 // Change first parm AEDesc (typeFSS) *defaultLocation to match dflt |
5191 NavGetFile(NULL, &reply, &navOptions, NULL, NULL, NULL, NULL, NULL); | 5176 NavGetFile(NULL, &reply, &navOptions, NULL, NULL, NULL, NULL, NULL); |
5192 if (!reply.validRecord) | 5177 if (!reply.validRecord) |
5193 return NULL; | 5178 return NULL; |
5194 } | 5179 } |
5195 | 5180 |
5201 { | 5186 { |
5202 fname = fnames[0]; | 5187 fname = fnames[0]; |
5203 vim_free(fnames); | 5188 vim_free(fnames); |
5204 } | 5189 } |
5205 | 5190 |
5206 /* TODO: Shorten the file name if possible */ | 5191 // TODO: Shorten the file name if possible |
5207 return fname; | 5192 return fname; |
5208 } | 5193 } |
5209 #endif /* FEAT_BROWSE */ | 5194 #endif // FEAT_BROWSE |
5210 | 5195 |
5211 #ifdef FEAT_GUI_DIALOG | 5196 #ifdef FEAT_GUI_DIALOG |
5212 /* | 5197 /* |
5213 * Stuff for dialogues | 5198 * Stuff for dialogues |
5214 */ | 5199 */ |
5231 */ | 5216 */ |
5232 | 5217 |
5233 typedef struct | 5218 typedef struct |
5234 { | 5219 { |
5235 short idx; | 5220 short idx; |
5236 short width; /* Size of the text in pixel */ | 5221 short width; // Size of the text in pixel |
5237 Rect box; | 5222 Rect box; |
5238 } vgmDlgItm; /* Vim Gui_Mac.c Dialog Item */ | 5223 } vgmDlgItm; // Vim Gui_Mac.c Dialog Item |
5239 | 5224 |
5240 #define MoveRectTo(r,x,y) OffsetRect(r,x-r->left,y-r->top) | 5225 #define MoveRectTo(r,x,y) OffsetRect(r,x-r->left,y-r->top) |
5241 | 5226 |
5242 static void | 5227 static void |
5243 macMoveDialogItem( | 5228 macMoveDialogItem( |
5245 short itemNumber, | 5230 short itemNumber, |
5246 short X, | 5231 short X, |
5247 short Y, | 5232 short Y, |
5248 Rect *inBox) | 5233 Rect *inBox) |
5249 { | 5234 { |
5250 #if 0 /* USE_CARBONIZED */ | 5235 #if 0 // USE_CARBONIZED |
5251 /* Untested */ | 5236 // Untested |
5252 MoveDialogItem(theDialog, itemNumber, X, Y); | 5237 MoveDialogItem(theDialog, itemNumber, X, Y); |
5253 if (inBox != nil) | 5238 if (inBox != nil) |
5254 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, inBox); | 5239 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, inBox); |
5255 #else | 5240 #else |
5256 short itemType; | 5241 short itemType; |
5262 itemBox = inBox; | 5247 itemBox = inBox; |
5263 | 5248 |
5264 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, itemBox); | 5249 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, itemBox); |
5265 OffsetRect(itemBox, -itemBox->left, -itemBox->top); | 5250 OffsetRect(itemBox, -itemBox->left, -itemBox->top); |
5266 OffsetRect(itemBox, X, Y); | 5251 OffsetRect(itemBox, X, Y); |
5267 /* To move a control (like a button) we need to call both | 5252 // To move a control (like a button) we need to call both |
5268 * MoveControl and SetDialogItem. FAQ 6-18 */ | 5253 // MoveControl and SetDialogItem. FAQ 6-18 |
5269 if (1) /*(itemType & kControlDialogItem) */ | 5254 if (1) //(itemType & kControlDialogItem) |
5270 MoveControl((ControlRef) itemHandle, X, Y); | 5255 MoveControl((ControlRef) itemHandle, X, Y); |
5271 SetDialogItem(theDialog, itemNumber, itemType, itemHandle, itemBox); | 5256 SetDialogItem(theDialog, itemNumber, itemType, itemHandle, itemBox); |
5272 #endif | 5257 #endif |
5273 } | 5258 } |
5274 | 5259 |
5283 Handle itemHandle; | 5268 Handle itemHandle; |
5284 Rect itemBox; | 5269 Rect itemBox; |
5285 | 5270 |
5286 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, &itemBox); | 5271 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, &itemBox); |
5287 | 5272 |
5288 /* When width or height is zero do not change it */ | 5273 // When width or height is zero do not change it |
5289 if (width == 0) | 5274 if (width == 0) |
5290 width = itemBox.right - itemBox.left; | 5275 width = itemBox.right - itemBox.left; |
5291 if (height == 0) | 5276 if (height == 0) |
5292 height = itemBox.bottom - itemBox.top; | 5277 height = itemBox.bottom - itemBox.top; |
5293 | 5278 |
5294 #if 0 /* USE_CARBONIZED */ | 5279 #if 0 // USE_CARBONIZED |
5295 SizeDialogItem(theDialog, itemNumber, width, height); /* Untested */ | 5280 SizeDialogItem(theDialog, itemNumber, width, height); // Untested |
5296 #else | 5281 #else |
5297 /* Resize the bounding box */ | 5282 // Resize the bounding box |
5298 itemBox.right = itemBox.left + width; | 5283 itemBox.right = itemBox.left + width; |
5299 itemBox.bottom = itemBox.top + height; | 5284 itemBox.bottom = itemBox.top + height; |
5300 | 5285 |
5301 /* To resize a control (like a button) we need to call both | 5286 // To resize a control (like a button) we need to call both |
5302 * SizeControl and SetDialogItem. (deducted from FAQ 6-18) */ | 5287 // SizeControl and SetDialogItem. (deducted from FAQ 6-18) |
5303 if (itemType & kControlDialogItem) | 5288 if (itemType & kControlDialogItem) |
5304 SizeControl((ControlRef) itemHandle, width, height); | 5289 SizeControl((ControlRef) itemHandle, width, height); |
5305 | 5290 |
5306 /* Configure back the item */ | 5291 // Configure back the item |
5307 SetDialogItem(theDialog, itemNumber, itemType, itemHandle, &itemBox); | 5292 SetDialogItem(theDialog, itemNumber, itemType, itemHandle, &itemBox); |
5308 #endif | 5293 #endif |
5309 } | 5294 } |
5310 | 5295 |
5311 static void | 5296 static void |
5325 else | 5310 else |
5326 SetDialogItemText(itemHandle, itemName); | 5311 SetDialogItemText(itemHandle, itemName); |
5327 } | 5312 } |
5328 | 5313 |
5329 | 5314 |
5330 /* ModalDialog() handler for message dialogs that have hotkey accelerators. | 5315 /* |
5316 * ModalDialog() handler for message dialogs that have hotkey accelerators. | |
5331 * Expects a mapping of hotkey char to control index in gDialogHotKeys; | 5317 * Expects a mapping of hotkey char to control index in gDialogHotKeys; |
5332 * setting gDialogHotKeys to NULL disables any hotkey handling. | 5318 * setting gDialogHotKeys to NULL disables any hotkey handling. |
5333 */ | 5319 */ |
5334 static pascal Boolean | 5320 static pascal Boolean |
5335 DialogHotkeyFilterProc ( | 5321 DialogHotkeyFilterProc ( |
5348 #ifdef DEBUG_MAC_DIALOG_HOTKEYS | 5334 #ifdef DEBUG_MAC_DIALOG_HOTKEYS |
5349 printf("user pressed hotkey '%c' --> item %d\n", keyHit, gDialogHotKeys[keyHit]); | 5335 printf("user pressed hotkey '%c' --> item %d\n", keyHit, gDialogHotKeys[keyHit]); |
5350 #endif | 5336 #endif |
5351 *itemHit = gDialogHotKeys[keyHit]; | 5337 *itemHit = gDialogHotKeys[keyHit]; |
5352 | 5338 |
5353 /* When handing off to StdFilterProc, pretend that the user | 5339 // When handing off to StdFilterProc, pretend that the user |
5354 * clicked the control manually. Note that this is also supposed | 5340 // clicked the control manually. Note that this is also supposed |
5355 * to cause the button to hilite briefly (to give some user | 5341 // to cause the button to hilite briefly (to give some user |
5356 * feedback), but this seems not to actually work (or it's too | 5342 // feedback), but this seems not to actually work (or it's too |
5357 * fast to be seen). | 5343 // fast to be seen). |
5358 */ | |
5359 event->what = kEventControlSimulateHit; | 5344 event->what = kEventControlSimulateHit; |
5360 | 5345 |
5361 return true; /* we took care of it */ | 5346 return true; // we took care of it |
5362 } | 5347 } |
5363 | 5348 |
5364 /* Defer to the OS's standard behavior for this event. | 5349 // Defer to the OS's standard behavior for this event. |
5365 * This ensures that Enter will still activate the default button. */ | 5350 // This ensures that Enter will still activate the default button. |
5366 return StdFilterProc(theDialog, event, itemHit); | 5351 return StdFilterProc(theDialog, event, itemHit); |
5367 } | 5352 } |
5368 return false; /* Let ModalDialog deal with it */ | 5353 return false; // Let ModalDialog deal with it |
5369 } | 5354 } |
5370 | 5355 |
5371 | 5356 |
5372 /* TODO: There have been some crashes with dialogs, check your inbox | 5357 /* |
5358 * TODO: There have been some crashes with dialogs, check your inbox | |
5373 * (Jussi) | 5359 * (Jussi) |
5374 */ | 5360 */ |
5375 int | 5361 int |
5376 gui_mch_dialog( | 5362 gui_mch_dialog( |
5377 int type, | 5363 int type, |
5388 Handle messageDITL; | 5374 Handle messageDITL; |
5389 Handle itemHandle; | 5375 Handle itemHandle; |
5390 Handle iconHandle; | 5376 Handle iconHandle; |
5391 DialogPtr theDialog; | 5377 DialogPtr theDialog; |
5392 char_u len; | 5378 char_u len; |
5393 char_u PascalTitle[256]; /* place holder for the title */ | 5379 char_u PascalTitle[256]; // place holder for the title |
5394 char_u name[256]; | 5380 char_u name[256]; |
5395 GrafPtr oldPort; | 5381 GrafPtr oldPort; |
5396 short itemHit; | 5382 short itemHit; |
5397 char_u *buttonChar; | 5383 char_u *buttonChar; |
5398 short hotKeys[256]; /* map of hotkey -> control ID */ | 5384 short hotKeys[256]; // map of hotkey -> control ID |
5399 char_u aHotKey; | 5385 char_u aHotKey; |
5400 Rect box; | 5386 Rect box; |
5401 short button; | 5387 short button; |
5402 short lastButton; | 5388 short lastButton; |
5403 short itemType; | 5389 short itemType; |
5404 short useIcon; | 5390 short useIcon; |
5405 short width; | 5391 short width; |
5406 short totalButtonWidth = 0; /* the width of all buttons together | 5392 short totalButtonWidth = 0; // the width of all buttons together |
5407 including spacing */ | 5393 // including spacing |
5408 short widestButton = 0; | 5394 short widestButton = 0; |
5409 short dfltButtonEdge = 20; /* gut feeling */ | 5395 short dfltButtonEdge = 20; // gut feeling |
5410 short dfltElementSpacing = 13; /* from IM:V.2-29 */ | 5396 short dfltElementSpacing = 13; // from IM:V.2-29 |
5411 short dfltIconSideSpace = 23; /* from IM:V.2-29 */ | 5397 short dfltIconSideSpace = 23; // from IM:V.2-29 |
5412 short maximumWidth = 400; /* gut feeling */ | 5398 short maximumWidth = 400; // gut feeling |
5413 short maxButtonWidth = 175; /* gut feeling */ | 5399 short maxButtonWidth = 175; // gut feeling |
5414 | 5400 |
5415 short vertical; | 5401 short vertical; |
5416 short dialogHeight; | 5402 short dialogHeight; |
5417 short messageLines = 3; | 5403 short messageLines = 3; |
5418 FontInfo textFontInfo; | 5404 FontInfo textFontInfo; |
5424 | 5410 |
5425 WindowRef theWindow; | 5411 WindowRef theWindow; |
5426 | 5412 |
5427 ModalFilterUPP dialogUPP; | 5413 ModalFilterUPP dialogUPP; |
5428 | 5414 |
5429 /* Check 'v' flag in 'guioptions': vertical button placement. */ | 5415 // Check 'v' flag in 'guioptions': vertical button placement. |
5430 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL); | 5416 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL); |
5431 | 5417 |
5432 /* Create a new Dialog Box from template. */ | 5418 // Create a new Dialog Box from template. |
5433 theDialog = GetNewDialog(129, nil, (WindowRef) -1); | 5419 theDialog = GetNewDialog(129, nil, (WindowRef) -1); |
5434 | 5420 |
5435 /* Get the WindowRef */ | 5421 // Get the WindowRef |
5436 theWindow = GetDialogWindow(theDialog); | 5422 theWindow = GetDialogWindow(theDialog); |
5437 | 5423 |
5438 /* Hide the window. | 5424 // Hide the window. |
5439 * 1. to avoid seeing slow drawing | 5425 // 1. to avoid seeing slow drawing |
5440 * 2. to prevent a problem seen while moving dialog item | 5426 // 2. to prevent a problem seen while moving dialog item |
5441 * within a visible window. (non-Carbon MacOS 9) | 5427 // within a visible window. (non-Carbon MacOS 9) |
5442 * Could be avoided by changing the resource. | 5428 // Could be avoided by changing the resource. |
5443 */ | |
5444 HideWindow(theWindow); | 5429 HideWindow(theWindow); |
5445 | 5430 |
5446 /* Change the graphical port to the dialog, | 5431 // Change the graphical port to the dialog, |
5447 * so we can measure the text with the proper font */ | 5432 // so we can measure the text with the proper font |
5448 GetPort(&oldPort); | 5433 GetPort(&oldPort); |
5449 SetPortDialogPort(theDialog); | 5434 SetPortDialogPort(theDialog); |
5450 | 5435 |
5451 /* Get the info about the default text, | 5436 // Get the info about the default text, |
5452 * used to calculate the height of the message | 5437 // used to calculate the height of the message |
5453 * and of the text field */ | 5438 // and of the text field |
5454 GetFontInfo(&textFontInfo); | 5439 GetFontInfo(&textFontInfo); |
5455 | 5440 |
5456 /* Set the dialog title */ | 5441 // Set the dialog title |
5457 if (title != NULL) | 5442 if (title != NULL) |
5458 { | 5443 { |
5459 (void) C2PascalString(title, &PascalTitle); | 5444 (void) C2PascalString(title, &PascalTitle); |
5460 SetWTitle(theWindow, PascalTitle); | 5445 SetWTitle(theWindow, PascalTitle); |
5461 } | 5446 } |
5462 | 5447 |
5463 /* Creates the buttons and add them to the Dialog Box. */ | 5448 // Creates the buttons and add them to the Dialog Box. |
5464 buttonDITL = GetResource('DITL', 130); | 5449 buttonDITL = GetResource('DITL', 130); |
5465 buttonChar = buttons; | 5450 buttonChar = buttons; |
5466 button = 0; | 5451 button = 0; |
5467 | 5452 |
5468 /* initialize the hotkey mapping */ | 5453 // initialize the hotkey mapping |
5469 vim_memset(hotKeys, 0, sizeof(hotKeys)); | 5454 vim_memset(hotKeys, 0, sizeof(hotKeys)); |
5470 | 5455 |
5471 for (;*buttonChar != 0;) | 5456 for (;*buttonChar != 0;) |
5472 { | 5457 { |
5473 /* Get the name of the button */ | 5458 // Get the name of the button |
5474 button++; | 5459 button++; |
5475 len = 0; | 5460 len = 0; |
5476 for (;((*buttonChar != DLG_BUTTON_SEP) && (*buttonChar != 0) && (len < 255)); buttonChar++) | 5461 for (;((*buttonChar != DLG_BUTTON_SEP) && (*buttonChar != 0) && (len < 255)); buttonChar++) |
5477 { | 5462 { |
5478 if (*buttonChar != DLG_HOTKEY_CHAR) | 5463 if (*buttonChar != DLG_HOTKEY_CHAR) |
5491 | 5476 |
5492 if (*buttonChar != 0) | 5477 if (*buttonChar != 0) |
5493 buttonChar++; | 5478 buttonChar++; |
5494 name[0] = len; | 5479 name[0] = len; |
5495 | 5480 |
5496 /* Add the button */ | 5481 // Add the button |
5497 AppendDITL(theDialog, buttonDITL, overlayDITL); /* appendDITLRight); */ | 5482 AppendDITL(theDialog, buttonDITL, overlayDITL); // appendDITLRight); |
5498 | 5483 |
5499 /* Change the button's name */ | 5484 // Change the button's name |
5500 macSetDialogItemText(theDialog, button, name); | 5485 macSetDialogItemText(theDialog, button, name); |
5501 | 5486 |
5502 /* Resize the button to fit its name */ | 5487 // Resize the button to fit its name |
5503 width = StringWidth(name) + 2 * dfltButtonEdge; | 5488 width = StringWidth(name) + 2 * dfltButtonEdge; |
5504 /* Limit the size of any button to an acceptable value. */ | 5489 // Limit the size of any button to an acceptable value. |
5505 /* TODO: Should be based on the message width */ | 5490 // TODO: Should be based on the message width |
5506 if (width > maxButtonWidth) | 5491 if (width > maxButtonWidth) |
5507 width = maxButtonWidth; | 5492 width = maxButtonWidth; |
5508 macSizeDialogItem(theDialog, button, width, 0); | 5493 macSizeDialogItem(theDialog, button, width, 0); |
5509 | 5494 |
5510 totalButtonWidth += width; | 5495 totalButtonWidth += width; |
5513 widestButton = width; | 5498 widestButton = width; |
5514 } | 5499 } |
5515 ReleaseResource(buttonDITL); | 5500 ReleaseResource(buttonDITL); |
5516 lastButton = button; | 5501 lastButton = button; |
5517 | 5502 |
5518 /* Add the icon to the Dialog Box. */ | 5503 // Add the icon to the Dialog Box. |
5519 iconItm.idx = lastButton + 1; | 5504 iconItm.idx = lastButton + 1; |
5520 iconDITL = GetResource('DITL', 131); | 5505 iconDITL = GetResource('DITL', 131); |
5521 switch (type) | 5506 switch (type) |
5522 { | 5507 { |
5523 case VIM_GENERIC: | 5508 case VIM_GENERIC: |
5528 default: useIcon = kStopIcon; | 5513 default: useIcon = kStopIcon; |
5529 } | 5514 } |
5530 AppendDITL(theDialog, iconDITL, overlayDITL); | 5515 AppendDITL(theDialog, iconDITL, overlayDITL); |
5531 ReleaseResource(iconDITL); | 5516 ReleaseResource(iconDITL); |
5532 GetDialogItem(theDialog, iconItm.idx, &itemType, &itemHandle, &box); | 5517 GetDialogItem(theDialog, iconItm.idx, &itemType, &itemHandle, &box); |
5533 /* TODO: Should the item be freed? */ | 5518 // TODO: Should the item be freed? |
5534 iconHandle = GetIcon(useIcon); | 5519 iconHandle = GetIcon(useIcon); |
5535 SetDialogItem(theDialog, iconItm.idx, itemType, iconHandle, &box); | 5520 SetDialogItem(theDialog, iconItm.idx, itemType, iconHandle, &box); |
5536 | 5521 |
5537 /* Add the message to the Dialog box. */ | 5522 // Add the message to the Dialog box. |
5538 messageItm.idx = lastButton + 2; | 5523 messageItm.idx = lastButton + 2; |
5539 messageDITL = GetResource('DITL', 132); | 5524 messageDITL = GetResource('DITL', 132); |
5540 AppendDITL(theDialog, messageDITL, overlayDITL); | 5525 AppendDITL(theDialog, messageDITL, overlayDITL); |
5541 ReleaseResource(messageDITL); | 5526 ReleaseResource(messageDITL); |
5542 GetDialogItem(theDialog, messageItm.idx, &itemType, &itemHandle, &box); | 5527 GetDialogItem(theDialog, messageItm.idx, &itemType, &itemHandle, &box); |
5543 (void) C2PascalString(message, &name); | 5528 (void) C2PascalString(message, &name); |
5544 SetDialogItemText(itemHandle, name); | 5529 SetDialogItemText(itemHandle, name); |
5545 messageItm.width = StringWidth(name); | 5530 messageItm.width = StringWidth(name); |
5546 | 5531 |
5547 /* Add the input box if needed */ | 5532 // Add the input box if needed |
5548 if (textfield != NULL) | 5533 if (textfield != NULL) |
5549 { | 5534 { |
5550 /* Cheat for now reuse the message and convert to text edit */ | 5535 // Cheat for now reuse the message and convert to text edit |
5551 inputItm.idx = lastButton + 3; | 5536 inputItm.idx = lastButton + 3; |
5552 inputDITL = GetResource('DITL', 132); | 5537 inputDITL = GetResource('DITL', 132); |
5553 AppendDITL(theDialog, inputDITL, overlayDITL); | 5538 AppendDITL(theDialog, inputDITL, overlayDITL); |
5554 ReleaseResource(inputDITL); | 5539 ReleaseResource(inputDITL); |
5555 GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &box); | 5540 GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &box); |
5556 /* SetDialogItem(theDialog, inputItm.idx, kEditTextDialogItem, itemHandle, &box);*/ | 5541 // SetDialogItem(theDialog, inputItm.idx, kEditTextDialogItem, itemHandle, &box); |
5557 (void) C2PascalString(textfield, &name); | 5542 (void) C2PascalString(textfield, &name); |
5558 SetDialogItemText(itemHandle, name); | 5543 SetDialogItemText(itemHandle, name); |
5559 inputItm.width = StringWidth(name); | 5544 inputItm.width = StringWidth(name); |
5560 | 5545 |
5561 /* Hotkeys don't make sense if there's a text field */ | 5546 // Hotkeys don't make sense if there's a text field |
5562 gDialogHotKeys = NULL; | 5547 gDialogHotKeys = NULL; |
5563 } | 5548 } |
5564 else | 5549 else |
5565 /* Install hotkey table */ | 5550 // Install hotkey table |
5566 gDialogHotKeys = (short *)&hotKeys; | 5551 gDialogHotKeys = (short *)&hotKeys; |
5567 | 5552 |
5568 /* Set the <ENTER> and <ESC> button. */ | 5553 // Set the <ENTER> and <ESC> button. |
5569 SetDialogDefaultItem(theDialog, dfltbutton); | 5554 SetDialogDefaultItem(theDialog, dfltbutton); |
5570 SetDialogCancelItem(theDialog, 0); | 5555 SetDialogCancelItem(theDialog, 0); |
5571 | 5556 |
5572 /* Reposition element */ | 5557 // Reposition element |
5573 | 5558 |
5574 /* Check if we need to force vertical */ | 5559 // Check if we need to force vertical |
5575 if (totalButtonWidth > maximumWidth) | 5560 if (totalButtonWidth > maximumWidth) |
5576 vertical = TRUE; | 5561 vertical = TRUE; |
5577 | 5562 |
5578 /* Place icon */ | 5563 // Place icon |
5579 macMoveDialogItem(theDialog, iconItm.idx, dfltIconSideSpace, dfltElementSpacing, &box); | 5564 macMoveDialogItem(theDialog, iconItm.idx, dfltIconSideSpace, dfltElementSpacing, &box); |
5580 iconItm.box.right = box.right; | 5565 iconItm.box.right = box.right; |
5581 iconItm.box.bottom = box.bottom; | 5566 iconItm.box.bottom = box.bottom; |
5582 | 5567 |
5583 /* Place Message */ | 5568 // Place Message |
5584 messageItm.box.left = iconItm.box.right + dfltIconSideSpace; | 5569 messageItm.box.left = iconItm.box.right + dfltIconSideSpace; |
5585 macSizeDialogItem(theDialog, messageItm.idx, 0, messageLines * (textFontInfo.ascent + textFontInfo.descent)); | 5570 macSizeDialogItem(theDialog, messageItm.idx, 0, messageLines * (textFontInfo.ascent + textFontInfo.descent)); |
5586 macMoveDialogItem(theDialog, messageItm.idx, messageItm.box.left, dfltElementSpacing, &messageItm.box); | 5571 macMoveDialogItem(theDialog, messageItm.idx, messageItm.box.left, dfltElementSpacing, &messageItm.box); |
5587 | 5572 |
5588 /* Place Input */ | 5573 // Place Input |
5589 if (textfield != NULL) | 5574 if (textfield != NULL) |
5590 { | 5575 { |
5591 inputItm.box.left = messageItm.box.left; | 5576 inputItm.box.left = messageItm.box.left; |
5592 inputItm.box.top = messageItm.box.bottom + dfltElementSpacing; | 5577 inputItm.box.top = messageItm.box.bottom + dfltElementSpacing; |
5593 macSizeDialogItem(theDialog, inputItm.idx, 0, textFontInfo.ascent + textFontInfo.descent); | 5578 macSizeDialogItem(theDialog, inputItm.idx, 0, textFontInfo.ascent + textFontInfo.descent); |
5594 macMoveDialogItem(theDialog, inputItm.idx, inputItm.box.left, inputItm.box.top, &inputItm.box); | 5579 macMoveDialogItem(theDialog, inputItm.idx, inputItm.box.left, inputItm.box.top, &inputItm.box); |
5595 /* Convert the static text into a text edit. | 5580 // Convert the static text into a text edit. |
5596 * For some reason this change need to be done last (Dany) */ | 5581 // For some reason this change need to be done last (Dany) |
5597 GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &inputItm.box); | 5582 GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &inputItm.box); |
5598 SetDialogItem(theDialog, inputItm.idx, kEditTextDialogItem, itemHandle, &inputItm.box); | 5583 SetDialogItem(theDialog, inputItm.idx, kEditTextDialogItem, itemHandle, &inputItm.box); |
5599 SelectDialogItemText(theDialog, inputItm.idx, 0, 32767); | 5584 SelectDialogItemText(theDialog, inputItm.idx, 0, 32767); |
5600 } | 5585 } |
5601 | 5586 |
5602 /* Place Button */ | 5587 // Place Button |
5603 if (textfield != NULL) | 5588 if (textfield != NULL) |
5604 { | 5589 { |
5605 buttonItm.box.left = inputItm.box.left; | 5590 buttonItm.box.left = inputItm.box.left; |
5606 buttonItm.box.top = inputItm.box.bottom + dfltElementSpacing; | 5591 buttonItm.box.top = inputItm.box.bottom + dfltElementSpacing; |
5607 } | 5592 } |
5613 | 5598 |
5614 for (button=1; button <= lastButton; button++) | 5599 for (button=1; button <= lastButton; button++) |
5615 { | 5600 { |
5616 | 5601 |
5617 macMoveDialogItem(theDialog, button, buttonItm.box.left, buttonItm.box.top, &box); | 5602 macMoveDialogItem(theDialog, button, buttonItm.box.left, buttonItm.box.top, &box); |
5618 /* With vertical, it's better to have all buttons the same length */ | 5603 // With vertical, it's better to have all buttons the same length |
5619 if (vertical) | 5604 if (vertical) |
5620 { | 5605 { |
5621 macSizeDialogItem(theDialog, button, widestButton, 0); | 5606 macSizeDialogItem(theDialog, button, widestButton, 0); |
5622 GetDialogItem(theDialog, button, &itemType, &itemHandle, &box); | 5607 GetDialogItem(theDialog, button, &itemType, &itemHandle, &box); |
5623 } | 5608 } |
5624 /* Calculate position of next button */ | 5609 // Calculate position of next button |
5625 if (vertical) | 5610 if (vertical) |
5626 buttonItm.box.top = box.bottom + dfltElementSpacing; | 5611 buttonItm.box.top = box.bottom + dfltElementSpacing; |
5627 else | 5612 else |
5628 buttonItm.box.left = box.right + dfltElementSpacing; | 5613 buttonItm.box.left = box.right + dfltElementSpacing; |
5629 } | 5614 } |
5630 | 5615 |
5631 /* Resize the dialog box */ | 5616 // Resize the dialog box |
5632 dialogHeight = box.bottom + dfltElementSpacing; | 5617 dialogHeight = box.bottom + dfltElementSpacing; |
5633 SizeWindow(theWindow, maximumWidth, dialogHeight, TRUE); | 5618 SizeWindow(theWindow, maximumWidth, dialogHeight, TRUE); |
5634 | 5619 |
5635 /* Magic resize */ | 5620 // Magic resize |
5636 AutoSizeDialog(theDialog); | 5621 AutoSizeDialog(theDialog); |
5637 /* Need a horizontal resize anyway so not that useful */ | 5622 // Need a horizontal resize anyway so not that useful |
5638 | 5623 |
5639 /* Display it */ | 5624 // Display it |
5640 ShowWindow(theWindow); | 5625 ShowWindow(theWindow); |
5641 /* BringToFront(theWindow); */ | 5626 // BringToFront(theWindow); |
5642 SelectWindow(theWindow); | 5627 SelectWindow(theWindow); |
5643 | 5628 |
5644 /* DrawDialog(theDialog); */ | 5629 // DrawDialog(theDialog); |
5645 #if 0 | 5630 #if 0 |
5646 GetPort(&oldPort); | 5631 GetPort(&oldPort); |
5647 SetPortDialogPort(theDialog); | 5632 SetPortDialogPort(theDialog); |
5648 #endif | 5633 #endif |
5649 | 5634 |
5650 #ifdef USE_CARBONKEYHANDLER | 5635 #ifdef USE_CARBONKEYHANDLER |
5651 /* Avoid that we use key events for the main window. */ | 5636 // Avoid that we use key events for the main window. |
5652 dialog_busy = TRUE; | 5637 dialog_busy = TRUE; |
5653 #endif | 5638 #endif |
5654 | 5639 |
5655 /* Prepare the shortcut-handling filterProc for handing to the dialog */ | 5640 // Prepare the shortcut-handling filterProc for handing to the dialog |
5656 dialogUPP = NewModalFilterUPP(DialogHotkeyFilterProc); | 5641 dialogUPP = NewModalFilterUPP(DialogHotkeyFilterProc); |
5657 | 5642 |
5658 /* Hang until one of the button is hit */ | 5643 // Hang until one of the button is hit |
5659 do | 5644 do |
5660 ModalDialog(dialogUPP, &itemHit); | 5645 ModalDialog(dialogUPP, &itemHit); |
5661 while ((itemHit < 1) || (itemHit > lastButton)); | 5646 while ((itemHit < 1) || (itemHit > lastButton)); |
5662 | 5647 |
5663 #ifdef USE_CARBONKEYHANDLER | 5648 #ifdef USE_CARBONKEYHANDLER |
5664 dialog_busy = FALSE; | 5649 dialog_busy = FALSE; |
5665 #endif | 5650 #endif |
5666 | 5651 |
5667 /* Copy back the text entered by the user into the param */ | 5652 // Copy back the text entered by the user into the param |
5668 if (textfield != NULL) | 5653 if (textfield != NULL) |
5669 { | 5654 { |
5670 GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &box); | 5655 GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &box); |
5671 GetDialogItemText(itemHandle, (char_u *) &name); | 5656 GetDialogItemText(itemHandle, (char_u *) &name); |
5672 #if IOSIZE < 256 | 5657 #if IOSIZE < 256 |
5673 /* Truncate the name to IOSIZE if needed */ | 5658 // Truncate the name to IOSIZE if needed |
5674 if (name[0] > IOSIZE) | 5659 if (name[0] > IOSIZE) |
5675 name[0] = IOSIZE - 1; | 5660 name[0] = IOSIZE - 1; |
5676 #endif | 5661 #endif |
5677 vim_strncpy(textfield, &name[1], name[0]); | 5662 vim_strncpy(textfield, &name[1], name[0]); |
5678 } | 5663 } |
5679 | 5664 |
5680 /* Restore the original graphical port */ | 5665 // Restore the original graphical port |
5681 SetPort(oldPort); | 5666 SetPort(oldPort); |
5682 | 5667 |
5683 /* Free the modal filterProc */ | 5668 // Free the modal filterProc |
5684 DisposeRoutineDescriptor(dialogUPP); | 5669 DisposeRoutineDescriptor(dialogUPP); |
5685 | 5670 |
5686 /* Get ride of the dialog (free memory) */ | 5671 // Get ride of the dialog (free memory) |
5687 DisposeDialog(theDialog); | 5672 DisposeDialog(theDialog); |
5688 | 5673 |
5689 return itemHit; | 5674 return itemHit; |
5690 /* | 5675 /* |
5691 * Useful thing which could be used | 5676 * Useful thing which could be used |
5694 * MoveDialogItem(): Probably better than SetDialogItem | 5679 * MoveDialogItem(): Probably better than SetDialogItem |
5695 * SizeDialogItem(): (but is it Carbon Only?) | 5680 * SizeDialogItem(): (but is it Carbon Only?) |
5696 * AutoSizeDialog(): Magic resize of dialog based on text length | 5681 * AutoSizeDialog(): Magic resize of dialog based on text length |
5697 */ | 5682 */ |
5698 } | 5683 } |
5699 #endif /* FEAT_DIALOG_GUI */ | 5684 #endif // FEAT_DIALOG_GUI |
5700 | 5685 |
5701 /* | 5686 /* |
5702 * Display the saved error message(s). | 5687 * Display the saved error message(s). |
5703 */ | 5688 */ |
5704 #ifdef USE_MCH_ERRMSG | 5689 #ifdef USE_MCH_ERRMSG |
5709 char_u pError[256]; | 5694 char_u pError[256]; |
5710 | 5695 |
5711 if (error_ga.ga_data == NULL) | 5696 if (error_ga.ga_data == NULL) |
5712 return; | 5697 return; |
5713 | 5698 |
5714 /* avoid putting up a message box with blanks only */ | 5699 // avoid putting up a message box with blanks only |
5715 for (p = (char *)error_ga.ga_data; *p; ++p) | 5700 for (p = (char *)error_ga.ga_data; *p; ++p) |
5716 if (!isspace(*p)) | 5701 if (!isspace(*p)) |
5717 { | 5702 { |
5718 if (STRLEN(p) > 255) | 5703 if (STRLEN(p) > 255) |
5719 pError[0] = 255; | 5704 pError[0] = 255; |
5722 | 5707 |
5723 STRNCPY(&pError[1], p, pError[0]); | 5708 STRNCPY(&pError[1], p, pError[0]); |
5724 ParamText(pError, nil, nil, nil); | 5709 ParamText(pError, nil, nil, nil); |
5725 Alert(128, nil); | 5710 Alert(128, nil); |
5726 break; | 5711 break; |
5727 /* TODO: handled message longer than 256 chars | 5712 // TODO: handled message longer than 256 chars |
5728 * use auto-sizeable alert | 5713 // use auto-sizeable alert |
5729 * or dialog with scrollbars (TextEdit zone) | 5714 // or dialog with scrollbars (TextEdit zone) |
5730 */ | |
5731 } | 5715 } |
5732 ga_clear(&error_ga); | 5716 ga_clear(&error_ga); |
5733 } | 5717 } |
5734 #endif | 5718 #endif |
5735 | 5719 |
5748 } | 5732 } |
5749 | 5733 |
5750 void | 5734 void |
5751 gui_mch_setmouse(int x, int y) | 5735 gui_mch_setmouse(int x, int y) |
5752 { | 5736 { |
5753 /* TODO */ | 5737 // TODO |
5754 #if 0 | 5738 #if 0 |
5755 /* From FAQ 3-11 */ | 5739 // From FAQ 3-11 |
5756 | 5740 |
5757 CursorDevicePtr myMouse; | 5741 CursorDevicePtr myMouse; |
5758 Point where; | 5742 Point where; |
5759 | 5743 |
5760 if ( NGetTrapAddress(_CursorDeviceDispatch, ToolTrap) | 5744 if ( NGetTrapAddress(_CursorDeviceDispatch, ToolTrap) |
5761 != NGetTrapAddress(_Unimplemented, ToolTrap)) | 5745 != NGetTrapAddress(_Unimplemented, ToolTrap)) |
5762 { | 5746 { |
5763 /* New way */ | 5747 // New way |
5764 | 5748 |
5765 /* | 5749 /* |
5766 * Get first device with one button. | 5750 * Get first device with one button. |
5767 * This will probably be the standard mouse | 5751 * This will probably be the standard mouse |
5768 * start at head of cursor dev list | 5752 * start at head of cursor dev list |
5771 | 5755 |
5772 myMouse = nil; | 5756 myMouse = nil; |
5773 | 5757 |
5774 do | 5758 do |
5775 { | 5759 { |
5776 /* Get the next cursor device */ | 5760 // Get the next cursor device |
5777 CursorDeviceNextDevice(&myMouse); | 5761 CursorDeviceNextDevice(&myMouse); |
5778 } | 5762 } |
5779 while ((myMouse != nil) && (myMouse->cntButtons != 1)); | 5763 while ((myMouse != nil) && (myMouse->cntButtons != 1)); |
5780 | 5764 |
5781 CursorDeviceMoveTo(myMouse, x, y); | 5765 CursorDeviceMoveTo(myMouse, x, y); |
5782 } | 5766 } |
5783 else | 5767 else |
5784 { | 5768 { |
5785 /* Old way */ | 5769 // Old way |
5786 where.h = x; | 5770 where.h = x; |
5787 where.v = y; | 5771 where.v = y; |
5788 | 5772 |
5789 *(Point *)RawMouse = where; | 5773 *(Point *)RawMouse = where; |
5790 *(Point *)MTemp = where; | 5774 *(Point *)MTemp = where; |
5809 SInt16 CntxMenuID; | 5793 SInt16 CntxMenuID; |
5810 UInt16 CntxMenuItem; | 5794 UInt16 CntxMenuItem; |
5811 Str255 HelpName = ""; | 5795 Str255 HelpName = ""; |
5812 GrafPtr savePort; | 5796 GrafPtr savePort; |
5813 | 5797 |
5814 /* Save Current Port: On MacOS X we seem to lose the port */ | 5798 // Save Current Port: On MacOS X we seem to lose the port |
5815 GetPort(&savePort); /*OSX*/ | 5799 GetPort(&savePort); //OSX |
5816 | 5800 |
5817 GetMouse(&where); | 5801 GetMouse(&where); |
5818 LocalToGlobal(&where); /*OSX*/ | 5802 LocalToGlobal(&where); //OSX |
5819 CntxMenu = menu->submenu_handle; | 5803 CntxMenu = menu->submenu_handle; |
5820 | 5804 |
5821 /* TODO: Get the text selection from Vim */ | 5805 // TODO: Get the text selection from Vim |
5822 | 5806 |
5823 /* Call to Handle Popup */ | 5807 // Call to Handle Popup |
5824 status = ContextualMenuSelect(CntxMenu, where, false, kCMHelpItemRemoveHelp, | 5808 status = ContextualMenuSelect(CntxMenu, where, false, kCMHelpItemRemoveHelp, |
5825 HelpName, NULL, &CntxType, &CntxMenuID, &CntxMenuItem); | 5809 HelpName, NULL, &CntxType, &CntxMenuID, &CntxMenuItem); |
5826 | 5810 |
5827 if (status == noErr) | 5811 if (status == noErr) |
5828 { | 5812 { |
5829 if (CntxType == kCMMenuItemSelected) | 5813 if (CntxType == kCMMenuItemSelected) |
5830 { | 5814 { |
5831 /* Handle the menu CntxMenuID, CntxMenuItem */ | 5815 // Handle the menu CntxMenuID, CntxMenuItem |
5832 /* The submenu can be handle directly by gui_mac_handle_menu */ | 5816 // The submenu can be handle directly by gui_mac_handle_menu |
5833 /* But what about the current menu, is the menu changed by | 5817 // But what about the current menu, is the menu changed by |
5834 * ContextualMenuSelect */ | 5818 // ContextualMenuSelect |
5835 gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem); | 5819 gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem); |
5836 } | 5820 } |
5837 else if (CntxMenuID == kCMShowHelpSelected) | 5821 else if (CntxMenuID == kCMShowHelpSelected) |
5838 { | 5822 { |
5839 /* Should come up with the help */ | 5823 // Should come up with the help |
5840 } | 5824 } |
5841 } | 5825 } |
5842 | 5826 |
5843 /* Restore original Port */ | 5827 // Restore original Port |
5844 SetPort(savePort); /*OSX*/ | 5828 SetPort(savePort); //OSX |
5845 } | 5829 } |
5846 | 5830 |
5847 #if defined(FEAT_CW_EDITOR) || defined(PROTO) | 5831 #if defined(FEAT_CW_EDITOR) || defined(PROTO) |
5848 /* TODO: Is it need for MACOS_X? (Dany) */ | 5832 // TODO: Is it need for MACOS_X? (Dany) |
5849 void | 5833 void |
5850 mch_post_buffer_write(buf_T *buf) | 5834 mch_post_buffer_write(buf_T *buf) |
5851 { | 5835 { |
5852 GetFSSpecFromPath(buf->b_ffname, &buf->b_FSSpec); | 5836 GetFSSpecFromPath(buf->b_ffname, &buf->b_FSSpec); |
5853 Send_KAHL_MOD_AE(buf); | 5837 Send_KAHL_MOD_AE(buf); |
5860 * (The icon is not taken care of). | 5844 * (The icon is not taken care of). |
5861 */ | 5845 */ |
5862 void | 5846 void |
5863 gui_mch_settitle(char_u *title, char_u *icon) | 5847 gui_mch_settitle(char_u *title, char_u *icon) |
5864 { | 5848 { |
5865 /* TODO: Get vim to make sure maxlen (from p_titlelen) is smaller | 5849 // TODO: Get vim to make sure maxlen (from p_titlelen) is smaller |
5866 * that 256. Even better get it to fit nicely in the titlebar. | 5850 // that 256. Even better get it to fit nicely in the titlebar. |
5867 */ | |
5868 #ifdef MACOS_CONVERT | 5851 #ifdef MACOS_CONVERT |
5869 CFStringRef windowTitle; | 5852 CFStringRef windowTitle; |
5870 size_t windowTitleLen; | 5853 size_t windowTitleLen; |
5871 #else | 5854 #else |
5872 char_u *pascalTitle; | 5855 char_u *pascalTitle; |
5873 #endif | 5856 #endif |
5874 | 5857 |
5875 if (title == NULL) /* nothing to do */ | 5858 if (title == NULL) // nothing to do |
5876 return; | 5859 return; |
5877 | 5860 |
5878 #ifdef MACOS_CONVERT | 5861 #ifdef MACOS_CONVERT |
5879 windowTitleLen = STRLEN(title); | 5862 windowTitleLen = STRLEN(title); |
5880 windowTitle = (CFStringRef)mac_enc_to_cfstring(title, windowTitleLen); | 5863 windowTitle = (CFStringRef)mac_enc_to_cfstring(title, windowTitleLen); |
5923 } | 5906 } |
5924 | 5907 |
5925 int | 5908 int |
5926 GetFSSpecFromPath(char_u *file, FSSpec *fileFSSpec) | 5909 GetFSSpecFromPath(char_u *file, FSSpec *fileFSSpec) |
5927 { | 5910 { |
5928 /* From FAQ 8-12 */ | 5911 // From FAQ 8-12 |
5929 Str255 filePascal; | 5912 Str255 filePascal; |
5930 CInfoPBRec myCPB; | 5913 CInfoPBRec myCPB; |
5931 OSErr err; | 5914 OSErr err; |
5932 | 5915 |
5933 (void) C2PascalString(file, &filePascal); | 5916 (void) C2PascalString(file, &filePascal); |
5937 myCPB.dirInfo.ioFDirIndex = 0; | 5920 myCPB.dirInfo.ioFDirIndex = 0; |
5938 myCPB.dirInfo.ioDrDirID = 0; | 5921 myCPB.dirInfo.ioDrDirID = 0; |
5939 | 5922 |
5940 err= PBGetCatInfo(&myCPB, false); | 5923 err= PBGetCatInfo(&myCPB, false); |
5941 | 5924 |
5942 /* vRefNum, dirID, name */ | 5925 // vRefNum, dirID, name |
5943 FSMakeFSSpec(0, 0, filePascal, fileFSSpec); | 5926 FSMakeFSSpec(0, 0, filePascal, fileFSSpec); |
5944 | 5927 |
5945 /* TODO: Use an error code mechanism */ | 5928 // TODO: Use an error code mechanism |
5946 return 0; | 5929 return 0; |
5947 } | 5930 } |
5948 | 5931 |
5949 /* | 5932 /* |
5950 * Convert a FSSpec to a full path | 5933 * Convert a FSSpec to a full path |
5974 char_u temporary[255]; | 5957 char_u temporary[255]; |
5975 char_u *temporaryPtr = temporary; | 5958 char_u *temporaryPtr = temporary; |
5976 #endif | 5959 #endif |
5977 | 5960 |
5978 #ifdef USE_UNIXFILENAME | 5961 #ifdef USE_UNIXFILENAME |
5979 /* Get the default volume */ | 5962 // Get the default volume |
5980 /* TODO: Remove as this only work if Vim is on the Boot Volume*/ | 5963 // TODO: Remove as this only work if Vim is on the Boot Volume |
5981 error=HGetVol(NULL, &dfltVol_vRefNum, &dfltVol_dirID); | 5964 error=HGetVol(NULL, &dfltVol_vRefNum, &dfltVol_dirID); |
5982 | 5965 |
5983 if (error) | 5966 if (error) |
5984 return NULL; | 5967 return NULL; |
5985 #endif | 5968 #endif |
5986 | 5969 |
5987 /* Start filling fname with file.name */ | 5970 // Start filling fname with file.name |
5988 vim_strncpy(filenamePtr, &file.name[1], file.name[0]); | 5971 vim_strncpy(filenamePtr, &file.name[1], file.name[0]); |
5989 | 5972 |
5990 /* Get the info about the file specified in FSSpec */ | 5973 // Get the info about the file specified in FSSpec |
5991 theCPB.dirInfo.ioFDirIndex = 0; | 5974 theCPB.dirInfo.ioFDirIndex = 0; |
5992 theCPB.dirInfo.ioNamePtr = file.name; | 5975 theCPB.dirInfo.ioNamePtr = file.name; |
5993 theCPB.dirInfo.ioVRefNum = file.vRefNum; | 5976 theCPB.dirInfo.ioVRefNum = file.vRefNum; |
5994 /*theCPB.hFileInfo.ioDirID = 0;*/ | 5977 //theCPB.hFileInfo.ioDirID = 0; |
5995 theCPB.dirInfo.ioDrDirID = file.parID; | 5978 theCPB.dirInfo.ioDrDirID = file.parID; |
5996 | 5979 |
5997 /* As ioFDirIndex = 0, get the info of ioNamePtr, | 5980 // As ioFDirIndex = 0, get the info of ioNamePtr, |
5998 which is relative to ioVrefNum, ioDirID */ | 5981 // which is relative to ioVrefNum, ioDirID |
5999 error = PBGetCatInfo(&theCPB, false); | 5982 error = PBGetCatInfo(&theCPB, false); |
6000 | 5983 |
6001 /* If we are called for a new file we expect fnfErr */ | 5984 // If we are called for a new file we expect fnfErr |
6002 if ((error) && (error != fnfErr)) | 5985 if ((error) && (error != fnfErr)) |
6003 return NULL; | 5986 return NULL; |
6004 | 5987 |
6005 /* Check if it's a file or folder */ | 5988 // Check if it's a file or folder |
6006 /* default to file if file don't exist */ | 5989 // default to file if file don't exist |
6007 if (((theCPB.hFileInfo.ioFlAttrib & ioDirMask) == 0) || (error)) | 5990 if (((theCPB.hFileInfo.ioFlAttrib & ioDirMask) == 0) || (error)) |
6008 folder = 0; /* It's not a folder */ | 5991 folder = 0; // It's not a folder |
6009 else | 5992 else |
6010 folder = 1; | 5993 folder = 1; |
6011 | 5994 |
6012 #ifdef USE_UNIXFILENAME | 5995 #ifdef USE_UNIXFILENAME |
6013 /* | 5996 /* |
6014 * The functions used here are available in Carbon, but do nothing on | 5997 * The functions used here are available in Carbon, but do nothing on |
6015 * MacOS 8 and 9. | 5998 * MacOS 8 and 9. |
6016 */ | 5999 */ |
6017 if (error == fnfErr) | 6000 if (error == fnfErr) |
6018 { | 6001 { |
6019 /* If the file to be saved does not already exist, it isn't possible | 6002 // If the file to be saved does not already exist, it isn't possible |
6020 to convert its FSSpec into an FSRef. But we can construct an | 6003 // to convert its FSSpec into an FSRef. But we can construct an |
6021 FSSpec for the file's parent folder (since we have its volume and | 6004 // FSSpec for the file's parent folder (since we have its volume and |
6022 directory IDs), and since that folder does exist, we can convert | 6005 // directory IDs), and since that folder does exist, we can convert |
6023 that FSSpec into an FSRef, convert the FSRef in turn into a path, | 6006 // that FSSpec into an FSRef, convert the FSRef in turn into a path, |
6024 and, finally, append the filename. */ | 6007 // and, finally, append the filename. |
6025 FSSpec dirSpec; | 6008 FSSpec dirSpec; |
6026 FSRef dirRef; | 6009 FSRef dirRef; |
6027 Str255 emptyFilename = "\p"; | 6010 Str255 emptyFilename = "\p"; |
6028 error = FSMakeFSSpec(theCPB.dirInfo.ioVRefNum, | 6011 error = FSMakeFSSpec(theCPB.dirInfo.ioVRefNum, |
6029 theCPB.dirInfo.ioDrDirID, emptyFilename, &dirSpec); | 6012 theCPB.dirInfo.ioDrDirID, emptyFilename, &dirSpec); |
6041 STRCAT(path, "/"); | 6024 STRCAT(path, "/"); |
6042 STRCAT(path, filenamePtr); | 6025 STRCAT(path, filenamePtr); |
6043 } | 6026 } |
6044 else | 6027 else |
6045 { | 6028 { |
6046 /* If the file to be saved already exists, we can get its full path | 6029 // If the file to be saved already exists, we can get its full path |
6047 by converting its FSSpec into an FSRef. */ | 6030 // by converting its FSSpec into an FSRef. |
6048 error=FSpMakeFSRef(&file, &refFile); | 6031 error=FSpMakeFSRef(&file, &refFile); |
6049 if (error) | 6032 if (error) |
6050 return NULL; | 6033 return NULL; |
6051 | 6034 |
6052 status=FSRefMakePath(&refFile, (UInt8 *) path, pathSize); | 6035 status=FSRefMakePath(&refFile, (UInt8 *) path, pathSize); |
6053 if (status) | 6036 if (status) |
6054 return NULL; | 6037 return NULL; |
6055 } | 6038 } |
6056 | 6039 |
6057 /* Add a slash at the end if needed */ | 6040 // Add a slash at the end if needed |
6058 if (folder) | 6041 if (folder) |
6059 STRCAT(path, "/"); | 6042 STRCAT(path, "/"); |
6060 | 6043 |
6061 return (vim_strsave(path)); | 6044 return (vim_strsave(path)); |
6062 #else | 6045 #else |
6063 /* TODO: Get rid of all USE_UNIXFILENAME below */ | 6046 // TODO: Get rid of all USE_UNIXFILENAME below |
6064 /* Set ioNamePtr, it's the same area which is always reused. */ | 6047 // Set ioNamePtr, it's the same area which is always reused. |
6065 theCPB.dirInfo.ioNamePtr = directoryName; | 6048 theCPB.dirInfo.ioNamePtr = directoryName; |
6066 | 6049 |
6067 /* Trick for first entry, set ioDrParID to the first value | 6050 // Trick for first entry, set ioDrParID to the first value |
6068 * we want for ioDrDirID*/ | 6051 // we want for ioDrDirID |
6069 theCPB.dirInfo.ioDrParID = file.parID; | 6052 theCPB.dirInfo.ioDrParID = file.parID; |
6070 theCPB.dirInfo.ioDrDirID = file.parID; | 6053 theCPB.dirInfo.ioDrDirID = file.parID; |
6071 | 6054 |
6072 if ((TRUE) && (file.parID != fsRtDirID /*fsRtParID*/)) | 6055 if ((TRUE) && (file.parID != fsRtDirID /*fsRtParID*/)) |
6073 do | 6056 do |
6074 { | 6057 { |
6075 theCPB.dirInfo.ioFDirIndex = -1; | 6058 theCPB.dirInfo.ioFDirIndex = -1; |
6076 /* theCPB.dirInfo.ioNamePtr = directoryName; Already done above. */ | 6059 // theCPB.dirInfo.ioNamePtr = directoryName; Already done above. |
6077 theCPB.dirInfo.ioVRefNum = file.vRefNum; | 6060 theCPB.dirInfo.ioVRefNum = file.vRefNum; |
6078 /* theCPB.dirInfo.ioDirID = irrelevant when ioFDirIndex = -1 */ | 6061 // theCPB.dirInfo.ioDirID = irrelevant when ioFDirIndex = -1 |
6079 theCPB.dirInfo.ioDrDirID = theCPB.dirInfo.ioDrParID; | 6062 theCPB.dirInfo.ioDrDirID = theCPB.dirInfo.ioDrParID; |
6080 | 6063 |
6081 /* As ioFDirIndex = -1, get the info of ioDrDirID, */ | 6064 // As ioFDirIndex = -1, get the info of ioDrDirID, |
6082 /* *ioNamePtr[0 TO 31] will be updated */ | 6065 // *ioNamePtr[0 TO 31] will be updated |
6083 error = PBGetCatInfo(&theCPB,false); | 6066 error = PBGetCatInfo(&theCPB,false); |
6084 | 6067 |
6085 if (error) | 6068 if (error) |
6086 return NULL; | 6069 return NULL; |
6087 | 6070 |
6088 /* Put the new directoryName in front of the current fname */ | 6071 // Put the new directoryName in front of the current fname |
6089 STRCPY(temporaryPtr, filenamePtr); | 6072 STRCPY(temporaryPtr, filenamePtr); |
6090 vim_strncpy(filenamePtr, &directoryName[1], directoryName[0]); | 6073 vim_strncpy(filenamePtr, &directoryName[1], directoryName[0]); |
6091 STRCAT(filenamePtr, ":"); | 6074 STRCAT(filenamePtr, ":"); |
6092 STRCAT(filenamePtr, temporaryPtr); | 6075 STRCAT(filenamePtr, temporaryPtr); |
6093 } | 6076 } |
6094 #if 1 /* def USE_UNIXFILENAME */ | 6077 #if 1 // def USE_UNIXFILENAME |
6095 while ((theCPB.dirInfo.ioDrParID != fsRtDirID) /* && */ | 6078 while ((theCPB.dirInfo.ioDrParID != fsRtDirID) |
6096 /* (theCPB.dirInfo.ioDrDirID != fsRtDirID)*/); | 6079 /* && (theCPB.dirInfo.ioDrDirID != fsRtDirID)*/); |
6097 #else | 6080 #else |
6098 while (theCPB.dirInfo.ioDrDirID != fsRtDirID); | 6081 while (theCPB.dirInfo.ioDrDirID != fsRtDirID); |
6099 #endif | 6082 #endif |
6100 | 6083 |
6101 /* Get the information about the volume on which the file reside */ | 6084 // Get the information about the volume on which the file reside |
6102 theCPB.dirInfo.ioFDirIndex = -1; | 6085 theCPB.dirInfo.ioFDirIndex = -1; |
6103 /* theCPB.dirInfo.ioNamePtr = directoryName; Already done above. */ | 6086 // theCPB.dirInfo.ioNamePtr = directoryName; Already done above. |
6104 theCPB.dirInfo.ioVRefNum = file.vRefNum; | 6087 theCPB.dirInfo.ioVRefNum = file.vRefNum; |
6105 /* theCPB.dirInfo.ioDirID = irrelevant when ioFDirIndex = -1 */ | 6088 // theCPB.dirInfo.ioDirID = irrelevant when ioFDirIndex = -1 |
6106 theCPB.dirInfo.ioDrDirID = theCPB.dirInfo.ioDrParID; | 6089 theCPB.dirInfo.ioDrDirID = theCPB.dirInfo.ioDrParID; |
6107 | 6090 |
6108 /* As ioFDirIndex = -1, get the info of ioDrDirID, */ | 6091 // As ioFDirIndex = -1, get the info of ioDrDirID, |
6109 /* *ioNamePtr[0 TO 31] will be updated */ | 6092 // *ioNamePtr[0 TO 31] will be updated |
6110 error = PBGetCatInfo(&theCPB,false); | 6093 error = PBGetCatInfo(&theCPB,false); |
6111 | 6094 |
6112 if (error) | 6095 if (error) |
6113 return NULL; | 6096 return NULL; |
6114 | 6097 |
6115 /* For MacOS Classic always add the volume name */ | 6098 // For MacOS Classic always add the volume name |
6116 /* For MacOS X add the volume name preceded by "Volumes" */ | 6099 // For MacOS X add the volume name preceded by "Volumes" |
6117 /* when we are not referring to the boot volume */ | 6100 // when we are not referring to the boot volume |
6118 #ifdef USE_UNIXFILENAME | 6101 #ifdef USE_UNIXFILENAME |
6119 if (file.vRefNum != dfltVol_vRefNum) | 6102 if (file.vRefNum != dfltVol_vRefNum) |
6120 #endif | 6103 #endif |
6121 { | 6104 { |
6122 /* Add the volume name */ | 6105 // Add the volume name |
6123 STRCPY(temporaryPtr, filenamePtr); | 6106 STRCPY(temporaryPtr, filenamePtr); |
6124 vim_strncpy(filenamePtr, &directoryName[1], directoryName[0]); | 6107 vim_strncpy(filenamePtr, &directoryName[1], directoryName[0]); |
6125 STRCAT(filenamePtr, ":"); | 6108 STRCAT(filenamePtr, ":"); |
6126 STRCAT(filenamePtr, temporaryPtr); | 6109 STRCAT(filenamePtr, temporaryPtr); |
6127 | 6110 |
6128 #ifdef USE_UNIXFILENAME | 6111 #ifdef USE_UNIXFILENAME |
6129 STRCPY(temporaryPtr, filenamePtr); | 6112 STRCPY(temporaryPtr, filenamePtr); |
6130 filenamePtr[0] = 0; /* NULL terminate the string */ | 6113 filenamePtr[0] = 0; // NULL terminate the string |
6131 STRCAT(filenamePtr, "Volumes:"); | 6114 STRCAT(filenamePtr, "Volumes:"); |
6132 STRCAT(filenamePtr, temporaryPtr); | 6115 STRCAT(filenamePtr, temporaryPtr); |
6133 #endif | 6116 #endif |
6134 } | 6117 } |
6135 | 6118 |
6136 /* Append final path separator if it's a folder */ | 6119 // Append final path separator if it's a folder |
6137 if (folder) | 6120 if (folder) |
6138 STRCAT(fname, ":"); | 6121 STRCAT(fname, ":"); |
6139 | 6122 |
6140 /* As we use Unix File Name for MacOS X convert it */ | 6123 // As we use Unix File Name for MacOS X convert it |
6141 #ifdef USE_UNIXFILENAME | 6124 #ifdef USE_UNIXFILENAME |
6142 /* Need to insert leading / */ | 6125 // Need to insert leading / |
6143 /* TODO: get the above code to use directly the / */ | 6126 // TODO: get the above code to use directly the / |
6144 STRCPY(&temporaryPtr[1], filenamePtr); | 6127 STRCPY(&temporaryPtr[1], filenamePtr); |
6145 temporaryPtr[0] = '/'; | 6128 temporaryPtr[0] = '/'; |
6146 STRCPY(filenamePtr, temporaryPtr); | 6129 STRCPY(filenamePtr, temporaryPtr); |
6147 { | 6130 { |
6148 char *p; | 6131 char *p; |
6166 */ | 6149 */ |
6167 void | 6150 void |
6168 im_set_position(int row, int col) | 6151 im_set_position(int row, int col) |
6169 { | 6152 { |
6170 # if 0 | 6153 # if 0 |
6171 /* TODO: Implement me! */ | 6154 // TODO: Implement me! |
6172 im_start_row = row; | 6155 im_start_row = row; |
6173 im_start_col = col; | 6156 im_start_col = col; |
6174 # endif | 6157 # endif |
6175 } | 6158 } |
6176 | 6159 |
6195 | 6178 |
6196 if (im_initialized == 0) | 6179 if (im_initialized == 0) |
6197 { | 6180 { |
6198 im_initialized = 1; | 6181 im_initialized = 1; |
6199 | 6182 |
6200 /* save default TSM component (should be U.S.) to default */ | 6183 // save default TSM component (should be U.S.) to default |
6201 GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault, | 6184 GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault, |
6202 kKeyboardInputMethodClass); | 6185 kKeyboardInputMethodClass); |
6203 } | 6186 } |
6204 | 6187 |
6205 if (active == TRUE) | 6188 if (active == TRUE) |
6248 | 6231 |
6249 if (im_initialized == 0) | 6232 if (im_initialized == 0) |
6250 { | 6233 { |
6251 im_initialized = 1; | 6234 im_initialized = 1; |
6252 | 6235 |
6253 /* save default TSM component (should be U.S.) to default */ | 6236 // save default TSM component (should be U.S.) to default |
6254 GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault, | 6237 GetDefaultInputMethodOfClass(&gTSCDefault, &gTSLDefault, |
6255 kKeyboardInputMethodClass); | 6238 kKeyboardInputMethodClass); |
6256 } | 6239 } |
6257 | 6240 |
6258 if (active == TRUE) | 6241 if (active == TRUE) |
6280 | 6263 |
6281 if (slptr) | 6264 if (slptr) |
6282 GetDefaultInputMethodOfClass(&gTSCInsert, slptr, | 6265 GetDefaultInputMethodOfClass(&gTSCInsert, slptr, |
6283 kKeyboardInputMethodClass); | 6266 kKeyboardInputMethodClass); |
6284 | 6267 |
6285 /* restore to default when switch to normal mode, so than we could | 6268 // restore to default when switch to normal mode, so than we could |
6286 * enter commands easier */ | 6269 // enter commands easier |
6287 SetDefaultInputMethodOfClass(gTSCDefault, &gTSLDefault, | 6270 SetDefaultInputMethodOfClass(gTSCDefault, &gTSLDefault, |
6288 kKeyboardInputMethodClass); | 6271 kKeyboardInputMethodClass); |
6289 SetTextServiceLanguage(&gTSLDefault); | 6272 SetTextServiceLanguage(&gTSLDefault); |
6290 | 6273 |
6291 im_is_active = FALSE; | 6274 im_is_active = FALSE; |