annotate src/gui_mac.c @ 502:52e76e2b5b65 v7.0140

updated for version 7.0140
author vimboss
date Thu, 01 Sep 2005 20:46:49 +0000
parents ce2181d14aa0
children 1325fab089fd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 * GUI/Motif support by Robert Webb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 * Macintosh port by Dany St-Amant
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * and Axel Kielhorn
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * Port to MPW by Bernhard PrŸmmer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 * Initial Carbon port by Ammon Skidmore
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 * NOTE: Comment mentionning FAQ refer to the book:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 * "Macworld Mac Programming FAQs" from "IDG Books"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 * WARNING: Vim must be able to compile without Carbon
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 * As the desired minimum requirement are circa System 7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 * (I want to run it on my Mac Classic) (Dany)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 * TODO: Change still to merge from the macvim's iDisk
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 * error_ga, mch_errmsg, Navigation's changes in gui_mch_browse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 * uses of MenuItemIndex, changes in gui_mch_set_shellsize,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 * ScrapManager error handling.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 * Comments about function remaining to Carbonize.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 /* TODO: find the best place for this (Dany) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 # if ! TARGET_API_MAC_CARBON
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 /* Enable the new API functions even when not compiling for Carbon */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 /* Apple recomends Universal Interface 3.3.2 or later */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 # define OPAQUE_TOOLBOX_STRUCTS 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 # define ACCESSOR_CALLS_ARE_FUNCTIONS 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 /* Help Menu not supported by Carbon */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 # define USE_HELPMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 #include <Devices.h> /* included first to avoid CR problems */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 /* Enable Contextual Menu Support */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 #if UNIVERSAL_INTERFACES_VERSION >= 0x0320
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 # define USE_CTRLCLICKMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 /* Put Vim Help in MacOS Help */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 #define USE_HELPMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 /* Enable AEVENT */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 #define USE_AEVENT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 /* Compile as CodeWarior External Editor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 #if defined(FEAT_CW_EDITOR) && !defined(USE_AEVENT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 # define USE_AEVENT /* Need Apple Event Support */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 /* The VIM creator is CodeWarior specific */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 #if !(defined(__MRC__) || defined(__SC__) || defined(__APPLE_CC__))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 # define USE_VIM_CREATOR_ID
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 # if 0 /* Was this usefull for some compiler? (Dany) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 static OSType _fcreator = 'VIM!';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 static OSType _ftype = 'TEXT';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
77 /* Vim's Scrap flavor. */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
78 #define VIMSCRAPFLAVOR 'VIM!'
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
79
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 /* CARBON version only tested with Project Builder under MacOS X */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 #undef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 #if (defined(__APPLE_CC__) || defined(__MRC__)) && defined(TARGET_API_MAC_CARBON)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 # if TARGET_API_MAC_CARBON
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 # define USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 #undef USE_MOUSEWHEEL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 #if defined(MACOS_X) && defined(USE_CARBONIZED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 # define USE_MOUSEWHEEL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 static EventHandlerUPP mouseWheelHandlerUPP = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
94 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
95 # define USE_CARBONKEYHANDLER
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
96 static EventHandlerUPP keyEventHandlerUPP = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
97 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
98
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
99 #ifdef MACOS_X
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
100 SInt32 gMacSystemVersion;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
101 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
102
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 /* Debugging feature: start Vim window OFFSETed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 #undef USE_OFFSETED_WINDOW
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 /* Debugging feature: use CodeWarior SIOUX */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 #undef USE_SIOUX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 /* Include some file. TODO: move into os_mac.h */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 #include <Menus.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 #include <Resources.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 #if !TARGET_API_MAC_CARBON
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 #include <StandardFile.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 #include <Traps.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 #include <Balloons.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 #include <Processes.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 #ifdef USE_AEVENT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 # include <AppleEvents.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 # include <AERegistry.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 #ifdef USE_CTRLCLICKMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 # include <Gestalt.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 #ifdef USE_SIOUX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 # include <stdio.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 # include <sioux.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 # include <console.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 #if UNIVERSAL_INTERFACES_VERSION >= 0x0330
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 # include <ControlDefinitions.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 # include <Navigation.h> /* Navigation only part of ?? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 #if TARGET_API_MAC_CARBON && 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 /* New Help Interface for Mac, not implemented yet.*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 # include <MacHelp.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 * Translate new name to old ones
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 * New function only available in MacOS 8.5,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 * So use old one to be compatible back to System 7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 #ifndef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 # undef EnableMenuItem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 # define EnableMenuItem EnableItem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 # undef DisableMenuItem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 # define DisableMenuItem DisableItem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 /* Carbon does not support the Get/SetControll functions,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 * use Get/SetControl32Bit instead and rename for non-carbon
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 * systems.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 #ifndef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 # undef SetControl32BitMaximum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 # define SetControl32BitMaximum SetControlMaximum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 # undef SetControl32BitMinimum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162 # define SetControl32BitMinimum SetControlMinimum
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
163 # undef SetControl32BitValue
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
164 # define SetControl32BitValue SetControlValue
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
165 # undef GetControl32BitValue
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
166 # define GetControl32BitValue GetControlValue
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
167 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
169 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
170 * ???
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
171 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 #define kNothing 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 #define kCreateEmpty 2 /*1*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 #define kCreateRect 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 #define kDestroy 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 * Dany: Don't like those...
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 #define topLeft(r) (((Point*)&(r))[0])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 #define botRight(r) (((Point*)&(r))[1])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 /* Time of last mouse click, to detect double-click */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 static long lastMouseTick = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 /* ??? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190 static RgnHandle cursorRgn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191 static RgnHandle dragRgn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
192 static Rect dragRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193 static short dragRectEnbl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 static short dragRectControl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196 /* This variable is set when waiting for an event, which is the only moment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 * scrollbar dragging can be done directly. It's not allowed while commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198 * are executed, because it may move the cursor and that may cause unexpected
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 * problems (e.g., while ":s" is working).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 static int allow_scrollbar = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 /* Last mouse click caused contextual menu, (to provide proper release) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
204 #ifdef USE_CTRLCLICKMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205 static short clickIsPopup;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
208 /* Feedback Action for Scrollbar */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 ControlActionUPP gScrollAction;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210 ControlActionUPP gScrollDrag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
212 /* Keeping track of which scrollbar is being dragged */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 static ControlHandle dragged_sb = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
215 #if defined(USE_CARBONIZED) && defined(MACOS_X)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
216 static struct
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
217 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
218 FMFontFamily family;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
219 FMFontSize size;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
220 FMFontStyle style;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
221 Boolean isPanelVisible;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
222 } gFontPanelInfo = { 0, 0, 0, false };
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
223 #endif
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
224
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
225 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
226 # define USE_ATSUI_DRAWING
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
227 ATSUStyle gFontStyle;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
228 Boolean gIsFontFallbackSet;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
229 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
230
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 * The Quickdraw global is predefined in CodeWarior
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 * but is not in Apple MPW
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
235 #if (defined(__MRC__) || defined(__SC__))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 # if !(defined(TARGET_API_MAC_CARBON) && TARGET_API_MAC_CARBON)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 QDGlobals qd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
241 /* Colors Macros */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
242 #define RGB(r,g,b) ((r) << 16) + ((g) << 8) + (b)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243 #define Red(c) ((c & 0x00FF0000) >> 16)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
244 #define Green(c) ((c & 0x0000FF00) >> 8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245 #define Blue(c) ((c & 0x000000FF) >> 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
247 /* Key mapping */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 #define vk_Esc 0x35 /* -> 1B */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 #define vk_F1 0x7A /* -> 10 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 #define vk_F2 0x78 /*0x63*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253 #define vk_F3 0x63 /*0x76*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
254 #define vk_F4 0x76 /*0x60*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 #define vk_F5 0x60 /*0x61*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 #define vk_F6 0x61 /*0x62*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
257 #define vk_F7 0x62 /*0x63*/ /*?*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
258 #define vk_F8 0x64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 #define vk_F9 0x65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 #define vk_F10 0x6D
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 #define vk_F11 0x67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 #define vk_F12 0x6F
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
263 #define vk_F13 0x69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 #define vk_F14 0x6B
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265 #define vk_F15 0x71
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
267 #define vk_Clr 0x47 /* -> 1B (ESC) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 #define vk_Enter 0x4C /* -> 03 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270 #define vk_Space 0x31 /* -> 20 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
271 #define vk_Tab 0x30 /* -> 09 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
272 #define vk_Return 0x24 /* -> 0D */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
273 /* This is wrong for OSX, what is it for? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
274 #define vk_Delete 0X08 /* -> 08 BackSpace */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276 #define vk_Help 0x72 /* -> 05 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 #define vk_Home 0x73 /* -> 01 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 #define vk_PageUp 0x74 /* -> 0D */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 #define vk_FwdDelete 0x75 /* -> 7F */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 #define vk_End 0x77 /* -> 04 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
281 #define vk_PageDown 0x79 /* -> 0C */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 #define vk_Up 0x7E /* -> 1E */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 #define vk_Down 0x7D /* -> 1F */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 #define vk_Left 0x7B /* -> 1C */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 #define vk_Right 0x7C /* -> 1D */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 #define vk_Undo vk_F1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289 #define vk_Cut vk_F2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
290 #define vk_Copy vk_F3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
291 #define vk_Paste vk_F4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
292 #define vk_PrintScreen vk_F13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
293 #define vk_SCrollLock vk_F14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 #define vk_Pause vk_F15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 #define vk_NumLock vk_Clr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 #define vk_Insert vk_Help
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 #define KeySym char
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 static struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302 KeySym key_sym;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 char_u vim_code0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 char_u vim_code1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305 } special_keys[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 {vk_Up, 'k', 'u'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 {vk_Down, 'k', 'd'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 {vk_Left, 'k', 'l'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 {vk_Right, 'k', 'r'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
312 {vk_F1, 'k', '1'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313 {vk_F2, 'k', '2'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 {vk_F3, 'k', '3'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315 {vk_F4, 'k', '4'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 {vk_F5, 'k', '5'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 {vk_F6, 'k', '6'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 {vk_F7, 'k', '7'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
319 {vk_F8, 'k', '8'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 {vk_F9, 'k', '9'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
321 {vk_F10, 'k', ';'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323 {vk_F11, 'F', '1'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 {vk_F12, 'F', '2'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 {vk_F13, 'F', '3'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 {vk_F14, 'F', '4'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 {vk_F15, 'F', '5'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 /* {XK_Help, '%', '1'}, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 /* {XK_Undo, '&', '8'}, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 /* {XK_BackSpace, 'k', 'b'}, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
332 #ifndef MACOS_X
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 {vk_Delete, 'k', 'b'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
334 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 {vk_Insert, 'k', 'I'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 {vk_FwdDelete, 'k', 'D'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 {vk_Home, 'k', 'h'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
338 {vk_End, '@', '7'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
339 /* {XK_Prior, 'k', 'P'}, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 /* {XK_Next, 'k', 'N'}, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 /* {XK_Print, '%', '9'}, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 {vk_PageUp, 'k', 'P'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 {vk_PageDown, 'k', 'N'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
345
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
346 /* End of list marker: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 {(KeySym)0, 0, 0}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
348 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 * Forward declaration (for those needed)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
356 #ifdef USE_AEVENT
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
357 OSErr HandleUnusedParms(const AppleEvent *theAEvent);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
360 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 * Conversion Utility
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
365
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 * C2Pascal_save
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369 * Allocate memory and convert the C-String passed in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 * into a pascal string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
371 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
372 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
373
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
374 char_u *C2Pascal_save(char_u *Cstring)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 char_u *PascalString;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 if (Cstring == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
382 len = STRLEN(Cstring);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 if (len > 255) /* Truncate if necessary */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385 len = 255;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
387 PascalString = alloc(len + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
388 if (PascalString != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 mch_memmove(PascalString + 1, Cstring, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 PascalString[0] = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
393
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
394 return PascalString;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
396
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
397 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 * C2Pascal_save_and_remove_backslash
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 * Allocate memory and convert the C-String passed in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 * into a pascal string. Also remove the backslash at the same time
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
404
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 char_u *C2Pascal_save_and_remove_backslash(char_u *Cstring)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 char_u *PascalString;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
408 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 char_u *p, *c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 len = STRLEN(Cstring);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413 if (len > 255) /* Truncate if necessary */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 len = 255;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 PascalString = alloc(len + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
417 if (PascalString != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 for (c = Cstring, p = PascalString+1, len = 0; (*c != 0) && (len < 255); c++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
420 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 if ((*c == '\\') && (c[1] != 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 c++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425 *p = *c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
427 len++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
428 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 PascalString[0] = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 return PascalString;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
434
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436 * Convert the modifiers of an Event into vim's modifiers (mouse)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 int_u
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 EventModifiers2VimMouseModifiers(EventModifiers macModifiers)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 int_u vimModifiers = 0x00;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444 if (macModifiers & (shiftKey | rightShiftKey))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
445 vimModifiers |= MOUSE_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446 if (macModifiers & (controlKey | rightControlKey))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 vimModifiers |= MOUSE_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448 if (macModifiers & (optionKey | rightOptionKey))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
449 vimModifiers |= MOUSE_ALT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
450 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451 /* Not yet supported */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
452 if (macModifiers & (cmdKey)) /* There's no rightCmdKey */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
453 vimModifiers |= MOUSE_CMD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
454 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455 return (vimModifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
456 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
457
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 * Convert the modifiers of an Event into vim's modifiers (keys)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 static int_u
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 EventModifiers2VimModifiers(EventModifiers macModifiers)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
464 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
465 int_u vimModifiers = 0x00;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
466
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 if (macModifiers & (shiftKey | rightShiftKey))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
468 vimModifiers |= MOD_MASK_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
469 if (macModifiers & (controlKey | rightControlKey))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
470 vimModifiers |= MOD_MASK_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 if (macModifiers & (optionKey | rightOptionKey))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
472 vimModifiers |= MOD_MASK_ALT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
473 #ifdef USE_CMD_KEY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 if (macModifiers & (cmdKey)) /* There's no rightCmdKey */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 vimModifiers |= MOD_MASK_CMD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
477 return (vimModifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
479
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 /* Convert a string representing a point size into pixels. The string should
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 * be a positive decimal number, with an optional decimal point (eg, "12", or
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
482 * "10.5"). The pixel value is returned, and a pointer to the next unconverted
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 * character is stored in *end. The flag "vertical" says whether this
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 * calculation is for a vertical (height) size or a horizontal (width) one.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
486 * From gui_w48.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
487 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
488 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
489 points_to_pixels(char_u *str, char_u **end, int vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
491 int pixels;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
492 int points = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 int divisor = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 while (*str)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
496 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
497 if (*str == '.' && divisor == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 /* Start keeping a divisor, for later */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 divisor = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
503
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 if (!isdigit(*str))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
505 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
507 points *= 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 points += *str - '0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509 divisor *= 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
510
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
511 ++str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
513
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
514 if (divisor == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 divisor = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
516
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
517 pixels = points/divisor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 *end = str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 return pixels;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
521
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
522 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
523 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
524 * Deletes all traces of any Windows-style mnemonic text (including any
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
525 * parentheses) from a menu item and returns the cleaned menu item title.
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
526 * The caller is responsible for releasing the returned string.
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
527 */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
528 static CFStringRef
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
529 menu_title_removing_mnemonic(menu)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
530 vimmenu_T *menu;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
531 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
532 CFStringRef name;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
533 size_t menuTitleLen;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
534 CFIndex displayLen;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
535 CFRange mnemonicStart;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
536 CFRange mnemonicEnd;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
537 CFMutableStringRef cleanedName;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
538
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
539 menuTitleLen = STRLEN(menu->dname);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
540 name = mac_enc_to_cfstring(menu->dname, menuTitleLen);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
541
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
542 if (name)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
543 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
544 /* Simple mnemonic-removal algorithm, assumes single parenthesized
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
545 * mnemonic character towards the end of the menu text */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
546 mnemonicStart = CFStringFind(name, CFSTR("("), kCFCompareBackwards);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
547 displayLen = CFStringGetLength(name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
548
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
549 if (mnemonicStart.location != kCFNotFound
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
550 && (mnemonicStart.location + 2) < displayLen
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
551 && CFStringGetCharacterAtIndex(name,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
552 mnemonicStart.location + 1) == (UniChar)menu->mnemonic)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
553 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
554 if (CFStringFindWithOptions(name, CFSTR(")"),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
555 CFRangeMake(mnemonicStart.location + 1,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
556 displayLen - mnemonicStart.location - 1),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
557 kCFCompareBackwards, &mnemonicEnd) &&
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
558 (mnemonicStart.location + 2) == mnemonicEnd.location)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
559 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
560 cleanedName = CFStringCreateMutableCopy(NULL, 0, name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
561 if (cleanedName)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
562 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
563 CFStringDelete(cleanedName,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
564 CFRangeMake(mnemonicStart.location,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
565 mnemonicEnd.location + 1 -
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
566 mnemonicStart.location));
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
567
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
568 CFRelease(name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
569 name = cleanedName;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
570 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
571 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
572 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
573 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
574
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
575 return name;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
576 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
577 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
578
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
580 * Convert a list of FSSpec aliases into a list of fullpathname
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
581 * character strings.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 char_u **new_fnames_from_AEDesc(AEDesc *theList, long *numFiles, OSErr *error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 char_u **fnames = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587 OSErr newError;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
588 long fileCount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 FSSpec fileToOpen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 long actualSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
591 AEKeyword dummyKeyword;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
592 DescType dummyType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 /* Get number of files in list */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 *error = AECountItems(theList, numFiles);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 if (*error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
599 printf("fname_from_AEDesc: AECountItems error: %d\n", error);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 return(fnames);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 /* Allocate the pointer list */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605 fnames = (char_u **) alloc(*numFiles * sizeof(char_u *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 /* Empty out the list */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
608 for (fileCount = 0; fileCount < *numFiles; fileCount++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 fnames[fileCount] = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 /* Scan the list of FSSpec */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612 for (fileCount = 1; fileCount <= *numFiles; fileCount++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
613 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 /* Get the alias for the nth file, convert to an FSSpec */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
615 newError = AEGetNthPtr(theList, fileCount, typeFSS,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
616 &dummyKeyword, &dummyType,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 (Ptr) &fileToOpen, sizeof(FSSpec), &actualSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 if (newError)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
620 /* Caller is able to clean up */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 /* TODO: Should be clean up or not? For safety. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622 #ifdef USE_SIOUX
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
623 printf("aevt_odoc: AEGetNthPtr error: %ld\n", (long)newError);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
624 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 return(fnames);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 /* Convert the FSSpec to a pathname */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
629 fnames[fileCount - 1] = FullPathFromFSSpec_save(fileToOpen);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
631
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
632 return (fnames);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
633 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
634
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 * CodeWarrior External Editor Support
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 #ifdef FEAT_CW_EDITOR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
643 * Handle the Window Search event from CodeWarrior
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
645 * Description
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
646 * -----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648 * The IDE sends the Window Search AppleEvent to the editor when it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
649 * needs to know whether a particular file is open in the editor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
651 * Event Reply
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 * -----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
653 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 * None. Put data in the location specified in the structure received.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 * Remarks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 * -------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 * When the editor receives this event, determine whether the specified
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
660 * file is open. If it is, return the modification date/time for that file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 * in the appropriate location specified in the structure. If the file is
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
662 * not opened, put the value fnfErr(file not found) in that location.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
663 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
666 #if defined(__MWERKS__) /* only in Codewarrior */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 # pragma options align=mac68k
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 typedef struct WindowSearch WindowSearch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670 struct WindowSearch /* for handling class 'KAHL', event 'SRCH', keyDirectObject typeChar*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
671 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 FSSpec theFile; // identifies the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673 long *theDate; // where to put the modification date/time
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
674 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
675 #if defined(__MWERKS__) /* only in Codewarrior */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 # pragma options align=reset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
678
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
679 pascal OSErr
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
680 Handle_KAHL_SRCH_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
682 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
683 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 int foundFile = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 DescType typeCode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686 WindowSearch SearchData;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
687 Size actualSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
688
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
689 error = AEGetParamPtr(theAEvent, keyDirectObject, typeChar, &typeCode, (Ptr) &SearchData, sizeof(WindowSearch), &actualSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
693 printf("KAHL_SRCH: AEGetParamPtr error: %d\n", error);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
696 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
698 error = HandleUnusedParms(theAEvent);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
699 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
700 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
701 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
702 printf("KAHL_SRCH: HandleUnusedParms error: %d\n", error);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
703 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
705 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
707 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
708 if (buf->b_ml.ml_mfp != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
709 && SearchData.theFile.parID == buf->b_FSSpec.parID
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
710 && SearchData.theFile.name[0] == buf->b_FSSpec.name[0]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 && STRNCMP(SearchData.theFile.name, buf->b_FSSpec.name, buf->b_FSSpec.name[0] + 1) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 foundFile = true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
714 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
715 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
717 if (foundFile == false)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 *SearchData.theDate = fnfErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 *SearchData.theDate = buf->b_mtime;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
721
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
723 printf("KAHL_SRCH: file \"%#s\" {%d}", SearchData.theFile.name,SearchData.theFile.parID);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 if (foundFile == false)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
725 printf(" NOT");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
726 printf(" found. [date %lx, %lx]\n", *SearchData.theDate, buf->b_mtime_read);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
727 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
730 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
731
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733 * Handle the Modified (from IDE to Editor) event from CodeWarrior
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 * Description
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
736 * -----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 * The IDE sends this event to the external editor when it wants to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 * know which files that are open in the editor have been modified.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 * Parameters None.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 * ----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 * Event Reply
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745 * -----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
746 * The reply for this event is:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
747 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748 * keyDirectObject typeAEList required
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 * each element in the list is a structure of typeChar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
750 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
751 * Remarks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 * -------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
754 * When building the reply event, include one element in the list for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 * each open file that has been modified.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 #if defined(__MWERKS__) /* only in Codewarrior */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
760 # pragma options align=mac68k
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 typedef struct ModificationInfo ModificationInfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 struct ModificationInfo /* for replying to class 'KAHL', event 'MOD ', keyDirectObject typeAEList*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
764 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 FSSpec theFile; // identifies the file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 long theDate; // the date/time the file was last modified
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 short saved; // set this to zero when replying, unused
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
769 #if defined(__MWERKS__) /* only in Codewarrior */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 # pragma options align=reset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
772
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
773 pascal OSErr
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
774 Handle_KAHL_MOD_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 AEDescList replyList;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 long numFiles;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
779 ModificationInfo theFile;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
781
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 theFile.saved = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
784 error = HandleUnusedParms(theAEvent);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
785 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
786 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
788 printf("KAHL_MOD: HandleUnusedParms error: %d\n", error);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
789 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
792
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
793 /* Send the reply */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
794 /* replyObject.descriptorType = typeNull;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 replyObject.dataHandle = nil;*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
796
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 /* AECreateDesc(typeChar, (Ptr)&title[1], title[0], &data) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
798 error = AECreateList(nil, 0, false, &replyList);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
801 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
802 printf("KAHL_MOD: AECreateList error: %d\n", error);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
803 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
806
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
807 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
808 error = AECountItems(&replyList, &numFiles);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
810 printf("KAHL_MOD ReplyList: %x %x\n", replyList.descriptorType, replyList.dataHandle);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
811 printf("KAHL_MOD ItemInList: %d\n", numFiles);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
812 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
813
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
814 /* AEPutKeyDesc(&replyList, keyAEPnject, &aDesc)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
815 * AEPutKeyPtr(&replyList, keyAEPosition, typeChar, (Ptr)&theType,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
816 * sizeof(DescType))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 /* AEPutDesc */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 numFiles = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
823 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 if (buf->b_ml.ml_mfp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
825 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
826 /* Add this file to the list */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 theFile.theFile = buf->b_FSSpec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828 theFile.theDate = buf->b_mtime;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
829 /* theFile.theDate = time(NULL) & (time_t) 0xFFFFFFF0; */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
830 error = AEPutPtr(&replyList, numFiles, typeChar, (Ptr) &theFile, sizeof(theFile));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 #ifdef USE_SIOUX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 if (numFiles == 0)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
833 printf("KAHL_MOD: ");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
834 else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
835 printf(", ");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
836 printf("\"%#s\" {%d} [date %lx, %lx]", theFile.theFile.name, theFile.theFile.parID, theFile.theDate, buf->b_mtime_read);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 if (error)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
838 printf(" (%d)", error);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 numFiles++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
840 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
841 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
842
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
843 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
844 printf("\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
845 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
846
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
847 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
848 error = AECountItems(&replyList, &numFiles);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
849 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
850 printf("KAHL_MOD ItemInList: %d\n", numFiles);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
854 /* We can add data only if something to reply */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
855 error = AEPutParamDesc(theReply, keyDirectObject, &replyList);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 #ifdef USE_SIOUX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
858 if (error)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
859 printf("KAHL_MOD: AEPutParamDesc error: %d\n", error);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 if (replyList.dataHandle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
863 AEDisposeDesc(&replyList);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
868 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
869 * Handle the Get Text event from CodeWarrior
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871 * Description
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
872 * -----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 * The IDE sends the Get Text AppleEvent to the editor when it needs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875 * the source code from a file. For example, when the user issues a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
876 * Check Syntax or Compile command, the compiler needs access to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
877 * the source code contained in the file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 * Event Reply
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
880 * -----------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882 * None. Put data in locations specified in the structure received.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
884 * Remarks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 * -------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 * When the editor receives this event, it must set the size of the handle
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 * in theText to fit the data in the file. It must then copy the entire
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889 * contents of the specified file into the memory location specified in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
890 * theText.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
894 #if defined(__MWERKS__) /* only in Codewarrior */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
895 # pragma options align=mac68k
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
896 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
897 typedef struct CW_GetText CW_GetText;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 struct CW_GetText /* for handling class 'KAHL', event 'GTTX', keyDirectObject typeChar*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
899 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
900 FSSpec theFile; /* identifies the file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
901 Handle theText; /* the location where you return the text (must be resized properly) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
902 long *unused; /* 0 (not used) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 long *theDate; /* where to put the modification date/time */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
904 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
905 #if defined(__MWERKS__) /* only in Codewarrior */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 # pragma options align=reset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
909 pascal OSErr
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
910 Handle_KAHL_GTTX_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 buf_T *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
914 int foundFile = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 DescType typeCode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 CW_GetText GetTextData;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 Size actualSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918 char_u *line;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
919 char_u *fullbuffer = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 long linesize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 long lineStart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
922 long BufferSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 long lineno;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
924
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
925 error = AEGetParamPtr(theAEvent, keyDirectObject, typeChar, &typeCode, (Ptr) &GetTextData, sizeof(GetTextData), &actualSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
926
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
929 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
930 printf("KAHL_GTTX: AEGetParamPtr error: %d\n", error);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 for (buf = firstbuf; buf != NULL; buf = buf->b_next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 if (buf->b_ml.ml_mfp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
937 if (GetTextData.theFile.parID == buf->b_FSSpec.parID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 foundFile = true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
943 if (foundFile)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
944 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
945 BufferSize = 0; /* GetHandleSize(GetTextData.theText); */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
946 for (lineno = 0; lineno <= buf->b_ml.ml_line_count; lineno++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
947 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948 /* Must use the right buffer */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 line = ml_get_buf(buf, (linenr_T) lineno, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 linesize = STRLEN(line) + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951 lineStart = BufferSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 BufferSize += linesize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 /* Resize handle to linesize+1 to include the linefeed */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
954 SetHandleSize(GetTextData.theText, BufferSize);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
955 if (GetHandleSize(GetTextData.theText) != BufferSize)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
958 printf("KAHL_GTTX: SetHandleSize increase: %d, size %d\n",
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
959 linesize, BufferSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
960 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
961 break; /* Simple handling for now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
963 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
965 HLock(GetTextData.theText);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966 fullbuffer = (char_u *) *GetTextData.theText;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
967 STRCPY((char_u *)(fullbuffer + lineStart), line);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 fullbuffer[BufferSize-1] = '\r';
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
969 HUnlock(GetTextData.theText);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
970 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
971 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 if (fullbuffer != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
974 HLock(GetTextData.theText);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 fullbuffer[BufferSize-1] = 0;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
976 HUnlock(GetTextData.theText);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
977 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
978 if (foundFile == false)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 *GetTextData.theDate = fnfErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
981 /* *GetTextData.theDate = time(NULL) & (time_t) 0xFFFFFFF0;*/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 *GetTextData.theDate = buf->b_mtime;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
985 printf("KAHL_GTTX: file \"%#s\" {%d} [date %lx, %lx]", GetTextData.theFile.name, GetTextData.theFile.parID, *GetTextData.theDate, buf->b_mtime_read);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 if (foundFile == false)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
987 printf(" NOT");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
988 printf(" found. (BufferSize = %d)\n", BufferSize);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
989 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
990
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
991 error = HandleUnusedParms(theAEvent);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
992 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
993 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
995 printf("KAHL_GTTX: HandleUnusedParms error: %d\n", error);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
997 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
998 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
999
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1000 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1006
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 /* Taken from MoreAppleEvents:ProcessHelpers*/
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1008 pascal OSErr FindProcessBySignature(const OSType targetType,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 const OSType targetCreator,
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1010 ProcessSerialNumberPtr psnPtr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1011 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1012 OSErr anErr = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 Boolean lookingForProcess = true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1014
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1015 ProcessInfoRec infoRec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1017 infoRec.processInfoLength = sizeof(ProcessInfoRec);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1018 infoRec.processName = nil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1019 infoRec.processAppSpec = nil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1021 psnPtr->lowLongOfPSN = kNoProcess;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 psnPtr->highLongOfPSN = kNoProcess;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1024 while (lookingForProcess)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1026 anErr = GetNextProcess(psnPtr);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1027 if (anErr != noErr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1028 lookingForProcess = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1029 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1031 anErr = GetProcessInformation(psnPtr, &infoRec);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1032 if ((anErr == noErr)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1033 && (infoRec.processType == targetType)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1034 && (infoRec.processSignature == targetCreator))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 lookingForProcess = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1036 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1037 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1038
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1039 return anErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 }//end FindProcessBySignature
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1042 void
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1043 Send_KAHL_MOD_AE(buf_T *buf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1044 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1045 OSErr anErr = noErr;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1046 AEDesc targetAppDesc = { typeNull, nil };
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 ProcessSerialNumber psn = { kNoProcess, kNoProcess };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 AppleEvent theReply = { typeNull, nil };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 AESendMode sendMode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1050 AppleEvent theEvent = {typeNull, nil };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 AEIdleUPP idleProcUPP = nil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 ModificationInfo ModData;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1054
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1055 anErr = FindProcessBySignature('APPL', 'CWIE', &psn);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1057 printf("CodeWarrior is");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 if (anErr != noErr)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1059 printf(" NOT");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1060 printf(" running\n");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1061 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1062 if (anErr == noErr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1064 anErr = AECreateDesc(typeProcessSerialNumber, &psn,
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1065 sizeof(ProcessSerialNumber), &targetAppDesc);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1066
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1067 if (anErr == noErr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 anErr = AECreateAppleEvent( 'KAHL', 'MOD ', &targetAppDesc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1070 kAutoGenerateReturnID, kAnyTransactionID, &theEvent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1071 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1073 AEDisposeDesc(&targetAppDesc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1074
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 /* Add the parms */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076 ModData.theFile = buf->b_FSSpec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1077 ModData.theDate = buf->b_mtime;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 if (anErr == noErr)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1080 anErr = AEPutParamPtr(&theEvent, keyDirectObject, typeChar, &ModData, sizeof(ModData));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1081
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1082 if (idleProcUPP == nil)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 sendMode = kAENoReply;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085 sendMode = kAEWaitReply;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1087 if (anErr == noErr)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1088 anErr = AESend(&theEvent, &theReply, sendMode, kAENormalPriority, kNoTimeOut, idleProcUPP, nil);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1089 if (anErr == noErr && sendMode == kAEWaitReply)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1092 printf("KAHL_MOD: Send error: %d\n", anErr);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1093 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1094 /* anErr = AEHGetHandlerError(&theReply);*/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1096 (void) AEDisposeDesc(&theReply);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1098 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 #endif /* FEAT_CW_EDITOR */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1102 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 * Apple Event Handling procedure
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1105 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106 #ifdef USE_AEVENT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1108 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 * Handle the Unused parms of an AppleEvent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1110 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1112 OSErr
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1113 HandleUnusedParms(const AppleEvent *theAEvent)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 OSErr error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 long actualSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 DescType dummyType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118 AEKeyword missedKeyword;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 /* Get the "missed keyword" attribute from the AppleEvent. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121 error = AEGetAttributePtr(theAEvent, keyMissedKeywordAttr,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1122 typeKeyword, &dummyType,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1123 (Ptr)&missedKeyword, sizeof(missedKeyword),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1124 &actualSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1126 /* If the descriptor isn't found, then we got the required parameters. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1127 if (error == errAEDescNotFound)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1129 error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1132 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1133 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1134 /* Why is this removed? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1135 error = errAEEventNotHandled;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1136 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1137 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1138
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1139 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1142
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1143 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144 * Handle the ODoc AppleEvent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1146 * Deals with all files dragged to the application icon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1147 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1148 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 #if defined(__MWERKS__) /* only in Codewarrior */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1151 # pragma options align=mac68k
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1152 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1153 typedef struct SelectionRange SelectionRange;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1154 struct SelectionRange /* for handling kCoreClassEvent:kOpenDocuments:keyAEPosition typeChar */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1155 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1156 short unused1; // 0 (not used)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157 short lineNum; // line to select (<0 to specify range)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1158 long startRange; // start of selection range (if line < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1159 long endRange; // end of selection range (if line < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 long unused2; // 0 (not used)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1161 long theDate; // modification date/time
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1162 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1163 #if defined(__MWERKS__) /* only in Codewarrior */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1164 # pragma options align=reset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1165 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1167 /* The IDE uses the optional keyAEPosition parameter to tell the ed-
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1168 itor the selection range. If lineNum is zero or greater, scroll the text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1169 to the specified line. If lineNum is less than zero, use the values in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1170 startRange and endRange to select the specified characters. Scroll
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171 the text to display the selection. If lineNum, startRange, and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1172 endRange are all negative, there is no selection range specified.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1175 pascal OSErr
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1176 HandleODocAE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1178 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1179 * TODO: Clean up the code with convert the AppleEvent into
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 * a ":args"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 // OSErr firstError = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1184 // short numErrors = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1185 AEDesc theList;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 DescType typeCode;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1187 long numFiles;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1188 // long fileCount;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 char_u **fnames;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190 // char_u fname[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1191 Size actualSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1192 SelectionRange thePosition;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1193 short gotPosition = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194 long lnum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1196 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1197 printf("aevt_odoc:\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1199
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1200 /* the direct object parameter is the list of aliases to files (one or more) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1201 error = AEGetParamDesc(theAEvent, keyDirectObject, typeAEList, &theList);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1202 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1203 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1204 #ifdef USE_SIOUX
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1205 printf("aevt_odoc: AEGetParamDesc error: %ld\n", (long)error);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1209
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211 error = AEGetParamPtr(theAEvent, keyAEPosition, typeChar, &typeCode, (Ptr) &thePosition, sizeof(SelectionRange), &actualSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 if (error == noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 gotPosition = true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 if (error == errAEDescNotFound)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1216 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1217 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1218 #ifdef USE_SIOUX
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1219 printf("aevt_odoc: AEGetParamPtr error: %ld\n", (long)error);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1220 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1221 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1222 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1224 #ifdef USE_SIOUX
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1225 printf("aevt_odoc: lineNum: %d, startRange %ld, endRange %ld, [date %lx]\n",
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1226 (int)thePosition.lineNum,
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1227 (long)thePosition.startRange, (long)thePosition.endRange,
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1228 (long)thePosition.theDate);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1231 error = AEGetParamDesc(theAEvent, keyAEPosition, typeChar, &thePosition);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1232
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1233 if (^error) then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1234 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1235 if (thePosition.lineNum >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1236 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1237 // Goto this line
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1239 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1240 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241 // Set the range char wise
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1244 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1245
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 #ifdef FEAT_VISUAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1248 reset_VIsual();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1250
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1251 fnames = new_fnames_from_AEDesc(&theList, &numFiles, &error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1252
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 /* TODO: empty fnames[] first */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256 vim_free(fnames);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1257 return (error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1258 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1260 if (starting > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1261 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 /* these are the initial files dropped on the Vim icon */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266 for (i = 0 ; i < numFiles; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1267 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1268 if (ga_grow(&global_alist.al_ga, 1) == FAIL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1269 || (p = vim_strsave(fnames[i])) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1270 mch_exit(2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1271 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272 alist_add(&global_alist, p, 2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 goto finished;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 /* Handle the drop, :edit to get to the file */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 handle_drop(numFiles, fnames, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 /* TODO: Handle the goto/select line more cleanly */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281 if ((numFiles == 1) & (gotPosition))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1282 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 if (thePosition.lineNum >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284 {
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1285 lnum = thePosition.lineNum + 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 /* oap->motion_type = MLINE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 setpcmark();*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1288 if (lnum < 1L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 lnum = 1L;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290 else if (lnum > curbuf->b_ml.ml_line_count)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 lnum = curbuf->b_ml.ml_line_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 curwin->w_cursor.lnum = lnum;
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1293 curwin->w_cursor.col = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 /* beginline(BL_SOL | BL_FIX);*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 goto_byte(thePosition.startRange + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 /* Update the screen display */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 update_screen(NOT_VALID);
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1302 #ifdef FEAT_VISUAL
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1303 /* Select the text if possible */
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1304 if (gotPosition)
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1305 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1306 VIsual_active = TRUE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1307 VIsual_select = FALSE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1308 VIsual = curwin->w_cursor;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1309 if (thePosition.lineNum < 0)
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1310 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1311 VIsual_mode = 'v';
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1312 goto_byte(thePosition.endRange);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1313 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1314 else
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1315 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1316 VIsual_mode = 'V';
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1317 VIsual.col = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1318 }
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1319 }
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1320 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1321 setcursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1324 /* Fake mouse event to wake from stall */
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1325 PostEvent(mouseUp, 0);
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1326
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1327 finished:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1328 AEDisposeDesc(&theList); /* dispose what we allocated */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1329
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1330 error = HandleUnusedParms(theAEvent);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1331 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1333 #ifdef USE_SIOUX
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
1334 printf("aevt_odoc: HandleUnusedParms error: %ld\n", (long)error);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1336 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1344
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1345 pascal OSErr
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1346 Handle_aevt_oapp_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1351 printf("aevt_oapp:\n");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1352 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1353
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1354 error = HandleUnusedParms(theAEvent);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1355 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1356 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1357 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1358 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1361 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1363 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1364 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1366
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1367 pascal OSErr
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1368 Handle_aevt_quit_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1371
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1373 printf("aevt_quit\n");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1374 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1375
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1376 error = HandleUnusedParms(theAEvent);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 /* Need to fake a :confirm qa */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 do_cmdline_cmd((char_u *)"confirm qa");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1392 pascal OSErr
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1393 Handle_aevt_pdoc_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1397 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1398 printf("aevt_pdoc:\n");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1399 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1400
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1401 error = HandleUnusedParms(theAEvent);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1402 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1404 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1409
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1410 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 * Handling of unknown AppleEvent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1412 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 * (Just get rid of all the parms)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1415 pascal OSErr
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1416 Handle_unknown_AE(const AppleEvent *theAEvent, AppleEvent *theReply, long refCon)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1417 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 OSErr error = noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420 #ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1421 printf("Unknown Event: %x\n", theAEvent->descriptorType);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1422 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1423
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1424 error = HandleUnusedParms(theAEvent);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1425 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1426 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1429
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 return(error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 #if TARGET_API_MAC_CARBON
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 # define NewAEEventHandlerProc(x) NewAEEventHandlerUPP(x)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1440 * Install the various AppleEvent Handlers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1441 */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1442 OSErr
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1443 InstallAEHandlers(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1444 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1445 OSErr error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1447 /* install open application handler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 error = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 NewAEEventHandlerProc(Handle_aevt_oapp_AE), 0, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1451 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1452 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1455 /* install quit application handler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1456 error = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457 NewAEEventHandlerProc(Handle_aevt_quit_AE), 0, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1460 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1462
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1463 /* install open document handler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1464 error = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 NewAEEventHandlerProc(HandleODocAE), 0, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1467 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1469 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471 /* install print document handler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 error = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1473 NewAEEventHandlerProc(Handle_aevt_pdoc_AE), 0, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1475 /* Install Core Suite */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1476 /* error = AEInstallEventHandler(kAECoreSuite, kAEClone,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1477 NewAEEventHandlerProc(Handle_unknown_AE), nil, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479 error = AEInstallEventHandler(kAECoreSuite, kAEClose,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 NewAEEventHandlerProc(Handle_unknown_AE), nil, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1481
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 error = AEInstallEventHandler(kAECoreSuite, kAECountElements,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 NewAEEventHandlerProc(Handle_unknown_AE), nil, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1485 error = AEInstallEventHandler(kAECoreSuite, kAECreateElement,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1486 NewAEEventHandlerProc(Handle_unknown_AE), nil, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1488 error = AEInstallEventHandler(kAECoreSuite, kAEDelete,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1489 NewAEEventHandlerProc(Handle_unknown_AE), nil, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1491 error = AEInstallEventHandler(kAECoreSuite, kAEDoObjectsExist,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 NewAEEventHandlerProc(Handle_unknown_AE), nil, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 error = AEInstallEventHandler(kAECoreSuite, kAEGetData,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 NewAEEventHandlerProc(Handle_unknown_AE), kAEGetData, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 error = AEInstallEventHandler(kAECoreSuite, kAEGetDataSize,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498 NewAEEventHandlerProc(Handle_unknown_AE), kAEGetDataSize, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 error = AEInstallEventHandler(kAECoreSuite, kAEGetClassInfo,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1501 NewAEEventHandlerProc(Handle_unknown_AE), nil, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1502
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 error = AEInstallEventHandler(kAECoreSuite, kAEGetEventInfo,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 NewAEEventHandlerProc(Handle_unknown_AE), nil, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 error = AEInstallEventHandler(kAECoreSuite, kAEMove,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507 NewAEEventHandlerProc(Handle_unknown_AE), nil, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 error = AEInstallEventHandler(kAECoreSuite, kAESave,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 NewAEEventHandlerProc(Handle_unknown_AE), nil, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1512 error = AEInstallEventHandler(kAECoreSuite, kAESetData,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1513 NewAEEventHandlerProc(Handle_unknown_AE), nil, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516 #ifdef FEAT_CW_EDITOR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1517 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1518 * Bind codewarrior support handlers
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1520 error = AEInstallEventHandler('KAHL', 'GTTX',
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 NewAEEventHandlerProc(Handle_KAHL_GTTX_AE), 0, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1523 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1524 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 error = AEInstallEventHandler('KAHL', 'SRCH',
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1527 NewAEEventHandlerProc(Handle_KAHL_SRCH_AE), 0, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1531 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 error = AEInstallEventHandler('KAHL', 'MOD ',
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533 NewAEEventHandlerProc(Handle_KAHL_MOD_AE), 0, false);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1534 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1535 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1536 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1538 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 return error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 #endif /* USE_AEVENT */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1545
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1546 #if defined(USE_CARBONIZED) && defined(MACOS_X)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1547 /*
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1548 * Callback function, installed by InstallFontPanelHandler(), below,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1549 * to handle Font Panel events.
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1550 */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1551 static OSStatus
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1552 FontPanelHandler(EventHandlerCallRef inHandlerCallRef, EventRef inEvent,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1553 void *inUserData)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1554 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1555 if (GetEventKind(inEvent) == kEventFontPanelClosed)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1556 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1557 gFontPanelInfo.isPanelVisible = false;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1558 return noErr;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1559 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1560
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1561 if (GetEventKind(inEvent) == kEventFontSelection)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1562 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1563 OSStatus status;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1564 FMFontFamily newFamily;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1565 FMFontSize newSize;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1566 FMFontStyle newStyle;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1567
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1568 /* Retrieve the font family ID number. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1569 status = GetEventParameter(inEvent, kEventParamFMFontFamily,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1570 /*inDesiredType=*/typeFMFontFamily, /*outActualType=*/NULL,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1571 /*inBufferSize=*/sizeof(FMFontFamily), /*outActualSize=*/NULL,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1572 &newFamily);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1573 if (status == noErr)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1574 gFontPanelInfo.family = newFamily;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1575
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1576 /* Retrieve the font size. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1577 status = GetEventParameter(inEvent, kEventParamFMFontSize,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1578 typeFMFontSize, NULL, sizeof(FMFontSize), NULL, &newSize);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1579 if (status == noErr)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1580 gFontPanelInfo.size = newSize;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1581
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1582 /* Retrieve the font style (bold, etc.). Currently unused. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1583 status = GetEventParameter(inEvent, kEventParamFMFontStyle,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1584 typeFMFontStyle, NULL, sizeof(FMFontStyle), NULL, &newStyle);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1585 if (status == noErr)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1586 gFontPanelInfo.style = newStyle;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1587 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1588 return noErr;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1589 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1590
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1591
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1592 static void
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1593 InstallFontPanelHandler()
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1594 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1595 EventTypeSpec eventTypes[2];
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1596 EventHandlerUPP handlerUPP;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1597 /* EventHandlerRef handlerRef; */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1598
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1599 eventTypes[0].eventClass = kEventClassFont;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1600 eventTypes[0].eventKind = kEventFontSelection;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1601 eventTypes[1].eventClass = kEventClassFont;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1602 eventTypes[1].eventKind = kEventFontPanelClosed;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1603
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1604 handlerUPP = NewEventHandlerUPP(FontPanelHandler);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1605
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1606 InstallApplicationEventHandler(handlerUPP, /*numTypes=*/2, eventTypes,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1607 /*userData=*/NULL, /*handlerRef=*/NULL);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1608 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1609
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1610
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1611 /*
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1612 * Fill the buffer pointed to by outName with the name and size
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1613 * of the font currently selected in the Font Panel.
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1614 */
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1615 #define FONT_STYLE_BUFFER_SIZE 32
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1616 static void
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 444
diff changeset
1617 GetFontPanelSelection(char_u *outName)
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1618 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1619 Str255 buf;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1620 ByteCount fontNameLen = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1621 ATSUFontID fid;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1622 char_u styleString[FONT_STYLE_BUFFER_SIZE];
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1623
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1624 if (!outName)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1625 return;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1626
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1627 if (FMGetFontFamilyName(gFontPanelInfo.family, buf) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1628 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1629 /* Canonicalize localized font names */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1630 if (FMGetFontFromFontFamilyInstance(gFontPanelInfo.family,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1631 gFontPanelInfo.style, &fid, NULL) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1632 return;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1633
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1634 /* Request font name with Mac encoding (otherwise we could
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1635 * get an unwanted utf-16 name) */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1636 if (ATSUFindFontName(fid, kFontFullName, kFontMacintoshPlatform,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1637 kFontNoScriptCode, kFontNoLanguageCode,
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 444
diff changeset
1638 255, (char *)outName, &fontNameLen, NULL) != noErr)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1639 return;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1640
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1641 /* Only encode font size, because style (bold, italic, etc) is
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1642 * already part of the font full name */
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 444
diff changeset
1643 vim_snprintf((char *)styleString, FONT_STYLE_BUFFER_SIZE, ":h%d",
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1644 gFontPanelInfo.size/*,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1645 ((gFontPanelInfo.style & bold)!=0 ? ":b" : ""),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1646 ((gFontPanelInfo.style & italic)!=0 ? ":i" : ""),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1647 ((gFontPanelInfo.style & underline)!=0 ? ":u" : "")*/);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1648
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1649 if ((fontNameLen + STRLEN(styleString)) < 255)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1650 STRCPY(outName + fontNameLen, styleString);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1651 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1652 else
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1653 {
501
ce2181d14aa0 updated for version 7.0139
vimboss
parents: 444
diff changeset
1654 *outName = NUL;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
1655 }
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1656 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1657 #endif
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1658
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
1659
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1660 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1661 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1662 * Unfiled yet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1663 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1664 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1665
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1666 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1667 * gui_mac_get_menu_item_index
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1668 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1669 * Returns the index inside the menu wher
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1670 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1671 short /* Shoulde we return MenuItemIndex? */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1672 gui_mac_get_menu_item_index(pMenu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1673 vimmenu_T *pMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1675 short index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1676 short itemIndex = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1677 vimmenu_T *pBrother;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1678
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1679 /* Only menu without parent are the:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 * -menu in the menubar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681 * -popup menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1682 * -toolbar (guess)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1683 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1684 * Which are not items anyway.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1685 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1686 if (pMenu->parent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1687 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1688 /* Start from the Oldest Brother */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1689 pBrother = pMenu->parent->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1690 index = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1691 while ((pBrother) && (itemIndex == -1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1692 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1693 if (pBrother == pMenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1694 itemIndex = index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1695 index++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696 pBrother = pBrother->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1698 #ifdef USE_HELPMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1699 /* Adjust index in help menu (for predefined ones) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1700 if (itemIndex != -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701 if (pMenu->parent->submenu_id == kHMHelpMenuID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 itemIndex += gui.MacOSHelpItems;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1703 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1704 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1705 return itemIndex;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1706 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1707
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1708 static vimmenu_T *
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1709 gui_mac_get_vim_menu(menuID, itemIndex, pMenu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1710 short menuID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1711 short itemIndex;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1712 vimmenu_T *pMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1713 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1714 short index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1715 vimmenu_T *pChildMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1716 vimmenu_T *pElder = pMenu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1717
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1718
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1719 /* Only menu without parent are the:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1720 * -menu in the menubar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1721 * -popup menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1722 * -toolbar (guess)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1723 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1724 * Which are not items anyway.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1725 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1726
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1727 if ((pElder) && (pElder->submenu_id == menuID))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1728 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1729 #ifdef USE_HELPMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1730 if (menuID == kHMHelpMenuID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1731 itemIndex -= gui.MacOSHelpItems;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1732 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1733
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1734 for (index = 1; (index != itemIndex) && (pMenu != NULL); index++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1735 pMenu = pMenu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1736 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1737 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1738 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1739 for (; pMenu != NULL; pMenu = pMenu->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1740 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1741 if (pMenu->children != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1742 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743 pChildMenu = gui_mac_get_vim_menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1744 (menuID, itemIndex, pMenu->children);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1745 if (pChildMenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1747 pMenu = pChildMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1748 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1749 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1750 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1751 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1752 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1753 return pMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1758 * MacOS Feedback procedures
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761 pascal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1762 void
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1763 gui_mac_drag_thumb(ControlHandle theControl, short partCode)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1765 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 int value, dragging;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767 ControlHandle theControlToUse;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 int dont_scroll_save = dont_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 theControlToUse = dragged_sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1772 sb = gui_find_scrollbar((long) GetControlReference(theControlToUse));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1774 if (sb == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1775 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1776
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777 /* Need to find value by diff between Old Poss New Pos */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1778 value = GetControl32BitValue(theControlToUse);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1779 dragging = (partCode != 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1780
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1781 /* When "allow_scrollbar" is FALSE still need to remember the new
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 * position, but don't actually scroll by setting "dont_scroll". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 dont_scroll = !allow_scrollbar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 gui_drag_scrollbar(sb, value, dragging);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 dont_scroll = dont_scroll_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1787
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 pascal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1789 void
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1790 gui_mac_scroll_action(ControlHandle theControl, short partCode)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792 /* TODO: have live support */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793 scrollbar_T *sb, *sb_info;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794 long data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1795 long value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796 int page;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1797 int dragging = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1798 int dont_scroll_save = dont_scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1800 sb = gui_find_scrollbar((long)GetControlReference(theControl));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1802 if (sb == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1803 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1805 if (sb->wp != NULL) /* Left or right scrollbar */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1808 * Careful: need to get scrollbar info out of first (left) scrollbar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1809 * for window, but keep real scrollbar too because we must pass it to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1810 * gui_drag_scrollbar().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1811 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1812 sb_info = &sb->wp->w_scrollbars[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1813
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1814 if (sb_info->size > 5)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1815 page = sb_info->size - 2; /* use two lines of context */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1816 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1817 page = sb_info->size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1819 else /* Bottom scrollbar */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1820 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1821 sb_info = sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1822 page = W_WIDTH(curwin) - 5;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1823 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1824
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1825 switch (partCode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827 case kControlUpButtonPart: data = -1; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1828 case kControlDownButtonPart: data = 1; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1829 case kControlPageDownPart: data = page; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1830 case kControlPageUpPart: data = -page; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1831 default: data = 0; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1832 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1833
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1834 value = sb_info->value + data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1835 /* if (value > sb_info->max)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1836 value = sb_info->max;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1837 else if (value < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1838 value = 0;*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1839
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1840 /* When "allow_scrollbar" is FALSE still need to remember the new
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1841 * position, but don't actually scroll by setting "dont_scroll". */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1842 dont_scroll = !allow_scrollbar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1843 gui_drag_scrollbar(sb, value, dragging);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1844 dont_scroll = dont_scroll_save;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1845
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1846 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1847 gui_mch_set_scrollbar_thumb(sb, value, sb_info->size, sb_info->max);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1848
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1849 /* if (sb_info->wp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1850 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1851 win_T *wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1852 int sb_num;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1854 sb_num = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1855 for (wp = firstwin; wp != sb->wp && wp != NULL; wp = W_NEXT(wp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1856 sb_num++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 if (wp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1859 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860 current_scrollbar = sb_num;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1861 scrollbar_value = value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1862 gui_do_scroll();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863 gui_mch_set_scrollbar_thumb(sb, value, sb_info->size, sb_info->max);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1864 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1865 }*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1866 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1867
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1868 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1869 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 * MacOS Click Handling procedures
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1871 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1872 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1873
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1874
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1875 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1876 * Handle a click inside the window, it may happens in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1877 * scrollbar or the contents.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1878 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1879 * TODO: Add support for potential TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1880 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1881 void
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1882 gui_mac_doInContentClick(theEvent, whichWindow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1883 EventRecord *theEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1884 WindowPtr whichWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1885 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1886 Point thePoint;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1887 int_u vimModifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1888 short thePortion;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1889 ControlHandle theControl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1890 int vimMouseButton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1891 short dblClick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1893 thePoint = theEvent->where;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1894 GlobalToLocal(&thePoint);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1895 SelectWindow(whichWindow);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1896
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1897 thePortion = FindControl(thePoint, whichWindow, &theControl);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899 if (theControl != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1900 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1901 /* We hit a scollbar */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903 if (thePortion != kControlIndicatorPart)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1904 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905 dragged_sb = theControl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1906 TrackControl(theControl, thePoint, gScrollAction);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1907 dragged_sb = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1908 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1909 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1910 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1911 dragged_sb = theControl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1912 #if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 TrackControl(theControl, thePoint, gScrollDrag);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915 TrackControl(theControl, thePoint, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1917 /* pass 0 as the part to tell gui_mac_drag_thumb, that the mouse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 * button has been released */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1919 gui_mac_drag_thumb(theControl, 0); /* Should it be thePortion ? (Dany) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1920 dragged_sb = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1921 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1922 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1923 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1924 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1925 /* We are inside the contents */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1926
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1927 /* Convert the CTRL, OPTION, SHIFT and CMD key */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928 vimModifiers = EventModifiers2VimMouseModifiers(theEvent->modifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1930 /* Defaults to MOUSE_LEFT as there's only one mouse button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1931 vimMouseButton = MOUSE_LEFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1932
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1933 #ifdef USE_CTRLCLICKMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1934 /* Convert the CTRL_MOUSE_LEFT to MOUSE_RIGHT */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1935 clickIsPopup = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1936
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1937 if ((gui.MacOSHaveCntxMenu) && (mouse_model_popup()))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1938 if (IsShowContextualMenuClick(theEvent))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1939 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1940 vimMouseButton = MOUSE_RIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1941 vimModifiers &= ~MOUSE_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942 clickIsPopup = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1944 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1945
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946 /* Is it a double click ? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1947 dblClick = ((theEvent->when - lastMouseTick) < GetDblTime());
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 /* Send the mouse clicj to Vim */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1950 gui_send_mouse_event(vimMouseButton, thePoint.h,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1951 thePoint.v, dblClick, vimModifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1952
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1953 /* Create the rectangle around the cursor to detect
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1954 * the mouse dragging
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1955 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1956 #ifdef USE_CTRLCLICKMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1957 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1958 /* TODO: Do we need to this even for the contextual menu?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1959 * It may be require for popup_setpos, but for popup?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1960 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1961 if (vimMouseButton == MOUSE_LEFT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1962 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1963 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1964 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1965 SetRect(&dragRect, FILL_X(X_2_COL(thePoint.h)),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1966 FILL_Y(Y_2_ROW(thePoint.v)),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1967 FILL_X(X_2_COL(thePoint.h)+1),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1968 FILL_Y(Y_2_ROW(thePoint.v)+1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1969
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1970 dragRectEnbl = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1971 dragRectControl = kCreateRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1972 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1973 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1974 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1975
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1976 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1977 * Handle the click in the titlebar (to move the window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1978 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1979 void
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1980 gui_mac_doInDragClick(where, whichWindow)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1981 Point where;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1982 WindowPtr whichWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1983 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1984 Rect movingLimits;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1985 Rect *movingLimitsPtr = &movingLimits;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1986
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1987 /* TODO: may try to prevent move outside screen? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1988 #ifdef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1989 movingLimitsPtr = GetRegionBounds(GetGrayRgn(), &movingLimits);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1990 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 movingLimitsPtr = &(*GetGrayRgn())->rgnBBox;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992 #endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
1993 DragWindow(whichWindow, where, movingLimitsPtr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1994 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1995
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 * Handle the click in the grow box
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1999 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000 gui_mac_doInGrowClick(where, whichWindow)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2001 Point where;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 WindowPtr whichWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2003 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2004
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2005 long newSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2006 unsigned short newWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2007 unsigned short newHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2008 Rect resizeLimits;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2009 Rect *resizeLimitsPtr = &resizeLimits;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2010 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011 Rect NewContentRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2012
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2013 resizeLimitsPtr = GetRegionBounds(GetGrayRgn(), &resizeLimits);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2014 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2015 resizeLimits = qd.screenBits.bounds;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2016 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2017
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2018 /* Set the minimun size */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2019 /* TODO: Should this come from Vim? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2020 resizeLimits.top = 100;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2021 resizeLimits.left = 100;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2022
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2023 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2024 newSize = ResizeWindow(whichWindow, where, &resizeLimits, &NewContentRect);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2025 newWidth = NewContentRect.right - NewContentRect.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2026 newHeight = NewContentRect.bottom - NewContentRect.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027 gui_resize_shell(newWidth, newHeight);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2028 gui_mch_set_bg_color(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2029 gui_set_shellsize(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2030 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2031 newSize = GrowWindow(whichWindow, where, &resizeLimits);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2032 if (newSize != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2034 newWidth = newSize & 0x0000FFFF;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2035 newHeight = (newSize >> 16) & 0x0000FFFF;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2036
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2037 gui_mch_set_bg_color(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2038
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2039 gui_resize_shell(newWidth, newHeight);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2040
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2041 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2042 * We need to call gui_set_shellsize as the size
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2043 * used by Vim may be smaller than the size selected
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2044 * by the user. This cause some overhead
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2045 * TODO: add a check inside gui_resize_shell?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2046 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2047 gui_set_shellsize(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2048
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2049 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2050 * Origin of the code below is unknown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2051 * Functionality is unknown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2052 * Time of commented out is unknown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2053 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2054 /* SetPort(wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2055 InvalRect(&wp->portRect);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2056 if (isUserWindow(wp)) {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2057 DrawingWindowPeek aWindow = (DrawingWindowPeek)wp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2058
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 if (aWindow->toolRoutines.toolWindowResizedProc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060 CallToolWindowResizedProc(aWindow->toolRoutines.toolWindowResizedProc, wp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2061 }*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2065 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2066
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2067 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2068 * Handle the click in the zoom box
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2069 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2070 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2071 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2072 gui_mac_doInZoomClick(theEvent, whichWindow)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2073 EventRecord *theEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2074 WindowPtr whichWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2075 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2076 Rect r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2077 Point p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2078 short thePart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2080 /* ideal width is current */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2081 p.h = Columns * gui.char_width + 2 * gui.border_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2082 if (gui.which_scrollbars[SBAR_LEFT])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2083 p.h += gui.scrollbar_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2084 if (gui.which_scrollbars[SBAR_RIGHT])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2085 p.h += gui.scrollbar_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2086 /* ideal height is as heigh as we can get */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2087 p.v = 15 * 1024;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2088
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2089 thePart = IsWindowInStandardState(whichWindow, &p, &r)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2090 ? inZoomIn : inZoomOut;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2091
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2092 if (!TrackBox(whichWindow, theEvent->where, thePart))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2093 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2094
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2095 /* use returned width */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2096 p.h = r.right - r.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2097 /* adjust returned height */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2098 p.v = r.bottom - r.top - 2 * gui.border_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2099 if (gui.which_scrollbars[SBAR_BOTTOM])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2100 p.v -= gui.scrollbar_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2101 p.v -= p.v % gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2102 p.v += 2 * gui.border_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2103 if (gui.which_scrollbars[SBAR_BOTTOM]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2104 p.v += gui.scrollbar_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2106 ZoomWindowIdeal(whichWindow, thePart, &p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2108 GetWindowBounds(whichWindow, kWindowContentRgn, &r);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2109 gui_resize_shell(r.right - r.left, r.bottom - r.top);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2110 gui_mch_set_bg_color(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2111 gui_set_shellsize(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2112 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2113 #endif /* defined(USE_CARBONIZED) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2114
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2115 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2116 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2117 * MacOS Event Handling procedure
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2118 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2119 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2120
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2121 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2122 * Handle the Update Event
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2123 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2124
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2125 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2126 gui_mac_doUpdateEvent(event)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2127 EventRecord *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2128 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2129 WindowPtr whichWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2130 GrafPtr savePort;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2131 RgnHandle updateRgn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2132 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2133 Rect updateRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2134 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2135 Rect *updateRectPtr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2136 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2137 Rect growRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2138 RgnHandle saveRgn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2141 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2142 updateRgn = NewRgn();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2143 if (updateRgn == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2144 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2145 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2146
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2147 /* This could be done by the caller as we
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2148 * don't require anything else out of the event
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2149 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2150 whichWindow = (WindowPtr) event->message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2152 /* Save Current Port */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2153 GetPort(&savePort);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2154
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2155 /* Select the Window's Port */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2156 #ifdef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2157 SetPortWindowPort(whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2158 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2159 SetPort(whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2160 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2161
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2162 /* Let's update the window */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2163 BeginUpdate(whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2164 /* Redraw the biggest rectangle covering the area
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2165 * to be updated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2166 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2167 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2168 GetPortVisibleRegion(GetWindowPort(whichWindow), updateRgn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2169 # if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2170 /* Would be more appropriate to use the follwing but doesn't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2171 * seem to work under MacOS X (Dany)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2172 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2173 GetWindowRegion(whichWindow, kWindowUpdateRgn, updateRgn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2174 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2175 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2176 updateRgn = whichWindow->visRgn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2177 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2178 /* Use the HLock useless in Carbon? Is it harmful?*/
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2179 HLock((Handle) updateRgn);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2180 #ifdef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2181 updateRectPtr = GetRegionBounds(updateRgn, &updateRect);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2182 # if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2183 /* Code from original Carbon Port (using GetWindowRegion.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2184 * I believe the UpdateRgn is already in local (Dany)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2185 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2186 GlobalToLocal(&topLeft(updateRect)); /* preCarbon? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2187 GlobalToLocal(&botRight(updateRect));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2188 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2189 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2190 updateRectPtr = &(*updateRgn)->rgnBBox;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2191 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2192 /* Update the content (i.e. the text) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2193 gui_redraw(updateRectPtr->left, updateRectPtr->top,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2194 updateRectPtr->right - updateRectPtr->left,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2195 updateRectPtr->bottom - updateRectPtr->top);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2196 /* Clear the border areas if needed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2197 gui_mch_set_bg_color(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2198 if (updateRectPtr->left < FILL_X(0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2199 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2200 SetRect(&rc, 0, 0, FILL_X(0), FILL_Y(Rows));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2201 EraseRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2202 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2203 if (updateRectPtr->top < FILL_Y(0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2204 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2205 SetRect(&rc, 0, 0, FILL_X(Columns), FILL_Y(0));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2206 EraseRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2207 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2208 if (updateRectPtr->right > FILL_X(Columns))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2209 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2210 SetRect(&rc, FILL_X(Columns), 0,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2211 FILL_X(Columns) + gui.border_offset, FILL_Y(Rows));
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2212 EraseRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2213 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2214 if (updateRectPtr->bottom > FILL_Y(Rows))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2215 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2216 SetRect(&rc, 0, FILL_Y(Rows), FILL_X(Columns) + gui.border_offset,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2217 FILL_Y(Rows) + gui.border_offset);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2218 EraseRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2219 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2220 HUnlock((Handle) updateRgn);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2221 #ifdef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2222 DisposeRgn(updateRgn);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2223 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2224
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2225 /* Update scrollbars */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2226 DrawControls(whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2227
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2228 /* Update the GrowBox */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2229 /* Taken from FAQ 33-27 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2230 saveRgn = NewRgn();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2231 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2232 GetWindowBounds(whichWindow, kWindowGrowRgn, &growRect);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2233 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2234 growRect = whichWindow->portRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2235 growRect.top = growRect.bottom - 15;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2236 growRect.left = growRect.right - 15;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2237 #endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2238 GetClip(saveRgn);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2239 ClipRect(&growRect);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2240 DrawGrowIcon(whichWindow);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2241 SetClip(saveRgn);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2242 DisposeRgn(saveRgn);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2243 EndUpdate(whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2245 /* Restore original Port */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2246 SetPort(savePort);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2247 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2248
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2249 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2250 * Handle the activate/deactivate event
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2251 * (apply to a window)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2252 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2253 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2254 gui_mac_doActivateEvent(event)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2255 EventRecord *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2256 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2257 WindowPtr whichWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2258
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2259 whichWindow = (WindowPtr) event->message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2260 if ((event->modifiers) & activeFlag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2261 /* Activate */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2262 gui_focus_change(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2263 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2264 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2265 /* Deactivate */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2266 gui_focus_change(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2267 /* DON'T KNOW what the code below was doing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2268 found in the deactivate clause, but the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2269 clause writting TRUE into in_focus (BUG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2270 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2271
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2272 #if 0 /* Removed by Dany as per above June 2001 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2273 a_bool = false;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2274 SetPreserveGlyph(a_bool);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2275 SetOutlinePreferred(a_bool);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2276 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2277 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2278 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2280
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2281 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2282 * Handle the suspend/resume event
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2283 * (apply to the application)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2284 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2285 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2286 gui_mac_doSuspendEvent(event)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2287 EventRecord *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2288 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2289 /* The frontmost application just changed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2290
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2291 /* NOTE: the suspend may happen before the deactivate
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2292 * seen on MacOS X
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2293 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2295 /* May not need to change focus as the window will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2296 * get an activate/desactivate event
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2297 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2298 if (event->message & 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2299 /* Resume */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2300 gui_focus_change(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2301 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2302 /* Suspend */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2303 gui_focus_change(FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2304 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2305
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2306 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2307 * Handle the key
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2308 */
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2309 #ifdef USE_CARBONKEYHANDLER
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2310 # define INLINE_KEY_BUFFER_SIZE 80
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2311 static pascal OSStatus
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2312 gui_mac_doKeyEventCarbon(EventHandlerCallRef nextHandler, EventRef theEvent,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2313 void *data)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2314 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2315 /* Multibyte-friendly key event handler */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2316 OSStatus e = -1;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2317 UInt32 actualSize;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2318 UniChar *text;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2319 char_u result[INLINE_KEY_BUFFER_SIZE];
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2320 short len = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2321 UInt32 key_sym;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2322 char charcode;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2323 int key_char;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2324 UInt32 modifiers;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2325 size_t encLen;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2326 char_u *to = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2327 Boolean isSpecial = FALSE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2328 int i;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2329
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2330 /* Mask the mouse (as per user setting) */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2331 if (p_mh)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2332 ObscureCursor();
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2333
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2334 do
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2335 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2336 if (noErr != GetEventParameter(theEvent, kEventParamTextInputSendText,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2337 typeUnicodeText, NULL, 0, &actualSize, NULL))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2338 break;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2339
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2340 text = (UniChar *)alloc(actualSize);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2341
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2342 if (text)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2343 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2344 do
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2345 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2346 if (noErr != GetEventParameter(theEvent,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2347 kEventParamTextInputSendText,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2348 typeUnicodeText, NULL, actualSize, NULL, text))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2349 break;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2350 EventRef keyEvent;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2351 if (noErr != GetEventParameter(theEvent,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2352 kEventParamTextInputSendKeyboardEvent,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2353 typeEventRef, NULL, sizeof(EventRef), NULL, &keyEvent))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2354 break;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2355 if (noErr != GetEventParameter(keyEvent,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2356 kEventParamKeyModifiers,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2357 typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2358 break;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2359 if (noErr != GetEventParameter(keyEvent,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2360 kEventParamKeyCode,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2361 typeUInt32, NULL, sizeof(UInt32), NULL, &key_sym))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2362 break;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2363 if (noErr != GetEventParameter(keyEvent,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2364 kEventParamKeyMacCharCodes,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2365 typeChar, NULL, sizeof(char), NULL, &charcode))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2366 break;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2367
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2368 key_char = charcode;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2369
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2370 if (modifiers & controlKey)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2371 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2372 if ((modifiers & ~(controlKey|shiftKey)) == 0
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2373 && (key_char == '2' || key_char == '6'))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2374 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2375 /* CTRL-^ and CTRL-@ don't work in the normal way. */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2376 if (key_char == '2')
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2377 key_char = Ctrl_AT;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2378 else
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2379 key_char = Ctrl_HAT;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2380
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2381 text[0] = (UniChar)key_char;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2382 modifiers = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2383 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2384 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2385
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2386 if (modifiers & cmdKey)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2387 #ifndef USE_CMD_KEY
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2388 break; /* Let system handle Cmd+... */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2389 #else
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2390 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2391 /* Intercept CMD-. */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2392 if (key_char == '.')
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2393 got_int = TRUE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2394
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2395 /* Convert the modifiers */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2396 modifiers = EventModifiers2VimModifiers(modifiers);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2397
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2398 /* Following code to simplify and consolidate modifiers
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2399 * taken liberally from gui_w48.c */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2400
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2401 key_char = simplify_key(key_char, (int *)&modifiers);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2402
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2403 /* remove SHIFT for keys that are already shifted, e.g.,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2404 * '(' and '*' */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2405 if (key_char < 0x100 &&
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2406 !isalpha(key_char) && isprint(key_char))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2407 modifiers &= ~MOD_MASK_SHIFT;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2408
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2409 /* Interpret META, include SHIFT, etc. */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2410 key_char = extract_modifiers(key_char, (int *)&modifiers);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2411 if (key_char == CSI)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2412 key_char = K_CSI;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2413
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2414 if (modifiers)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2415 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2416 result[len++] = CSI;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2417 result[len++] = KS_MODIFIER;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2418 result[len++] = modifiers;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2419 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2420
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2421 isSpecial = TRUE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2422 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2423 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2424 else
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2425 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2426 /* Find the special key (eg., for cursor keys) */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2427 if (!(actualSize > sizeof(UniChar)) &&
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2428 ((text[0] < 0x20) || (text[0] == 0x7f)))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2429 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2430 for (i = 0; special_keys[i].key_sym != (KeySym)0; ++i)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2431 if (special_keys[i].key_sym == key_sym)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2432 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2433 key_char = TO_SPECIAL(special_keys[i].vim_code0,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2434 special_keys[i].vim_code1);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2435 key_char = simplify_key(key_char,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2436 (int *)&modifiers);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2437 isSpecial = TRUE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2438 break;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2439 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2440 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2441 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2442
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2443 if (isSpecial && IS_SPECIAL(key_char))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2444 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2445 result[len++] = CSI;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2446 result[len++] = K_SECOND(key_char);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2447 result[len++] = K_THIRD(key_char);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2448 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2449 else
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2450 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2451 encLen = actualSize;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2452 to = mac_utf16_to_enc(text, actualSize, &encLen);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2453 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2454
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2455 if (to)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2456 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2457 /* This is basically add_to_input_buf_csi() */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2458 for (i = 0; i < encLen && len < (INLINE_KEY_BUFFER_SIZE-1); ++i)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2459 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2460 result[len++] = to[i];
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2461 if (to[i] == CSI)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2462 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2463 result[len++] = KS_EXTRA;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2464 result[len++] = (int)KE_CSI;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2465 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2466 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2467 vim_free(to);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2468 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2469
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2470 add_to_input_buf(result, len);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2471 e = noErr;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2472 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2473 while (0);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2474
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2475 vim_free(text);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2476 if (e == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2477 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2478 /* Fake event to wake up WNE (required to get
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2479 * key repeat working */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2480 PostEvent(keyUp, 0);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2481 return noErr;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2482 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2483 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2484 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2485 while (0);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2486
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2487 return CallNextEventHandler(nextHandler, theEvent);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2488 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2489 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2490 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2491 gui_mac_doKeyEvent(EventRecord *theEvent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2492 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2493 /* TODO: add support for COMMAND KEY */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2494 long menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2495 unsigned char string[20];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2496 short num, i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2497 short len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2498 KeySym key_sym;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2499 int key_char;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2500 int modifiers;
26
404aac550f35 updated for version 7.0017
vimboss
parents: 19
diff changeset
2501 int simplify = FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2502
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2503 /* Mask the mouse (as per user setting) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2504 if (p_mh)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2505 ObscureCursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2506
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2507 /* Get the key code and it's ASCII representation */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2508 key_sym = ((theEvent->message & keyCodeMask) >> 8);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2509 key_char = theEvent->message & charCodeMask;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2510 num = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2511
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2512 /* Intercept CTRL-C */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2513 if (theEvent->modifiers & controlKey)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2514 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2515 if (key_char == Ctrl_C && ctrl_c_interrupts)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2516 got_int = TRUE;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2517 else if ((theEvent->modifiers & ~(controlKey|shiftKey)) == 0
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2518 && (key_char == '2' || key_char == '6'))
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2519 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2520 /* CTRL-^ and CTRL-@ don't work in the normal way. */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2521 if (key_char == '2')
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2522 key_char = Ctrl_AT;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2523 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2524 key_char = Ctrl_HAT;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2525 theEvent->modifiers = 0;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2526 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2527 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529 /* Intercept CMD-. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2530 if (theEvent->modifiers & cmdKey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2531 if (key_char == '.')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2532 got_int = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2533
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2534 /* Handle command key as per menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2535 /* TODO: should override be allowed? Require YAO or could use 'winaltkey' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2536 if (theEvent->modifiers & cmdKey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2537 /* Only accept CMD alone or with CAPLOCKS and the mouse button.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2538 * Why the mouse button? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2539 if ((theEvent->modifiers & (~(cmdKey | btnState | alphaLock))) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2540 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2541 menu = MenuKey(key_char);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2542 if (HiWord(menu))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2543 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2544 gui_mac_handle_menu(menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2545 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2546 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2547 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2549 /* Convert the modifiers */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2550 modifiers = EventModifiers2VimModifiers(theEvent->modifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2551
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2552
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2553 /* Handle special keys. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2554 #if 0
26
404aac550f35 updated for version 7.0017
vimboss
parents: 19
diff changeset
2555 /* Why has this been removed? */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2556 if (!(theEvent->modifiers & (cmdKey | controlKey | rightControlKey)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2557 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2558 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 /* Find the special key (for non-printable keyt_char) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2560 if ((key_char < 0x20) || (key_char == 0x7f))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2561 for (i = 0; special_keys[i].key_sym != (KeySym)0; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2562 if (special_keys[i].key_sym == key_sym)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2563 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2564 # if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2565 /* We currently don't have not so special key */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2566 if (special_keys[i].vim_code1 == NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2567 key_char = special_keys[i].vim_code0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2568 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2569 # endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2570 key_char = TO_SPECIAL(special_keys[i].vim_code0,
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2571 special_keys[i].vim_code1);
26
404aac550f35 updated for version 7.0017
vimboss
parents: 19
diff changeset
2572 simplify = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2573 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2574 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2575 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2576
26
404aac550f35 updated for version 7.0017
vimboss
parents: 19
diff changeset
2577 /* For some keys the modifier is included in the char itself. */
404aac550f35 updated for version 7.0017
vimboss
parents: 19
diff changeset
2578 if (simplify || key_char == TAB || key_char == ' ')
404aac550f35 updated for version 7.0017
vimboss
parents: 19
diff changeset
2579 key_char = simplify_key(key_char, &modifiers);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2580
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 /* Add the modifier to the input bu if needed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2582 /* Do not want SHIFT-A or CTRL-A with modifier */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2583 if (!IS_SPECIAL(key_char)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2584 && key_sym != vk_Space
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2585 && key_sym != vk_Tab
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2586 && key_sym != vk_Return
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2587 && key_sym != vk_Enter
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2588 && key_sym != vk_Esc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2589 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2590 #if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2591 /* Clear modifiers when only one modifier is set */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2592 if ((modifiers == MOD_MASK_SHIFT)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2593 || (modifiers == MOD_MASK_CTRL)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2594 || (modifiers == MOD_MASK_ALT))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2595 modifiers = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2596 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2597 if (modifiers & MOD_MASK_CTRL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2598 modifiers = modifiers & ~MOD_MASK_CTRL;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2599 if (modifiers & MOD_MASK_ALT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2600 modifiers = modifiers & ~MOD_MASK_ALT;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2601 if (modifiers & MOD_MASK_SHIFT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2602 modifiers = modifiers & ~MOD_MASK_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2603 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2604 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2605 if (modifiers)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2606 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2607 string[len++] = CSI;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2608 string[len++] = KS_MODIFIER;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2609 string[len++] = modifiers;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2610 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2611
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2612 if (IS_SPECIAL(key_char))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2613 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2614 string[len++] = CSI;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2615 string[len++] = K_SECOND(key_char);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2616 string[len++] = K_THIRD(key_char);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2617 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2618 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2619 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2620 #ifdef FEAT_MBYTE
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2621 /* Convert characters when needed (e.g., from MacRoman to latin1).
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2622 * This doesn't work for the NUL byte. */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2623 if (input_conv.vc_type != CONV_NONE && key_char > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2624 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2625 char_u from[2], *to;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2626 int l;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2627
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2628 from[0] = key_char;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2629 from[1] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2630 l = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2631 to = string_convert(&input_conv, from, &l);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2632 if (to != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2633 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2634 for (i = 0; i < l && len < 19; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2635 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2636 if (to[i] == CSI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2637 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2638 string[len++] = KS_EXTRA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2639 string[len++] = KE_CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2640 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2641 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2642 string[len++] = to[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2643 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2644 vim_free(to);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2645 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2646 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2647 string[len++] = key_char;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2648 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2649 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2650 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2651 string[len++] = key_char;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2652 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2653
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2654 if (len == 1 && string[0] == CSI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2655 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2656 /* Turn CSI into K_CSI. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2657 string[ len++ ] = KS_EXTRA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2658 string[ len++ ] = KE_CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2659 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2660
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2661 add_to_input_buf(string, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2662 }
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2663 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2664
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2665 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2666 * Handle MouseClick
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2667 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2668 void
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2669 gui_mac_doMouseDownEvent(theEvent)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2670 EventRecord *theEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2671 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2672 short thePart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2673 WindowPtr whichWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2674
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2675 thePart = FindWindow(theEvent->where, &whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2676
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2677 switch (thePart)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2678 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2679 case (inDesk):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2680 /* TODO: what to do? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2681 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2682
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2683 case (inMenuBar):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2684 gui_mac_handle_menu(MenuSelect(theEvent->where));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2685 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2686
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2687 case (inContent):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2688 gui_mac_doInContentClick(theEvent, whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2689 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2690
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2691 case (inDrag):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2692 gui_mac_doInDragClick(theEvent->where, whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2693 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2694
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2695 case (inGrow):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2696 gui_mac_doInGrowClick(theEvent->where, whichWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2697 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2698
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2699 case (inGoAway):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2700 if (TrackGoAway(whichWindow, theEvent->where))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2701 gui_shell_closed();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2702 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2703
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2704 case (inZoomIn):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2705 case (inZoomOut):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2706 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2707 gui_mac_doInZoomClick(theEvent, whichWindow);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2708 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2709 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2710 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2711 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2712
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2713 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2714 * Handle MouseMoved
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2715 * [this event is a moving in and out of a region]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2716 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2717 void
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2718 gui_mac_doMouseMovedEvent(event)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2719 EventRecord *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2720 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2721 Point thePoint;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2722 int_u vimModifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2723
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2724 thePoint = event->where;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2725 GlobalToLocal(&thePoint);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2726 vimModifiers = EventModifiers2VimMouseModifiers(event->modifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2727
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2728 if (!Button())
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2729 gui_mouse_moved(thePoint.h, thePoint.v);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2730 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2731 #ifdef USE_CTRLCLICKMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2732 if (!clickIsPopup)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2733 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2734 gui_send_mouse_event(MOUSE_DRAG, thePoint.h,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2735 thePoint.v, FALSE, vimModifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2736
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2737 /* Reset the region from which we move in and out */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2738 SetRect(&dragRect, FILL_X(X_2_COL(thePoint.h)),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2739 FILL_Y(Y_2_ROW(thePoint.v)),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2740 FILL_X(X_2_COL(thePoint.h)+1),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2741 FILL_Y(Y_2_ROW(thePoint.v)+1));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2742
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2743 if (dragRectEnbl)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2744 dragRectControl = kCreateRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2745
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2746 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2747
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2748 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2749 * Handle the mouse release
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2750 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2751 void
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2752 gui_mac_doMouseUpEvent(theEvent)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2753 EventRecord *theEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2754 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2755 Point thePoint;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2756 int_u vimModifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2757
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2758 /* TODO: Properly convert the Contextual menu mouse-up */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2759 /* Potential source of the double menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2760 lastMouseTick = theEvent->when;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2761 dragRectEnbl = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2762 dragRectControl = kCreateEmpty;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2763 thePoint = theEvent->where;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2764 GlobalToLocal(&thePoint);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2765
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2766 vimModifiers = EventModifiers2VimMouseModifiers(theEvent->modifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2767 #ifdef USE_CTRLCLICKMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2768 if (clickIsPopup)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2769 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2770 vimModifiers &= ~MOUSE_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2771 clickIsPopup = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2772 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2773 #endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2774 gui_send_mouse_event(MOUSE_RELEASE, thePoint.h, thePoint.v, FALSE, vimModifiers);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2775 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2776
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2777 #ifdef USE_MOUSEWHEEL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2778 static pascal OSStatus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2779 gui_mac_mouse_wheel(EventHandlerCallRef nextHandler, EventRef theEvent,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2780 void *data)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2781 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2782 EventRef bogusEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2783 Point point;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2784 Rect bounds;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2785 UInt32 mod;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2786 SInt32 delta;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2787 int_u vim_mod;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2788
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2789 if (noErr != GetEventParameter(theEvent, kEventParamMouseWheelDelta,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2790 typeSInt32, NULL, sizeof(SInt32), NULL, &delta))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2791 goto bail;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2792 if (noErr != GetEventParameter(theEvent, kEventParamMouseLocation,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2793 typeQDPoint, NULL, sizeof(Point), NULL, &point))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2794 goto bail;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2795 if (noErr != GetEventParameter(theEvent, kEventParamKeyModifiers,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2796 typeUInt32, NULL, sizeof(UInt32), NULL, &mod))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2797 goto bail;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2798
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2799 vim_mod = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2800 if (mod & shiftKey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2801 vim_mod |= MOUSE_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2802 if (mod & controlKey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2803 vim_mod |= MOUSE_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2804 if (mod & optionKey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2805 vim_mod |= MOUSE_ALT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2806
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2807 /* post a bogus event to wake up WaitNextEvent */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2808 if (noErr != CreateEvent(NULL, kEventClassMouse, kEventMouseMoved, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2809 kEventAttributeNone, &bogusEvent))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2810 goto bail;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2811 if (noErr != PostEventToQueue(GetMainEventQueue(), bogusEvent,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2812 kEventPriorityLow))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2813 goto bail;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2814
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
2815 ReleaseEvent(bogusEvent);
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
2816
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2817 if (noErr == GetWindowBounds(gui.VimWindow, kWindowContentRgn, &bounds))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2818 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2819 point.h -= bounds.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2820 point.v -= bounds.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2821 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2822
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2823 gui_send_mouse_event((delta > 0) ? MOUSE_4 : MOUSE_5,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2824 point.h, point.v, FALSE, vim_mod);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2825
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2826 return noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2827
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2828 bail:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2829 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2830 * when we fail give any additional callback handler a chance to perform
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2831 * it's actions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2832 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2833 return CallNextEventHandler(nextHandler, theEvent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2834 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2835 #endif /* defined(USE_MOUSEWHEEL) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2836
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2837 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2838
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2839 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2840 * This would be the normal way of invoking the contextual menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2841 * but the Vim API doesn't seem to a support a request to get
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2842 * the menu that we should display
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2843 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2844 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2845 gui_mac_handle_contextual_menu(event)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2846 EventRecord *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2847 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2848 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2849 * Clone PopUp to use menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2850 * Create a object descriptor for the current selection
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2851 * Call the procedure
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2852 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2853
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2854 // Call to Handle Popup
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2855 OSStatus status = ContextualMenuSelect(CntxMenu, event->where, false, kCMHelpItemNoHelp, "", NULL, &CntxType, &CntxMenuID, &CntxMenuItem);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2856
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2857 if (status != noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2858 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2859
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2860 if (CntxType == kCMMenuItemSelected)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2861 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2862 /* Handle the menu CntxMenuID, CntxMenuItem */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2863 /* The submenu can be handle directly by gui_mac_handle_menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2864 /* But what about the current menu, is the meny changed by ContextualMenuSelect */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2865 gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2866 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2867 else if (CntxMenuID == kCMShowHelpSelected)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2868 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2869 /* Should come up with the help */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2870 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2871
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2872 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2873 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2874
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2875 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2876 * Handle menubar selection
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2877 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2878 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2879 gui_mac_handle_menu(menuChoice)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2880 long menuChoice;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2881 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2882 short menu = HiWord(menuChoice);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2883 short item = LoWord(menuChoice);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2884 vimmenu_T *theVimMenu = root_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2885 #ifndef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2886 MenuHandle appleMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2887 Str255 itemName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2888 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2889
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2890 if (menu == 256) /* TODO: use constant or gui.xyz */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2891 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2892 if (item == 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2893 gui_mch_beep(); /* TODO: Popup dialog or do :intro */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2894 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2895 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2896 #ifndef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2897 /* Desk Accessory doesn't exist in Carbon */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2898 appleMenu = GetMenuHandle(menu);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2899 GetMenuItemText(appleMenu, item, itemName);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2900 (void) OpenDeskAcc(itemName);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2901 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2902 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2903 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2904 else if (item != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2905 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2906 theVimMenu = gui_mac_get_vim_menu(menu, item, root_menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2907
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2908 if (theVimMenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2909 gui_menu_cb(theVimMenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2910 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2911 HiliteMenu(0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2912 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2913
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2914 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2915 * Dispatch the event to proper handler
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2916 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2917
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2918 void
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2919 gui_mac_handle_event(event)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2920 EventRecord *event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2921 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2922 OSErr error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2923
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2924 /* Handle contextual menu right now (if needed) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2925 #ifdef USE_CTRLCLICKMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2926 if (gui.MacOSHaveCntxMenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2927 if (IsShowContextualMenuClick(event))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2928 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2929 # if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2930 gui_mac_handle_contextual_menu(event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2931 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2932 gui_mac_doMouseDownEvent(event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2933 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2934 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2935 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2936 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2937
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2938 /* Handle normal event */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2939 switch (event->what)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2940 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2941 #ifndef USE_CARBONKEYHANDLER
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2942 case (keyDown):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2943 case (autoKey):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2944 gui_mac_doKeyEvent(event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2945 break;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
2946 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2947 case (keyUp):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2948 /* We don't care about when the key get release */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2949 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2950
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2951 case (mouseDown):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2952 gui_mac_doMouseDownEvent(event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2953 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2954
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2955 case (mouseUp):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2956 gui_mac_doMouseUpEvent(event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2957 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2958
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2959 case (updateEvt):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2960 gui_mac_doUpdateEvent(event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2961 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2962
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2963 case (diskEvt):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2964 /* We don't need special handling for disk insertion */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2965 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2966
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2967 case (activateEvt):
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2968 gui_mac_doActivateEvent(event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2969 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2970
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2971 case (osEvt):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2972 switch ((event->message >> 24) & 0xFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2973 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2974 case (0xFA): /* mouseMovedMessage */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2975 gui_mac_doMouseMovedEvent(event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2976 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2977 case (0x01): /* suspendResumeMessage */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
2978 gui_mac_doSuspendEvent(event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2979 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2980 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2981 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2982
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2983 #ifdef USE_AEVENT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2984 case (kHighLevelEvent):
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2985 /* Someone's talking to us, through AppleEvents */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2986 error = AEProcessAppleEvent(event); /* TODO: Error Handling */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2987 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2988 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2989 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2990 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2991
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2992 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2993 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2994 * Unknown Stuff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2995 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2996 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2997
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2998
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2999 GuiFont
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3000 gui_mac_find_font(font_name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3001 char_u *font_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3002 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3003 char_u c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3004 char_u *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3005 char_u pFontName[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3006 Str255 systemFontname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3007 short font_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3008 short size=9;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3009 GuiFont font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3010 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3011 char_u *fontNamePtr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3012 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3013
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3014 for (p = font_name; ((*p != 0) && (*p != ':')); p++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3015 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3016
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3017 c = *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3018 *p = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3019
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3020 #if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3021 STRCPY(&pFontName[1], font_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3022 pFontName[0] = STRLEN(font_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3023 *p = c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3024
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3025 /* Get the font name, minus the style suffix (:h, etc) */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3026 #if defined(MACOS_X) && defined(USE_CARBONIZED)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3027 char_u fontName[256];
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3028 char_u *styleStart = vim_strchr(font_name, ':');
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3029 size_t fontNameLen = styleStart ? styleStart - font_name : STRLEN(fontName);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3030 vim_strncpy(fontName, font_name, fontNameLen);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3031
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3032 ATSUFontID fontRef;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3033 FMFontStyle fontStyle;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3034 font_id = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3035
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3036 if (ATSUFindFontFromName(&pFontName[1], pFontName[0], kFontFullName,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3037 kFontMacintoshPlatform, kFontNoScriptCode, kFontNoLanguageCode,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3038 &fontRef) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3039 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3040 if (FMGetFontFamilyInstanceFromFont(fontRef, &font_id, &fontStyle) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3041 font_id = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3042 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3043 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3044 GetFNum(pFontName, &font_id);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3045 #endif
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3046
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3047 if (font_id == 0)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3048 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3049 /*
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3050 * Try again, this time replacing underscores in the font name
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3051 * with spaces (:set guifont allows the two to be used
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3052 * interchangeably; the Font Manager doesn't).
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3053 */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3054 int i, changed = FALSE;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3055
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3056 for (i = pFontName[0]; i > 0; --i)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3057 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3058 if (pFontName[i] == '_')
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3059 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3060 pFontName[i] = ' ';
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3061 changed = TRUE;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3062 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3063 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3064 if (changed)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3065 #if defined(MACOS_X) && defined(USE_CARBONIZED)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3066 if (ATSUFindFontFromName(&pFontName[1], pFontName[0],
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3067 kFontFullName, kFontNoPlatformCode, kFontNoScriptCode,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3068 kFontNoLanguageCode, &fontRef) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3069 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3070 if (FMGetFontFamilyInstanceFromFont(fontRef, &font_id, &fontStyle) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3071 font_id = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3072 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3073 #else
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3074 GetFNum(pFontName, &font_id);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3075 #endif
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3076 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3077
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3078 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3079 /* name = C2Pascal_save(menu->dname); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3080 fontNamePtr = C2Pascal_save_and_remove_backslash(font_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3081
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3082 GetFNum(fontNamePtr, &font_id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3083 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3084
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3085
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3086 if (font_id == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3087 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3088 /* Oups, the system font was it the one the user want */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3089
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3090 #if defined(MACOS_X) && defined(USE_CARBONIZED)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3091 if (FMGetFontFamilyName(systemFont, systemFontname) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3092 return NOFONT;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3093 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3094 GetFontName(0, systemFontname);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3095 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3096 if (!EqualString(pFontName, systemFontname, false, false))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3097 return NOFONT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3098 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3099 if (*p == ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3100 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3101 p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3102 /* Set the values found after ':' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3103 while (*p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3104 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3105 switch (*p++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3106 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3107 case 'h':
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3108 size = points_to_pixels(p, &p, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3109 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3110 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3111 * TODO: Maybe accept width and styles
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3112 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3113 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3114 while (*p == ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3115 p++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3116 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3117 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3119 if (size < 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3120 size = 1; /* Avoid having a size of 0 with system font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3122 font = (size << 16) + ((long) font_id & 0xFFFF);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3124 return font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3125 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3126
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3127 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3128 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3129 * GUI_MCH functionnality
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3130 * ------------------------------------------------------------
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3131 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3132
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3133 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3134 * Parse the GUI related command-line arguments. Any arguments used are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3135 * deleted from argv, and *argc is decremented accordingly. This is called
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3136 * when vim is started, whether or not the GUI has been started.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3137 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3138 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3139 gui_mch_prepare(argc, argv)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3140 int *argc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3141 char **argv;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3142 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3143 /* TODO: Move most of this stuff toward gui_mch_init */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3144 #ifdef USE_EXE_NAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3145 FSSpec applDir;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3146 # ifndef USE_FIND_BUNDLE_PATH
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3147 short applVRefNum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3148 long applDirID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3149 Str255 volName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3150 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3151 ProcessSerialNumber psn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3152 FSRef applFSRef;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3153 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3154 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3155
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3156 #ifndef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3157 MaxApplZone(); /* What could replace thos */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3158 /* In Carbon, all shared library are automatically load in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3159 * there's no need to init them
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3160 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3161 InitGraf(&qd.thePort);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3162 InitFonts();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3163 InitWindows();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3164 InitMenus();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3165 TEInit();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3166 InitDialogs(nil);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3167 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3168 /* Why did I put that in? (Dany) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3169 MoreMasterPointers (0x40 * 3); /* we love handles */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3170 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3171
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3172 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3173 InitCursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3174
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3175 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3176 RegisterAppearanceClient();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3177 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3178
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3179 #ifdef USE_AEVENT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3180 (void) InstallAEHandlers();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3181 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3182
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3183 #ifdef USE_CTRLCLICKMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3184 if (Gestalt(gestaltContextualMenuAttr, &gestalt_rc) == noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3185 gui.MacOSHaveCntxMenu = BitTst(&gestalt_rc, 31-gestaltContextualMenuTrapAvailable);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3186 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3187 gui.MacOSHaveCntxMenu = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3188
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3189 if (gui.MacOSHaveCntxMenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3190 gui.MacOSHaveCntxMenu = (InitContextualMenus()==noErr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3191 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3193 #ifdef USE_SIOUX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3194 SIOUXSettings.standalone = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3195 SIOUXSettings.initializeTB = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3196 SIOUXSettings.setupmenus = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3197 SIOUXSettings.asktosaveonclose = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3198 SIOUXSettings.showstatusline = true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3199 SIOUXSettings.toppixel = 300;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3200 SIOUXSettings.leftpixel = 10;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3201 InstallConsole(1); /* fileno(stdout) = 1, on page 430 of MSL C */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3202 printf("Debugging console enabled\n");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3203 /* SIOUXSetTitle((char_u *) "Vim Stdout"); */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3204 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3205
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3206 pomme = NewMenu(256, "\p\024"); /* 0x14= = Apple Menu */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3207
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3208 AppendMenu(pomme, "\pAbout VIM");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3209 #ifndef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3210 AppendMenu(pomme, "\p-");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3211 AppendResMenu(pomme, 'DRVR');
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3212 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3213
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3214 InsertMenu(pomme, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3216 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3217
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3219 #ifndef USE_OFFSETED_WINDOW
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3220 SetRect(&windRect, 10, 48, 10+80*7 + 16, 48+24*11);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3221 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3222 SetRect(&windRect, 300, 40, 300+80*7 + 16, 40+24*11);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3223 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3224
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3225
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3226 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3227 CreateNewWindow(kDocumentWindowClass,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3228 kWindowResizableAttribute | kWindowCollapseBoxAttribute,
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3229 &windRect, &gui.VimWindow);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3230 SetPortWindowPort(gui.VimWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3231 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3232 gui.VimWindow = NewCWindow(nil, &windRect, "\pgVim on Macintosh", true, documentProc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3233 (WindowPtr) -1L, false, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3234 SetPort(gui.VimWindow);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3235 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3236
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3237 gui.char_width = 7;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3238 gui.char_height = 11;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3239 gui.char_ascent = 6;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3240 gui.num_rows = 24;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3241 gui.num_cols = 80;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3242 gui.in_focus = TRUE; /* For the moment -> syn. of front application */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3243
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3244 #if TARGET_API_MAC_CARBON
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3245 gScrollAction = NewControlActionUPP(gui_mac_scroll_action);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3246 gScrollDrag = NewControlActionUPP(gui_mac_drag_thumb);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3247 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3248 gScrollAction = NewControlActionProc(gui_mac_scroll_action);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3249 gScrollDrag = NewControlActionProc(gui_mac_drag_thumb);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3250 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3251
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3252 /* Getting a handle to the Help menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3253 #ifdef USE_HELPMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3254 # ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3255 HMGetHelpMenu(&gui.MacOSHelpMenu, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3256 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3257 (void) HMGetHelpMenuHandle(&gui.MacOSHelpMenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3258 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3260 if (gui.MacOSHelpMenu != nil)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3261 gui.MacOSHelpItems = CountMenuItems(gui.MacOSHelpMenu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3262 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3263 gui.MacOSHelpItems = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3264 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3265
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3266 dragRectEnbl = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3267 dragRgn = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3268 dragRectControl = kCreateEmpty;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3269 cursorRgn = NewRgn();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3270 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3271 #ifdef USE_EXE_NAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3272 # ifndef USE_FIND_BUNDLE_PATH
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3273 HGetVol(volName, &applVRefNum, &applDirID);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3274 /* TN2015: mention a possible bad VRefNum */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3275 FSMakeFSSpec(applVRefNum, applDirID, "\p", &applDir);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3276 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3277 /* OSErr GetApplicationBundleFSSpec(FSSpecPtr theFSSpecPtr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3278 * of TN2015
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3279 * This technic remove the ../Contents/MacOS/etc part
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3280 */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3281 (void)GetCurrentProcess(&psn);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3282 /* if (err != noErr) return err; */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3283
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3284 (void)GetProcessBundleLocation(&psn, &applFSRef);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3285 /* if (err != noErr) return err; */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3286
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3287 (void)FSGetCatalogInfo(&applFSRef, kFSCatInfoNone, NULL, NULL, &applDir, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3288
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3289 /* This technic return NIL when we disallow_gui */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3290 # endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3291 exe_name = FullPathFromFSSpec_save(applDir);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3292 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3293
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3294 #ifdef USE_VIM_CREATOR_ID
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3295 _fcreator = 'VIM!';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3296 _ftype = 'TEXT';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3297 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3298 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3299
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3300 #ifndef ALWAYS_USE_GUI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3301 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3302 * Check if the GUI can be started. Called before gvimrc is sourced.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3303 * Return OK or FAIL.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3304 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3305 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3306 gui_mch_init_check(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3307 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3308 /* TODO: For MacOS X find a way to return FAIL, if the user logged in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3309 * using the >console
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3310 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3311 if (disallow_gui) /* see main.c for reason to disallow */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3312 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3313 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3314 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3315 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3316
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3317 static OSErr
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3318 receiveHandler(WindowRef theWindow, void* handlerRefCon, DragRef theDrag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3319 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3320 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3321 int_u modifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3322 char_u **fnames = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3323 int count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3324 int i, j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3325
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3326 /* Get drop position, modifiers and count of items */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3327 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3328 Point point;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3329 SInt16 mouseUpModifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3330 UInt16 countItem;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3331
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3332 GetDragMouse(theDrag, &point, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3333 GlobalToLocal(&point);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3334 x = point.h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3335 y = point.v;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3336 GetDragModifiers(theDrag, NULL, NULL, &mouseUpModifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3337 modifiers = EventModifiers2VimMouseModifiers(mouseUpModifiers);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3338 CountDragItems(theDrag, &countItem);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3339 count = countItem;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3340 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3341
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3342 fnames = (char_u **)alloc(count * sizeof(char_u *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3343 if (fnames == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3344 return dragNotAcceptedErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3345
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3346 /* Get file names dropped */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3347 for (i = j = 0; i < count; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3348 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3349 DragItemRef item;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3350 OSErr err;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3351 Size size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3352 FlavorType type = flavorTypeHFS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3353 HFSFlavor hfsFlavor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3354
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3355 fnames[i] = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3356 GetDragItemReferenceNumber(theDrag, i + 1, &item);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3357 err = GetFlavorDataSize(theDrag, item, type, &size);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3358 if (err != noErr || size > sizeof(hfsFlavor))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3359 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3360 err = GetFlavorData(theDrag, item, type, &hfsFlavor, &size, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3361 if (err != noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3362 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3363 fnames[j++] = FullPathFromFSSpec_save(hfsFlavor.fileSpec);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3364 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3365 count = j;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3366
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3367 gui_handle_drop(x, y, modifiers, fnames, count);
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3368
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3369 /* Fake mouse event to wake from stall */
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3370 PostEvent(mouseUp, 0);
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3371
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3372 return noErr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3373 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3374
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3375 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3376 * Initialise the GUI. Create all the windows, set up all the call-backs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3377 * etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3378 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3379 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3380 gui_mch_init()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3381 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3382 /* TODO: Move most of this stuff toward gui_mch_init */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3383 Rect windRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3384 MenuHandle pomme;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3385 #ifdef USE_CTRLCLICKMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3386 long gestalt_rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3387 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3388 #ifdef USE_MOUSEWHEEL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3389 EventTypeSpec eventTypeSpec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3390 EventHandlerRef mouseWheelHandlerRef;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3391 #endif
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3392 #ifdef USE_CARBONKEYHANDLER
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3393 EventHandlerRef keyEventHandlerRef;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3394 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3395
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3396 #ifdef MACOS_X
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3397 if (Gestalt(gestaltSystemVersion, &gMacSystemVersion) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3398 gMacSystemVersion = 0x1000; /* Default to minimum sensible value */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3399 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3400
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3401 #if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3402 InitCursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3403
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3404 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3405 RegisterAppearanceClient();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3406 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3407
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3408 #ifdef USE_AEVENT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3409 (void) InstallAEHandlers();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3410 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3411
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3412 #ifdef USE_CTRLCLICKMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3413 if (Gestalt(gestaltContextualMenuAttr, &gestalt_rc) == noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3414 gui.MacOSHaveCntxMenu = BitTst(&gestalt_rc, 31-gestaltContextualMenuTrapAvailable);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3415 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3416 gui.MacOSHaveCntxMenu = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3417
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3418 if (gui.MacOSHaveCntxMenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3419 gui.MacOSHaveCntxMenu = (InitContextualMenus()==noErr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3420 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3421
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3422 #ifdef USE_SIOUX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3423 SIOUXSettings.standalone = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3424 SIOUXSettings.initializeTB = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3425 SIOUXSettings.setupmenus = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3426 SIOUXSettings.asktosaveonclose = false;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3427 SIOUXSettings.showstatusline = true;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3428 SIOUXSettings.toppixel = 300;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3429 SIOUXSettings.leftpixel = 10;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3430 InstallConsole(1); /* fileno(stdout) = 1, on page 430 of MSL C */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3431 printf("Debugging console enabled\n");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3432 /* SIOUXSetTitle((char_u *) "Vim Stdout"); */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3433 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3434
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3435 pomme = NewMenu(256, "\p\024"); /* 0x14= = Apple Menu */
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3436
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3437 AppendMenu(pomme, "\pAbout VIM");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3438 #ifndef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3439 AppendMenu(pomme, "\p-");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3440 AppendResMenu(pomme, 'DRVR');
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3441 #endif
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3442
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3443 InsertMenu(pomme, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3444
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3445 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3446
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3447
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3448 #ifndef USE_OFFSETED_WINDOW
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3449 SetRect(&windRect, 10, 48, 10+80*7 + 16, 48+24*11);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3450 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3451 SetRect(&windRect, 300, 40, 300+80*7 + 16, 40+24*11);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3452 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3453
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3454 gui.VimWindow = NewCWindow(nil, &windRect, "\pgVim on Macintosh", true,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3455 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3456 zoomDocProc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3457 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3458 documentProc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3459 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3460 (WindowPtr)-1L, true, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3461 InstallReceiveHandler((DragReceiveHandlerUPP)receiveHandler,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3462 gui.VimWindow, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3463 #ifdef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3464 SetPortWindowPort(gui.VimWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3465 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3466 SetPort(gui.VimWindow);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3467 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3468
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3469 gui.char_width = 7;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3470 gui.char_height = 11;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3471 gui.char_ascent = 6;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3472 gui.num_rows = 24;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3473 gui.num_cols = 80;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3474 gui.in_focus = TRUE; /* For the moment -> syn. of front application */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3475
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3476 #if TARGET_API_MAC_CARBON
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3477 gScrollAction = NewControlActionUPP(gui_mac_scroll_action);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3478 gScrollDrag = NewControlActionUPP(gui_mac_drag_thumb);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3479 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3480 gScrollAction = NewControlActionProc(gui_mac_scroll_action);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3481 gScrollDrag = NewControlActionProc(gui_mac_drag_thumb);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3482 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3483
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3484 #if defined(USE_CARBONIZED) && defined(MACOS_X)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3485 /* Install Carbon event callbacks. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3486 (void)InstallFontPanelHandler();
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3487 #endif
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3488
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3489 /* Getting a handle to the Help menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3490 #ifdef USE_HELPMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3491 # ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3492 HMGetHelpMenu(&gui.MacOSHelpMenu, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3493 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3494 (void) HMGetHelpMenuHandle(&gui.MacOSHelpMenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3495 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3497 if (gui.MacOSHelpMenu != nil)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3498 gui.MacOSHelpItems = CountMenuItems(gui.MacOSHelpMenu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3499 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3500 gui.MacOSHelpItems = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3501 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3502
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3503 dragRectEnbl = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3504 dragRgn = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3505 dragRectControl = kCreateEmpty;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3506 cursorRgn = NewRgn();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3507 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3508 /* Display any pending error messages */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3509 display_errors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3510
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3511 /* Get background/foreground colors from system */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3512 /* TODO: do the approriate call to get real defaults */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3513 gui.norm_pixel = 0x00000000;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3514 gui.back_pixel = 0x00FFFFFF;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3515
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3516 /* Get the colors from the "Normal" group (set in syntax.c or in a vimrc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3517 * file). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3518 set_normal_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3519
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3520 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3521 * Check that none of the colors are the same as the background color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3522 * Then store the current values as the defaults.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3523 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3524 gui_check_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3525 gui.def_norm_pixel = gui.norm_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3526 gui.def_back_pixel = gui.back_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3527
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3528 /* Get the colors for the highlight groups (gui_check_colors() might have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3529 * changed them) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3530 highlight_gui_started();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3531
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3532 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3533 * Setting the gui constants
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3534 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3535 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3536 gui.menu_height = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3537 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3538 gui.scrollbar_height = gui.scrollbar_width = 15; /* cheat 1 overlap */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3539 gui.border_offset = gui.border_width = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3540
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3541 #if defined(FEAT_GUI) && defined(MACOS_X)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3542 /* If Quartz-style text antialiasing is available (see
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3543 gui_mch_draw_string() below), enable it for all font sizes. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3544 vim_setenv((char_u *)"QDTEXT_MINSIZE", (char_u *)"1");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3545 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3546
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3547 #ifdef USE_MOUSEWHEEL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3548 eventTypeSpec.eventClass = kEventClassMouse;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3549 eventTypeSpec.eventKind = kEventMouseWheelMoved;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3550 mouseWheelHandlerUPP = NewEventHandlerUPP(gui_mac_mouse_wheel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3551 if (noErr != InstallApplicationEventHandler(mouseWheelHandlerUPP, 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3552 &eventTypeSpec, NULL, &mouseWheelHandlerRef))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3553 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3554 mouseWheelHandlerRef = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3555 DisposeEventHandlerUPP(mouseWheelHandlerUPP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3556 mouseWheelHandlerUPP = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3557 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3558 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3559
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3560 #ifdef USE_CARBONKEYHANDLER
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3561 eventTypeSpec.eventClass = kEventClassTextInput;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3562 eventTypeSpec.eventKind = kEventUnicodeForKeyEvent;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3563 keyEventHandlerUPP = NewEventHandlerUPP(gui_mac_doKeyEventCarbon);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3564 if (noErr != InstallApplicationEventHandler(keyEventHandlerUPP, 1,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3565 &eventTypeSpec, NULL, &keyEventHandlerRef))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3566 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3567 keyEventHandlerRef = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3568 DisposeEventHandlerUPP(keyEventHandlerUPP);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3569 keyEventHandlerUPP = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3570 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3571 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3572
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3573 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3574 #ifdef FEAT_MBYTE
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3575 set_option_value((char_u *)"encoding", 0L, (char_u *)"utf-8", 0);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3576 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3577 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3578
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3579 /* TODO: Load bitmap if using TOOLBAR */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3580 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3581 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3582
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3583 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3584 * Called when the foreground or background color has been changed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3585 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3586 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3587 gui_mch_new_colors()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3588 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3589 /* TODO:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3590 * This proc is called when Normal is set to a value
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3591 * so what msut be done? I don't know
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3592 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3593 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3594
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3595 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3596 * Open the GUI window which was created by a call to gui_mch_init().
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3597 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3598 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3599 gui_mch_open()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3600 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3601 ShowWindow(gui.VimWindow);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3602
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3603 if (gui_win_x != -1 && gui_win_y != -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3604 gui_mch_set_winpos(gui_win_x, gui_win_y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3605
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3606 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3607 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3608 * Make the GUI the foreground process (in case it was launched
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3609 * from the Terminal or via :gui).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3610 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3611 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3612 ProcessSerialNumber psn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3613 if (GetCurrentProcess(&psn) == noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3614 SetFrontProcess(&psn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3615 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3616 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3617
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3618 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3619 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3620
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3621 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3622 gui_mch_exit(int rc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3623 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3624 /* TODO: find out all what is missing here? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3625 DisposeRgn(cursorRgn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3626
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3627 #ifdef USE_CARBONKEYHANDLER
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3628 if (keyEventHandlerUPP)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3629 DisposeEventHandlerUPP(keyEventHandlerUPP);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3630 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3631
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3632 #ifdef USE_MOUSEWHEEL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3633 if (mouseWheelHandlerUPP != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3634 DisposeEventHandlerUPP(mouseWheelHandlerUPP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3635 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3636
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3637 #ifdef USE_ATSUI_DRAWING
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3638 if (gFontStyle)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3639 ATSUDisposeStyle(gFontStyle);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3640 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3641
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3642 /* Exit to shell? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3643 exit(rc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3644 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3645
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3646 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3647 * Get the position of the top left corner of the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3648 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3649 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3650 gui_mch_get_winpos(int *x, int *y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3651 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3652 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3653 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3654 Rect bounds;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3655 OSStatus status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3656
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3657 /* Carbon >= 1.0.2, MacOS >= 8.5 */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3658 status = GetWindowBounds(gui.VimWindow, kWindowStructureRgn, &bounds);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3659
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3660 if (status != noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3661 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3662 *x = bounds.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3663 *y = bounds.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3664 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3665 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3666 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3667 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3668
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3669 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3670 * Set the position of the top left corner of the window to the given
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3671 * coordinates.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3672 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3673 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3674 gui_mch_set_winpos(int x, int y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3675 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3676 /* TODO: Should make sure the window is move within range
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3677 * e.g.: y > ~16 [Menu bar], x > 0, x < screen width
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3678 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3679 MoveWindow(gui.VimWindow, x, y, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3680 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3681
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3682 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3683 gui_mch_set_shellsize(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3684 int width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3685 int height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3686 int min_width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3687 int min_height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3688 int base_width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3689 int base_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3690 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3691 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3692 CGrafPtr VimPort;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3693 Rect VimBound;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3694 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3695
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3696 if (gui.which_scrollbars[SBAR_LEFT])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3697 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3698 #ifdef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3699 VimPort = GetWindowPort(gui.VimWindow);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3700 GetPortBounds(VimPort, &VimBound);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3701 VimBound.left = -gui.scrollbar_width; /* + 1;*/
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3702 SetPortBounds(VimPort, &VimBound);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3703 /* GetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &winPortRect); ??*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3704 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3705 gui.VimWindow->portRect.left = -gui.scrollbar_width; /* + 1;*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3706 /* SetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &winPortRect); ??*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3707 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3708 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3709 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3710 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3711 #ifdef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3712 VimPort = GetWindowPort(gui.VimWindow);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3713 GetPortBounds(VimPort, &VimBound);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3714 VimBound.left = 0;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3715 SetPortBounds(VimPort, &VimBound);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3716 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3717 gui.VimWindow->portRect.left = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3718 #endif;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3719 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3720
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3721 SizeWindow(gui.VimWindow, width, height, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3722
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3723 gui_resize_shell(width, height);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3724 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3725
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3726 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3727 * Get the screen dimensions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3728 * Allow 10 pixels for horizontal borders, 40 for vertical borders.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3729 * Is there no way to find out how wide the borders really are?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3730 * TODO: Add live udate of those value on suspend/resume.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3731 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3732 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3733 gui_mch_get_screen_dimensions(screen_w, screen_h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3734 int *screen_w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3735 int *screen_h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3736 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3737 GDHandle dominantDevice = GetMainDevice();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3738 Rect screenRect = (**dominantDevice).gdRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3739
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3740 *screen_w = screenRect.right - 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3741 *screen_h = screenRect.bottom - 40;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3742 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3743
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3744
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3745 #if defined(USE_CARBONIZED) && defined(MACOS_X)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3746 /*
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3747 * Open the Font Panel and wait for the user to select a font and
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3748 * close the panel. Then fill the buffer pointed to by font_name with
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3749 * the name and size of the selected font and return the font's handle,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3750 * or NOFONT in case of an error.
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3751 */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3752 static GuiFont
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3753 gui_mac_select_font(char_u *font_name)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3754 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3755 GuiFont selected_font = NOFONT;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3756 OSStatus status;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3757 FontSelectionQDStyle curr_font;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3758
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3759 /* Initialize the Font Panel with the current font. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3760 curr_font.instance.fontFamily = gui.norm_font & 0xFFFF;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3761 curr_font.size = (gui.norm_font >> 16);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3762 /* TODO: set fontStyle once styles are supported in gui_mac_find_font() */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3763 curr_font.instance.fontStyle = 0;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3764 curr_font.hasColor = false;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3765 curr_font.version = 0; /* version number of the style structure */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3766 status = SetFontInfoForSelection(kFontSelectionQDType,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3767 /*numStyles=*/1, &curr_font, /*eventTarget=*/NULL);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3768
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3769 gFontPanelInfo.family = curr_font.instance.fontFamily;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3770 gFontPanelInfo.style = curr_font.instance.fontStyle;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3771 gFontPanelInfo.size = curr_font.size;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3772
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3773 /* Pop up the Font Panel. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3774 status = FPShowHideFontPanel();
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3775 if (status == noErr)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3776 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3777 /*
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3778 * The Font Panel is modeless. We really need it to be modal,
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3779 * so we spin in an event loop until the panel is closed.
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3780 */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3781 gFontPanelInfo.isPanelVisible = true;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3782 while (gFontPanelInfo.isPanelVisible)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3783 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3784 EventRecord e;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3785 WaitNextEvent(everyEvent, &e, /*sleep=*/20, /*mouseRgn=*/NULL);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3786 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3787
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3788 GetFontPanelSelection(font_name);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3789 selected_font = gui_mac_find_font(font_name);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3790 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3791 return selected_font;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3792 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3793 #endif
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3794
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3795
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3796 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3797 * Initialise vim to use the font with the given name. Return FAIL if the font
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3798 * could not be loaded, OK otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3799 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3800 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3801 gui_mch_init_font(font_name, fontset)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3802 char_u *font_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3803 int fontset; /* not used */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3804 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3805 /* TODO: Add support for bold italic underline proportional etc... */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3806 Str255 suggestedFont = "\pMonaco";
170
8c60f65311fa updated for version 7.0052
vimboss
parents: 168
diff changeset
3807 int suggestedSize = 10;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3808 FontInfo font_info;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3809 short font_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3810 GuiFont font;
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3811 char_u used_font_name[512];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3812
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3813 #ifdef USE_ATSUI_DRAWING
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3814 if (gFontStyle == NULL)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3815 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3816 if (ATSUCreateStyle(&gFontStyle) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3817 gFontStyle = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3818 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3819 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3820
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3821 if (font_name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3822 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3823 /* First try to get the suggested font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3824 GetFNum(suggestedFont, &font_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3825
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3826 if (font_id == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3827 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3828 /* Then pickup the standard application font */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3829 font_id = GetAppFont();
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3830 STRCPY(used_font_name, "default");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3831 }
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3832 else
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3833 STRCPY(used_font_name, "Monaco");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3834 font = (suggestedSize << 16) + ((long) font_id & 0xFFFF);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3835 }
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3836 #if defined(USE_CARBONIZED) && defined(MACOS_X)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3837 else if (STRCMP(font_name, "*") == 0)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3838 {
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3839 char_u *new_p_guifont;
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3840
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3841 font = gui_mac_select_font(used_font_name);
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3842 if (font == NOFONT)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3843 return FAIL;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3844
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3845 /* Set guifont to the name of the selected font. */
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3846 new_p_guifont = alloc(STRLEN(used_font_name) + 1);
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3847 if (new_p_guifont != NULL)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3848 {
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3849 STRCPY(new_p_guifont, used_font_name);
13
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3850 vim_free(p_guifont);
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3851 p_guifont = new_p_guifont;
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3852 /* Replace spaces in the font name with underscores. */
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3853 for ( ; *new_p_guifont; ++new_p_guifont)
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3854 {
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3855 if (*new_p_guifont == ' ')
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3856 *new_p_guifont = '_';
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3857 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3858 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3859 }
24d5189d3956 updated for version 7.0005
vimboss
parents: 9
diff changeset
3860 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3861 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3862 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3863 font = gui_mac_find_font(font_name);
418
84825cc6f049 updated for version 7.0109
vimboss
parents: 308
diff changeset
3864 vim_strncpy(used_font_name, font_name, sizeof(used_font_name) - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3865
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3866 if (font == NOFONT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3867 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3868 }
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3869
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3870 gui.norm_font = font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3871
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3872 hl_set_font_name(used_font_name);
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3873
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3874 TextSize(font >> 16);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3875 TextFont(font & 0xFFFF);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3876
189
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3877 GetFontInfo(&font_info);
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3878
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3879 gui.char_ascent = font_info.ascent;
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3880 gui.char_width = CharWidth('_');
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3881 gui.char_height = font_info.ascent + font_info.descent + p_linespace;
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
3882
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3883 #ifdef USE_ATSUI_DRAWING
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3884 ATSUFontID fontID;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3885 Fixed fontSize;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3886 ATSStyleRenderingOptions fontOptions;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3887
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3888 if (gFontStyle)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3889 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3890 fontID = font & 0xFFFF;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3891 fontSize = Long2Fix(font >> 16);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3892
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3893 /* No antialiasing by default (do not attempt to touch antialising
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3894 * options on pre-Jaguar) */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3895 fontOptions =
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3896 #ifdef MACOS_X
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3897 (gMacSystemVersion >= 0x1020) ?
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3898 kATSStyleNoAntiAliasing :
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3899 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3900 kATSStyleNoOptions;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3901
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3902 ATSUAttributeTag attribTags[] =
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3903 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3904 kATSUFontTag, kATSUSizeTag, kATSUStyleRenderingOptionsTag,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3905 kATSUMaxATSUITagValue+1
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3906 };
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3907 ByteCount attribSizes[] =
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3908 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3909 sizeof(ATSUFontID), sizeof(Fixed),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3910 sizeof(ATSStyleRenderingOptions), sizeof font
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3911 };
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3912 ATSUAttributeValuePtr attribValues[] =
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3913 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3914 &fontID, &fontSize, &fontOptions, &font
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3915 };
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3916
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3917 /* Convert font id to ATSUFontID */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3918 if (FMGetFontFromFontFamilyInstance(fontID, 0, &fontID, NULL) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3919 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3920 if (ATSUSetAttributes(gFontStyle,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3921 (sizeof attribTags)/sizeof(ATSUAttributeTag),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3922 attribTags, attribSizes, attribValues) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3923 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3924 ATSUDisposeStyle(gFontStyle);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3925 gFontStyle = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3926 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3927 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3928 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3929 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3930
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3931 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3932
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3933 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3934
444
d0d15b184c56 updated for version 7.0116
vimboss
parents: 418
diff changeset
3935 /*
d0d15b184c56 updated for version 7.0116
vimboss
parents: 418
diff changeset
3936 * Adjust gui.char_height (after 'linespace' was changed).
d0d15b184c56 updated for version 7.0116
vimboss
parents: 418
diff changeset
3937 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3938 int
444
d0d15b184c56 updated for version 7.0116
vimboss
parents: 418
diff changeset
3939 gui_mch_adjust_charheight()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3940 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3941 FontInfo font_info;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3942
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
3943 GetFontInfo(&font_info);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3944 gui.char_height = font_info.ascent + font_info.descent + p_linespace;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3945 gui.char_ascent = font_info.ascent + p_linespace / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3946 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3947 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3948
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3949 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3950 * Get a font structure for highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3951 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3952 GuiFont
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3953 gui_mch_get_font(name, giveErrorIfMissing)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3954 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3955 int giveErrorIfMissing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3956 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3957 GuiFont font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3958
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3959 font = gui_mac_find_font(name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3960
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3961 if (font == NOFONT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3962 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3963 if (giveErrorIfMissing)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3964 EMSG2(_(e_font), name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3965 return NOFONT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3966 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3967 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3968 * TODO : Accept only monospace
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3969 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3970
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3971 return font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3972 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3973
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents: 37
diff changeset
3974 #if defined(FEAT_EVAL) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3975 /*
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3976 * Return the name of font "font" in allocated memory.
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3977 * Don't know how to get the actual name, thus use the provided name.
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3978 */
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3979 char_u *
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3980 gui_mch_get_fontname(font, name)
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3981 GuiFont font;
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3982 char_u *name;
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3983 {
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3984 if (name == NULL)
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3985 return NULL;
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3986 return vim_strsave(name);
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3987 }
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents: 37
diff changeset
3988 #endif
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3989
fdf55076c53f updated for version 7.0022
vimboss
parents: 36
diff changeset
3990 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3991 * Set the current text font.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3992 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3993 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3994 gui_mch_set_font(font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3995 GuiFont font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3996 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3997 #ifdef USE_ATSUI_DRAWING
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3998 GuiFont currFont;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
3999 ByteCount actualFontByteCount;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4000 ATSUFontID fontID;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4001 Fixed fontSize;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4002 ATSStyleRenderingOptions fontOptions;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4003
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4004 if (gFontStyle)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4005 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4006 /* Avoid setting same font again */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4007 if (ATSUGetAttribute(gFontStyle, kATSUMaxATSUITagValue+1, sizeof font,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4008 &currFont, &actualFontByteCount) == noErr &&
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4009 actualFontByteCount == (sizeof font))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4010 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4011 if (currFont == font)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4012 return;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4013 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4014
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4015 fontID = font & 0xFFFF;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4016 fontSize = Long2Fix(font >> 16);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4017 /* Respect p_antialias setting only for wide font.
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4018 * The reason for doing this at the moment is a bit complicated,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4019 * but it's mainly because a) latin (non-wide) aliased fonts
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4020 * look bad in OS X 10.3.x and below (due to a bug in ATS), and
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4021 * b) wide multibyte input does not suffer from that problem. */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4022 fontOptions =
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4023 #ifdef MACOS_X
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4024 (p_antialias && (font == gui.wide_font)) ?
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4025 kATSStyleNoOptions : kATSStyleNoAntiAliasing;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4026 #else
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4027 kATSStyleNoOptions;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4028 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4029
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4030 ATSUAttributeTag attribTags[] =
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4031 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4032 kATSUFontTag, kATSUSizeTag, kATSUStyleRenderingOptionsTag,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4033 kATSUMaxATSUITagValue+1
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4034 };
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4035 ByteCount attribSizes[] =
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4036 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4037 sizeof(ATSUFontID), sizeof(Fixed),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4038 sizeof(ATSStyleRenderingOptions), sizeof font
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4039 };
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4040 ATSUAttributeValuePtr attribValues[] =
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4041 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4042 &fontID, &fontSize, &fontOptions, &font
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4043 };
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4044
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4045 if (FMGetFontFromFontFamilyInstance(fontID, 0, &fontID, NULL) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4046 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4047 if (ATSUSetAttributes(gFontStyle,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4048 (sizeof attribTags)/sizeof(ATSUAttributeTag),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4049 attribTags, attribSizes, attribValues) != noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4050 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4051 #ifndef NDEBUG
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4052 fprintf(stderr, "couldn't set font style\n");
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4053 #endif
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4054 ATSUDisposeStyle(gFontStyle);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4055 gFontStyle = NULL;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4056 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4057 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4058
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4059 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4060
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4061 if (!gIsFontFallbackSet)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4062 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4063 /* Setup automatic font substitution. The user's guifontwide
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4064 * is tried first, then the system tries other fonts. */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4065 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4066 ATSUAttributeTag fallbackTags[] = { kATSULineFontFallbacksTag };
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4067 ByteCount fallbackSizes[] = { sizeof(ATSUFontFallbacks) };
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4068 ATSUCreateFontFallbacks(&gFontFallbacks);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4069 ATSUSetObjFontFallbacks(gFontFallbacks, );
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4070 */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4071 if (gui.wide_font)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4072 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4073 ATSUFontID fallbackFonts;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4074 gIsFontFallbackSet = TRUE;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4075
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4076 if (FMGetFontFromFontFamilyInstance(
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4077 (gui.wide_font & 0xFFFF),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4078 0,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4079 &fallbackFonts,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4080 NULL) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4081 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4082 ATSUSetFontFallbacks((sizeof fallbackFonts)/sizeof(ATSUFontID), &fallbackFonts, kATSUSequentialFallbacksPreferred);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4083 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4084 /*
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4085 ATSUAttributeValuePtr fallbackValues[] = { };
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4086 */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4087 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4088 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4089 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4090 TextSize(font >> 16);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4091 TextFont(font & 0xFFFF);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4092 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4093
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4094 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4095 * If a font is not going to be used, free its structure.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4096 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4097 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4098 gui_mch_free_font(font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4099 GuiFont font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4100 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4101 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4102 * Free font when "font" is not 0.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4103 * Nothing to do in the current implementation, since
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4104 * nothing is allocated for each font used.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4105 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4106 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4108 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4109 hex_digit(c)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4110 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4111 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4112 if (isdigit(c))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4113 return c - '0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4114 c = TOLOWER_ASC(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4115 if (c >= 'a' && c <= 'f')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4116 return c - 'a' + 10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4117 return -1000;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4118 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4120 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4121 * Return the Pixel value (color) for the given color name. This routine was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4122 * pretty much taken from example code in the Silicon Graphics OSF/Motif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4123 * Programmer's Guide.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4124 * Return INVALCOLOR when failed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4125 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4126 guicolor_T
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4127 gui_mch_get_color(name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4128 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4129 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4130 /* TODO: Add support for the new named color of MacOS 8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4131 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4132 RGBColor MacColor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4133 // guicolor_T color = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4135 typedef struct guicolor_tTable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4136 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4137 char *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4138 guicolor_T color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4139 } guicolor_tTable;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4141 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4142 * The comment at the end of each line is the source
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4143 * (Mac, Window, Unix) and the number is the unix rgb.txt value
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4144 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4145 static guicolor_tTable table[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4146 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4147 {"Black", RGB(0x00, 0x00, 0x00)},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4148 {"darkgray", RGB(0x80, 0x80, 0x80)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4149 {"darkgrey", RGB(0x80, 0x80, 0x80)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4150 {"Gray", RGB(0xC0, 0xC0, 0xC0)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4151 {"Grey", RGB(0xC0, 0xC0, 0xC0)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4152 {"lightgray", RGB(0xE0, 0xE0, 0xE0)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4153 {"lightgrey", RGB(0xE0, 0xE0, 0xE0)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4154 {"white", RGB(0xFF, 0xFF, 0xFF)},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4155 {"darkred", RGB(0x80, 0x00, 0x00)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4156 {"red", RGB(0xDD, 0x08, 0x06)}, /*M*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4157 {"lightred", RGB(0xFF, 0xA0, 0xA0)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4158 {"DarkBlue", RGB(0x00, 0x00, 0x80)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4159 {"Blue", RGB(0x00, 0x00, 0xD4)}, /*M*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4160 {"lightblue", RGB(0xA0, 0xA0, 0xFF)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4161 {"DarkGreen", RGB(0x00, 0x80, 0x00)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4162 {"Green", RGB(0x00, 0x64, 0x11)}, /*M*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4163 {"lightgreen", RGB(0xA0, 0xFF, 0xA0)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4164 {"DarkCyan", RGB(0x00, 0x80, 0x80)}, /*W ?0x307D7E */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4165 {"cyan", RGB(0x02, 0xAB, 0xEA)}, /*M*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4166 {"lightcyan", RGB(0xA0, 0xFF, 0xFF)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4167 {"darkmagenta", RGB(0x80, 0x00, 0x80)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4168 {"magenta", RGB(0xF2, 0x08, 0x84)}, /*M*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4169 {"lightmagenta",RGB(0xF0, 0xA0, 0xF0)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4170 {"brown", RGB(0x80, 0x40, 0x40)}, /*W*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4171 {"yellow", RGB(0xFC, 0xF3, 0x05)}, /*M*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4172 {"lightyellow", RGB(0xFF, 0xFF, 0xA0)}, /*M*/
308
74e9d19831c2 updated for version 7.0081
vimboss
parents: 273
diff changeset
4173 {"darkyellow", RGB(0xBB, 0xBB, 0x00)}, /*U*/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4174 {"SeaGreen", RGB(0x2E, 0x8B, 0x57)}, /*W 0x4E8975 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4175 {"orange", RGB(0xFC, 0x80, 0x00)}, /*W 0xF87A17 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4176 {"Purple", RGB(0xA0, 0x20, 0xF0)}, /*W 0x8e35e5 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4177 {"SlateBlue", RGB(0x6A, 0x5A, 0xCD)}, /*W 0x737CA1 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4178 {"Violet", RGB(0x8D, 0x38, 0xC9)}, /*U*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4179 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4181 int r, g, b;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4182 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4184 if (name[0] == '#' && strlen((char *) name) == 7)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4185 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4186 /* Name is in "#rrggbb" format */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4187 r = hex_digit(name[1]) * 16 + hex_digit(name[2]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4188 g = hex_digit(name[3]) * 16 + hex_digit(name[4]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4189 b = hex_digit(name[5]) * 16 + hex_digit(name[6]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4190 if (r < 0 || g < 0 || b < 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4191 return INVALCOLOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4192 return RGB(r, g, b);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4193 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4194 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4195 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4196 if (STRICMP(name, "hilite") == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4197 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4198 LMGetHiliteRGB(&MacColor);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4199 return (RGB(MacColor.red >> 8, MacColor.green >> 8, MacColor.blue >> 8));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4200 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4201 /* Check if the name is one of the colors we know */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4202 for (i = 0; i < sizeof(table) / sizeof(table[0]); i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4203 if (STRICMP(name, table[i].name) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4204 return table[i].color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4205 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4207
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4208 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4209 * Last attempt. Look in the file "$VIM/rgb.txt".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4210 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4211 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4212 #define LINE_LEN 100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4213 FILE *fd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4214 char line[LINE_LEN];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4215 char_u *fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4217 #ifdef COLON_AS_PATHSEP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4218 fname = expand_env_save((char_u *)"$VIMRUNTIME:rgb.txt");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4219 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4220 fname = expand_env_save((char_u *)"$VIMRUNTIME/rgb.txt");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4221 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4222 if (fname == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4223 return INVALCOLOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4224
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4225 fd = fopen((char *)fname, "rt");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4226 vim_free(fname);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4227 if (fd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4228 return INVALCOLOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4229
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4230 while (!feof(fd))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4231 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4232 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4233 int pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4234 char *color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4236 fgets(line, LINE_LEN, fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4237 len = strlen(line);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4239 if (len <= 1 || line[len-1] != '\n')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4240 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4241
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4242 line[len-1] = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4243
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4244 i = sscanf(line, "%d %d %d %n", &r, &g, &b, &pos);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4245 if (i != 3)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4246 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4247
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4248 color = line + pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4249
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4250 if (STRICMP(color, name) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4251 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4252 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4253 return (guicolor_T) RGB(r, g, b);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4254 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4255 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4256 fclose(fd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4257 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4258
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4259 return INVALCOLOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4260 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4261
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4262 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4263 * Set the current text foreground color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4264 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4265 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4266 gui_mch_set_fg_color(color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4267 guicolor_T color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4268 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4269 RGBColor TheColor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4270
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4271 TheColor.red = Red(color) * 0x0101;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4272 TheColor.green = Green(color) * 0x0101;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4273 TheColor.blue = Blue(color) * 0x0101;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4274
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4275 RGBForeColor(&TheColor);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4276 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4277
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4278 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4279 * Set the current text background color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4280 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4281 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4282 gui_mch_set_bg_color(color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4283 guicolor_T color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4284 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4285 RGBColor TheColor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4286
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4287 TheColor.red = Red(color) * 0x0101;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4288 TheColor.green = Green(color) * 0x0101;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4289 TheColor.blue = Blue(color) * 0x0101;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4290
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4291 RGBBackColor(&TheColor);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4292 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4293
212
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
4294 /*
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
4295 * Set the current text speail color. TODO
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
4296 */
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
4297 void
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
4298 gui_mch_set_sp_color(color)
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
4299 guicolor_T color;
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
4300 {
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
4301 }
e39657bbbb98 updated for version 7.0060
vimboss
parents: 189
diff changeset
4302
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4303 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4304 gui_mch_draw_string(row, col, s, len, flags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4305 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4306 int col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4307 char_u *s;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4308 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4309 int flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4310 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4311 #ifdef FEAT_MBYTE
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4312 #ifdef USE_ATSUI_DRAWING
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4313 /* ATSUI requires utf-16 strings */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4314 UniCharCount utf16_len;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4315 UniChar *tofree = mac_enc_to_utf16(s, len, (size_t *)&utf16_len);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4316 utf16_len /= sizeof(UniChar);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4317 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4318 char_u *tofree = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4319
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4320 if (output_conv.vc_type != CONV_NONE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4321 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4322 tofree = string_convert(&output_conv, s, &len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4323 if (tofree != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4324 s = tofree;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4325 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4326 #endif
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4327 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4328
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4329 #if defined(FEAT_GUI) && defined(MACOS_X)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4330 /* ATSUI automatically antialiases text */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4331 #ifndef USE_ATSUI_DRAWING
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4332 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4333 * On OS X, try using Quartz-style text antialiasing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4334 */
189
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
4335 if (gMacSystemVersion >= 0x1020)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4336 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4337 /* Quartz antialiasing is available only in OS 10.2 and later. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4338 UInt32 qd_flags = (p_antialias ?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4339 kQDUseCGTextRendering | kQDUseCGTextMetrics : 0);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4340 QDSwapTextFlags(qd_flags);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4341 }
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4342 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4343
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4344 /*
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4345 * When antialiasing we're using srcOr mode, we have to clear the block
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4346 * before drawing the text.
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4347 * Also needed when 'linespace' is non-zero to remove the cursor and
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4348 * underlining.
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4349 * But not when drawing transparently.
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4350 * The following is like calling gui_mch_clear_block(row, col, row, col +
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4351 * len - 1), but without setting the bg color to gui.back_pixel.
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4352 */
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4353 #ifdef USE_ATSUI_DRAWING
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4354 if ((flags & DRAW_TRANSP) == 0)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4355 #else
189
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
4356 if (((gMacSystemVersion >= 0x1020 && p_antialias) || p_linespace != 0)
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4357 && !(flags & DRAW_TRANSP))
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4358 #endif
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4359 {
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4360 Rect rc;
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4361
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4362 rc.left = FILL_X(col);
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4363 rc.top = FILL_Y(row);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4364 #ifdef FEAT_MBYTE
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4365 /* Multibyte computation taken from gui_w32.c */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4366 if (has_mbyte)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4367 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4368 int cell_len = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4369 int n;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4370
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4371 /* Compute the length in display cells. */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4372 for (n = 0; n < len; n += MB_BYTE2LEN(s[n]))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4373 cell_len += (*mb_ptr2cells)(s + n);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4374 rc.right = FILL_X(col + cell_len);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4375 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4376 else
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4377 #endif
36
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4378 rc.right = FILL_X(col + len) + (col + len == Columns);
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4379 rc.bottom = FILL_Y(row + 1);
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4380 EraseRect(&rc);
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4381 }
125e80798a85 updated for version 7.0021
vimboss
parents: 26
diff changeset
4382
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4383 #ifndef USE_ATSUI_DRAWING
189
504c627f7474 updated for version 7.0057
vimboss
parents: 170
diff changeset
4384 if (gMacSystemVersion >= 0x1020 && p_antialias)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4385 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4386 StyleParameter face;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4388 face = normal;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4389 if (flags & DRAW_BOLD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4390 face |= bold;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4391 if (flags & DRAW_UNDERL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4392 face |= underline;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4393 TextFace(face);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4395 /* Quartz antialiasing works only in srcOr transfer mode. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4396 TextMode(srcOr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4397
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4398 MoveTo(TEXT_X(col), TEXT_Y(row));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4399 DrawText((char*)s, 0, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4400 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4401 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4402 #endif
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4403 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4404 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4405 /* Use old-style, non-antialiased QuickDraw text rendering. */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4406 TextMode(srcCopy);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4407 TextFace(normal);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4408
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4409 /* SelectFont(hdc, gui.currFont); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4410
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4411 if (flags & DRAW_TRANSP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4412 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4413 TextMode(srcOr);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4414 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4415
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4416 MoveTo(TEXT_X(col), TEXT_Y(row));
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4417 #ifdef USE_ATSUI_DRAWING
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4418 ATSUTextLayout textLayout;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4419
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4420 if (ATSUCreateTextLayoutWithTextPtr(tofree,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4421 kATSUFromTextBeginning, kATSUToTextEnd,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4422 utf16_len,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4423 (gFontStyle ? 1 : 0), &utf16_len,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4424 (gFontStyle ? &gFontStyle : NULL),
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4425 &textLayout) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4426 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4427 ATSUSetTransientFontMatching(textLayout, TRUE);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4428
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4429 ATSUDrawText(textLayout,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4430 kATSUFromTextBeginning, kATSUToTextEnd,
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4431 kATSUUseGrafPortPenLoc, kATSUUseGrafPortPenLoc);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4432
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4433 ATSUDisposeTextLayout(textLayout);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4434 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4435 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4436 DrawText((char *)s, 0, len);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4437
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4439 if (flags & DRAW_BOLD)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4440 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4441 TextMode(srcOr);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4442 MoveTo(TEXT_X(col) + 1, TEXT_Y(row));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4443 DrawText((char *)s, 0, len);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4444 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4445
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4446 if (flags & DRAW_UNDERL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4447 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4448 MoveTo(FILL_X(col), FILL_Y(row + 1) - 1);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4449 LineTo(FILL_X(col + len) - 1, FILL_Y(row + 1) - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4450 }
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4451 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4452 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4453
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4454 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4455 vim_free(tofree);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4456 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4457 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4458
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4459 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4460 * Return OK if the key with the termcap name "name" is supported.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4461 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4462 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4463 gui_mch_haskey(name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4464 char_u *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4465 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4466 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4467
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4468 for (i = 0; special_keys[i].key_sym != (KeySym)0; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4469 if (name[0] == special_keys[i].vim_code0 &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4470 name[1] == special_keys[i].vim_code1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4471 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4472 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4473 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4474
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4475 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4476 gui_mch_beep()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4477 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4478 SysBeep(1); /* Should this be 0? (????) */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4479 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4480
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4481 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4482 gui_mch_flash(msec)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4483 int msec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4484 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4485 /* Do a visual beep by reversing the foreground and background colors */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4486 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4487
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4488 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4489 * Note: InvertRect() excludes right and bottom of rectangle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4490 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4491 rc.left = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4492 rc.top = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4493 rc.right = gui.num_cols * gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4494 rc.bottom = gui.num_rows * gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4495 InvertRect(&rc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4497 ui_delay((long)msec, TRUE); /* wait for some msec */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4498
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4499 InvertRect(&rc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4500 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4501
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4502 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4503 * Invert a rectangle from row r, column c, for nr rows and nc columns.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4504 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4505 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4506 gui_mch_invert_rectangle(r, c, nr, nc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4507 int r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4508 int c;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4509 int nr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4510 int nc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4511 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4512 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4513
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4514 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4515 * Note: InvertRect() excludes right and bottom of rectangle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4516 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4517 rc.left = FILL_X(c);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4518 rc.top = FILL_Y(r);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4519 rc.right = rc.left + nc * gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4520 rc.bottom = rc.top + nr * gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4521 InvertRect(&rc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4522
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4523 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4524
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4525 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4526 * Iconify the GUI window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4527 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4528 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4529 gui_mch_iconify()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4530 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4531 /* TODO: find out what could replace iconify
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4532 * -window shade?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4533 * -hide application?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4534 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4535 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4536
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4537 #if defined(FEAT_EVAL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4538 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4539 * Bring the Vim window to the foreground.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4540 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4541 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4542 gui_mch_set_foreground()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4543 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4544 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4545 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4546 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4547
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4548 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4549 * Draw a cursor without focus.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4550 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4551 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4552 gui_mch_draw_hollow_cursor(color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4553 guicolor_T color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4554 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4555 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4556
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4557 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4558 * Note: FrameRect() excludes right and bottom of rectangle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4559 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4560 rc.left = FILL_X(gui.col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4561 rc.top = FILL_Y(gui.row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4562 rc.right = rc.left + gui.char_width;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4563 #ifdef FEAT_MBYTE
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4564 if (mb_lefthalve(gui.row, gui.col))
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4565 rc.right += gui.char_width;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4566 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4567 rc.bottom = rc.top + gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4568
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4569 gui_mch_set_fg_color(color);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4570
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4571 FrameRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4572 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4573
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4574 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4575 * Draw part of a cursor, only w pixels wide, and h pixels high.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4576 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4577 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4578 gui_mch_draw_part_cursor(w, h, color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4579 int w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4580 int h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4581 guicolor_T color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4582 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4583 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4584
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4585 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4586 /* vertical line should be on the right of current point */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4587 if (CURSOR_BAR_RIGHT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4588 rc.left = FILL_X(gui.col + 1) - w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4589 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4590 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4591 rc.left = FILL_X(gui.col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4592 rc.top = FILL_Y(gui.row) + gui.char_height - h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4593 rc.right = rc.left + w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4594 rc.bottom = rc.top + h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4595
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4596 gui_mch_set_fg_color(color);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4597
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4598 FrameRect(&rc);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4599 // PaintRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4600 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4601
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4602
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4603
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4604 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4605 * Catch up with any queued X events. This may put keyboard input into the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4606 * input buffer, call resize call-backs, trigger timers etc. If there is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4607 * nothing in the X event queue (& no timers pending), then we return
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4608 * immediately.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4609 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4610 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4611 gui_mch_update()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4612 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4613 /* TODO: find what to do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4614 * maybe call gui_mch_wait_for_chars (0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4615 * more like look at EventQueue then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4616 * call heart of gui_mch_wait_for_chars;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4617 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4618 * if (eventther)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4619 * gui_mac_handle_event(&event);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4620 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4621 EventRecord theEvent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4622
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4623 if (EventAvail(everyEvent, &theEvent))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4624 if (theEvent.what != nullEvent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4625 gui_mch_wait_for_chars(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4626 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4627
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4628 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4629 * Simple wrapper to neglect more easily the time
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4630 * spent inside WaitNextEvent while profiling.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4631 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4632
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4633 #if defined(__MWERKS__) /* only in Codewarrior */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4634 # pragma profile reset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4635 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4636 pascal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4637 Boolean
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4638 WaitNextEventWrp(EventMask eventMask, EventRecord *theEvent, UInt32 sleep, RgnHandle mouseRgn)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4639 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4640 if (((long) sleep) < -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4641 sleep = 32767;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4642 return WaitNextEvent(eventMask, theEvent, sleep, mouseRgn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4643 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4644
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4645 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4646 * GUI input routine called by gui_wait_for_chars(). Waits for a character
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4647 * from the keyboard.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4648 * wtime == -1 Wait forever.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4649 * wtime == 0 This should never happen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4650 * wtime > 0 Wait wtime milliseconds for a character.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4651 * Returns OK if a character was found to be available within the given time,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4652 * or FAIL otherwise.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4653 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4654 #if defined(__MWERKS__) /* only in Codewarrior */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4655 # pragma profile reset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4656 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4657 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4658 gui_mch_wait_for_chars(wtime)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4659 int wtime;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4660 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4661 EventMask mask = (everyEvent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4662 EventRecord event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4663 long entryTick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4664 long currentTick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4665 long sleeppyTick;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4666
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4667 /* If we are providing life feedback with the scrollbar,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4668 * we don't want to try to wait for an event, or else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4669 * there won't be any life feedback.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4670 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4671 if (dragged_sb != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4672 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4673 /* TODO: Check if FAIL is the proper return code */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4674
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4675 entryTick = TickCount();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4676
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4677 allow_scrollbar = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4678
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4679 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4680 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4681 /* if (dragRectControl == kCreateEmpty)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4682 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4683 dragRgn = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4684 dragRectControl = kNothing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4685 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4686 else*/ if (dragRectControl == kCreateRect)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4687 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4688 dragRgn = cursorRgn;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4689 RectRgn(dragRgn, &dragRect);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4690 dragRectControl = kNothing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4691 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4692 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4693 * Don't use gui_mch_update() because then we will spin-lock until a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4694 * char arrives, instead we use WaitNextEventWrp() to hang until an
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4695 * event arrives. No need to check for input_buf_full because we are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4696 * returning as soon as it contains a single char.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4697 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4698 /* TODO: reduce wtime accordinly??? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4699 if (wtime > -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4700 sleeppyTick = 60*wtime/1000;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4701 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4702 sleeppyTick = 32767;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4703 if (WaitNextEventWrp(mask, &event, sleeppyTick, dragRgn))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4704 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4705 #ifdef USE_SIOUX
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4706 if (!SIOUXHandleOneEvent(&event))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4707 #endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4708 gui_mac_handle_event(&event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4709 if (input_available())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4710 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4711 allow_scrollbar = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4712 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4713 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4714 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4715 currentTick = TickCount();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4716 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4717 while ((wtime == -1) || ((currentTick - entryTick) < 60*wtime/1000));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4718
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4719 allow_scrollbar = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4720 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4721 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4722
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4723 #if defined(__MWERKS__) /* only in Codewarrior */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4724 # pragma profile reset
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4725 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4726
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4727 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4728 * Output routines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4729 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4730
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4731 /* Flush any output to the screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4732 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4733 gui_mch_flush()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4734 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4735 /* TODO: Is anything needed here? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4736 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4737
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4738 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4739 * Clear a rectangular region of the screen from text pos (row1, col1) to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4740 * (row2, col2) inclusive.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4741 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4742 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4743 gui_mch_clear_block(row1, col1, row2, col2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4744 int row1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4745 int col1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4746 int row2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4747 int col2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4748 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4749 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4750
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4751 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4752 * Clear one extra pixel at the far right, for when bold characters have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4753 * spilled over to the next column.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4754 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4755 rc.left = FILL_X(col1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4756 rc.top = FILL_Y(row1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4757 rc.right = FILL_X(col2 + 1) + (col2 == Columns - 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4758 rc.bottom = FILL_Y(row2 + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4759
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4760 gui_mch_set_bg_color(gui.back_pixel);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4761 EraseRect(&rc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4762 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4763
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4764 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4765 * Clear the whole text window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4766 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4767 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4768 gui_mch_clear_all()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4769 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4770 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4771
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4772 rc.left = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4773 rc.top = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4774 rc.right = Columns * gui.char_width + 2 * gui.border_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4775 rc.bottom = Rows * gui.char_height + 2 * gui.border_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4776
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4777 gui_mch_set_bg_color(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4778 EraseRect(&rc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4779 /* gui_mch_set_fg_color(gui.norm_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4780 FrameRect(&rc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4781 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4782 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4783
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4784 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4785 * Delete the given number of lines from the given row, scrolling up any
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4786 * text further down within the scroll region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4787 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4788 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4789 gui_mch_delete_lines(row, num_lines)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4790 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4791 int num_lines;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4792 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4793 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4794
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4795 /* changed without checking! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4796 rc.left = FILL_X(gui.scroll_region_left);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4797 rc.right = FILL_X(gui.scroll_region_right + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4798 rc.top = FILL_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4799 rc.bottom = FILL_Y(gui.scroll_region_bot + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4800
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4801 gui_mch_set_bg_color(gui.back_pixel);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4802 ScrollRect(&rc, 0, -num_lines * gui.char_height, (RgnHandle) nil);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4803
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4804 gui_clear_block(gui.scroll_region_bot - num_lines + 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4805 gui.scroll_region_left,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4806 gui.scroll_region_bot, gui.scroll_region_right);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4807 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4808
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4809 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4810 * Insert the given number of lines before the given row, scrolling down any
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4811 * following text within the scroll region.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4812 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4813 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4814 gui_mch_insert_lines(row, num_lines)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4815 int row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4816 int num_lines;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4817 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4818 Rect rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4819
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4820 rc.left = FILL_X(gui.scroll_region_left);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4821 rc.right = FILL_X(gui.scroll_region_right + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4822 rc.top = FILL_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4823 rc.bottom = FILL_Y(gui.scroll_region_bot + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4824
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4825 gui_mch_set_bg_color(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4826
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4827 ScrollRect(&rc, 0, gui.char_height * num_lines, (RgnHandle) nil);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4828
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4829 /* Update gui.cursor_row if the cursor scrolled or copied over */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4830 if (gui.cursor_row >= gui.row
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4831 && gui.cursor_col >= gui.scroll_region_left
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4832 && gui.cursor_col <= gui.scroll_region_right)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4833 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4834 if (gui.cursor_row <= gui.scroll_region_bot - num_lines)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4835 gui.cursor_row += num_lines;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4836 else if (gui.cursor_row <= gui.scroll_region_bot)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4837 gui.cursor_is_valid = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4838 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4839
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4840 gui_clear_block(row, gui.scroll_region_left,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4841 row + num_lines - 1, gui.scroll_region_right);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4842 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4843
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4844 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4845 * TODO: add a vim format to the clipboard which remember
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4846 * LINEWISE, CHARWISE, BLOCKWISE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4847 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4848
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4849 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4850 clip_mch_request_selection(cbd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4851 VimClipboard *cbd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4852 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4853
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4854 Handle textOfClip;
19
a81bc802c17c updated for version 7.0011
vimboss
parents: 13
diff changeset
4855 int flavor = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4856 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4857 Size scrapSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4858 ScrapFlavorFlags scrapFlags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4859 ScrapRef scrap = nil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4860 OSStatus error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4861 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4862 long scrapOffset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4863 long scrapSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4864 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4865 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4866 char *searchCR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4867 char_u *tempclip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4868
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4869
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4870 #ifdef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4871 error = GetCurrentScrap(&scrap);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4872 if (error != noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4873 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4874
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4875 error = GetScrapFlavorFlags(scrap, VIMSCRAPFLAVOR, &scrapFlags);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4876 if (error == noErr)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4877 {
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4878 error = GetScrapFlavorSize(scrap, VIMSCRAPFLAVOR, &scrapSize);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4879 if (error == noErr && scrapSize > 1)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4880 flavor = 1;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4881 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4882
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4883 if (flavor == 0)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4884 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4885 error = GetScrapFlavorFlags(scrap, kScrapFlavorTypeUnicode, &scrapFlags);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4886 if (error != noErr)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4887 return;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4888
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4889 error = GetScrapFlavorSize(scrap, kScrapFlavorTypeUnicode, &scrapSize);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4890 if (error != noErr)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4891 return;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4892 }
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4893
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4894 ReserveMem(scrapSize);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4895 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4896 /* Call to LoadScrap seem to avoid problem with crash on first paste */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4897 scrapSize = LoadScrap();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4898 scrapSize = GetScrap(nil, 'TEXT', &scrapOffset);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4899
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4900 if (scrapSize > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4901 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4902 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4903 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4904 /* In CARBON we don't need a Handle, a pointer is good */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4905 textOfClip = NewHandle(scrapSize);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4906 /* tempclip = lalloc(scrapSize+1, TRUE); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4907 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4908 textOfClip = NewHandle(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4909 #endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4910 HLock(textOfClip);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4911 #ifdef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4912 error = GetScrapFlavorData(scrap,
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4913 flavor ? VIMSCRAPFLAVOR : kScrapFlavorTypeUnicode,
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4914 &scrapSize, *textOfClip);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4915 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4916 scrapSize = GetScrap(textOfClip, 'TEXT', &scrapOffset);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4917 #endif
19
a81bc802c17c updated for version 7.0011
vimboss
parents: 13
diff changeset
4918 scrapSize -= flavor;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4919
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4920 if (flavor)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4921 type = **textOfClip;
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4922 else
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4923 type = (strchr(*textOfClip, '\r') != NULL) ? MLINE : MCHAR;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4924
19
a81bc802c17c updated for version 7.0011
vimboss
parents: 13
diff changeset
4925 tempclip = lalloc(scrapSize + 1, TRUE);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4926 #if defined(FEAT_MBYTE) && defined(USE_CARBONIZED)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4927 mch_memmove(tempclip, *textOfClip + flavor, scrapSize);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4928 #else
19
a81bc802c17c updated for version 7.0011
vimboss
parents: 13
diff changeset
4929 STRNCPY(tempclip, *textOfClip + flavor, scrapSize);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4930 #endif
19
a81bc802c17c updated for version 7.0011
vimboss
parents: 13
diff changeset
4931 tempclip[scrapSize] = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4932
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4933 #if defined(FEAT_MBYTE) && defined(USE_CARBONIZED)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4934 /* Convert from utf-16 (clipboard) */
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4935 size_t encLen = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4936 char_u *to = mac_utf16_to_enc((UniChar *)tempclip, scrapSize, &encLen);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4937 if (to)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4938 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4939 scrapSize = encLen;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4940 vim_free(tempclip);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
4941 tempclip = to;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4942 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4943 #endif
502
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
4944
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
4945 searchCR = (char *)tempclip;
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
4946 while (searchCR != NULL)
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
4947 {
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
4948 searchCR = strchr(searchCR, '\r');
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
4949
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
4950 if (searchCR != NULL)
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
4951 searchCR[0] = '\n';
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
4952
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
4953 }
52e76e2b5b65 updated for version 7.0140
vimboss
parents: 501
diff changeset
4954
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4955 clip_yank_selection(type, tempclip, scrapSize, cbd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4956
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4957 vim_free(tempclip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4958 HUnlock(textOfClip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4959
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4960 DisposeHandle(textOfClip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4961 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4962 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4963
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4964 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4965 clip_mch_lose_selection(cbd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4966 VimClipboard *cbd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4967 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4968 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4969 * TODO: Really nothing to do?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4970 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4971 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4972
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4973 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4974 clip_mch_own_selection(cbd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4975 VimClipboard *cbd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4976 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4977 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4978 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4979
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4980 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4981 * Send the current selection to the clipboard.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4982 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4983 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4984 clip_mch_set_selection(cbd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4985 VimClipboard *cbd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4986 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4987 Handle textOfClip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4988 long scrapSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4989 int type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4990 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4991 ScrapRef scrap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4992 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4993
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4994 char_u *str = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4995
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4996 if (!cbd->owned)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4997 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4998
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4999 clip_get_selection(cbd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5000
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5001 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5002 * Once we set the clipboard, lose ownership. If another application sets
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5003 * the clipboard, we don't want to think that we still own it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5004 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5005 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5006
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5007 cbd->owned = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5008
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5009 type = clip_convert_selection(&str, (long_u *) &scrapSize, cbd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5010
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5011 #if defined(FEAT_MBYTE) && defined(USE_CARBONIZED)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5012 size_t utf16_len = 0;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5013 UniChar *to = mac_enc_to_utf16(str, scrapSize, &utf16_len);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5014 if (to)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5015 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5016 scrapSize = utf16_len;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5017 vim_free(str);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5018 str = (char_u *)to;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5019 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5020 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5021
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5022 if (type >= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5023 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5024 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5025 ClearCurrentScrap();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5026 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5027 ZeroScrap();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5028 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5029
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5030 #ifdef USE_CARBONIZED
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5031 textOfClip = NewHandle(scrapSize + 1);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5032 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5033 textOfClip = NewHandle(scrapSize);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5034 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5035 HLock(textOfClip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5036
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5037 #ifdef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5038 **textOfClip = type;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5039 mch_memmove(*textOfClip + 1, str, scrapSize);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5040 GetCurrentScrap(&scrap);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5041 PutScrapFlavor(scrap, kScrapFlavorTypeUnicode, kScrapFlavorMaskNone,
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5042 scrapSize, *textOfClip + 1);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5043 PutScrapFlavor(scrap, VIMSCRAPFLAVOR, kScrapFlavorMaskNone,
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5044 scrapSize + 1, *textOfClip);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5045 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5046 STRNCPY(*textOfClip, str, scrapSize);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5047 PutScrap(scrapSize, 'TEXT', *textOfClip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5048 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5049 HUnlock(textOfClip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5050 DisposeHandle(textOfClip);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5051 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5052
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5053 vim_free(str);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5054 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5055
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5056 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5057 gui_mch_set_text_area_pos(x, y, w, h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5058 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5059 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5060 int w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5061 int h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5062 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5063 Rect VimBound;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5064
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5065 /* HideWindow(gui.VimWindow); */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5066 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5067 GetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &VimBound);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5068 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5069 VimBound = gui.VimWindow->portRect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5070 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5071
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5072 if (gui.which_scrollbars[SBAR_LEFT])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5073 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5074 VimBound.left = -gui.scrollbar_width + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5075 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5076 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5077 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5078 VimBound.left = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5079 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5080
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5081 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5082 SetWindowBounds(gui.VimWindow, kWindowGlobalPortRgn, &VimBound);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5083 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5084
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5085 ShowWindow(gui.VimWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5086 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5087
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5088 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5089 * Menu stuff.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5090 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5091
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5092 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5093 gui_mch_enable_menu(flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5094 int flag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5095 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5096 /*
444
d0d15b184c56 updated for version 7.0116
vimboss
parents: 418
diff changeset
5097 * Menu is always active.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5098 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5099 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5101 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5102 gui_mch_set_menu_pos(x, y, w, h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5103 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5104 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5105 int w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5106 int h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5107 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5108 /*
444
d0d15b184c56 updated for version 7.0116
vimboss
parents: 418
diff changeset
5109 * The menu is always at the top of the screen.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5110 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5111 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5113 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5114 * Add a sub menu to the menu bar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5115 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5116 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5117 gui_mch_add_menu(menu, idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5118 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5119 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5120 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5121 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5122 * TODO: Try to use only menu_id instead of both menu_id and menu_handle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5123 * TODO: use menu->mnemonic and menu->actext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5124 * TODO: Try to reuse menu id
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5125 * Carbon Help suggest to use only id between 1 and 235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5126 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5127 static long next_avail_id = 128;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5128 long menu_after_me = 0; /* Default to the end */
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5129 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5130 CFStringRef name;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5131 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5132 char_u *name;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5133 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5134 short index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5135 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5136 vimmenu_T *brother = menu->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5137
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5138 /* Cannot add a menu if ... */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5139 if ((parent != NULL && parent->submenu_id == 0))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5140 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5141
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5142 /* menu ID greater than 1024 are reserved for ??? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5143 if (next_avail_id == 1024)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5144 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5145
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5146 /* My brother could be the PopUp, find my real brother */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5147 while ((brother != NULL) && (!menu_is_menubar(brother->name)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5148 brother = brother->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5150 /* Find where to insert the menu (for MenuBar) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5151 if ((parent == NULL) && (brother != NULL))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5152 menu_after_me = brother->submenu_id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5153
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5154 /* If the menu is not part of the menubar (and its submenus), add it 'nowhere' */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5155 if (!menu_is_menubar(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5156 menu_after_me = hierMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5157
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5158 /* Convert the name */
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5159 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5160 name = menu_title_removing_mnemonic(menu);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5161 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5162 name = C2Pascal_save(menu->dname);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5163 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5164 if (name == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5165 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5167 /* Create the menu unless it's the help menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5168 #ifdef USE_HELPMENU
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5169 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5170 if (menu->priority == 9999)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5171 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5172 if (STRNCMP(name, "\4Help", 5) == 0)
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5173 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5174 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5175 menu->submenu_id = kHMHelpMenuID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5176 menu->submenu_handle = gui.MacOSHelpMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5177 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5178 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5179 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5180 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5181 /* Carbon suggest use of
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5182 * OSStatus CreateNewMenu(MenuID, MenuAttributes, MenuRef *);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5183 * OSStatus SetMenuTitle(MenuRef, ConstStr255Param title);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5184 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5185 menu->submenu_id = next_avail_id;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5186 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5187 if (CreateNewMenu(menu->submenu_id, 0, (MenuRef *)&menu->submenu_handle) == noErr)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5188 SetMenuTitleWithCFString((MenuRef)menu->submenu_handle, name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5189 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5190 menu->submenu_handle = NewMenu(menu->submenu_id, name);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5191 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5192 next_avail_id++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5193 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5194
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5195 if (parent == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5196 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5197 /* Adding a menu to the menubar, or in the no mans land (for PopUp) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5198
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5199 /* TODO: Verify if we could only Insert Menu if really part of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5200 * menubar The Inserted menu are scanned or the Command-key combos
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5201 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5202
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5203 /* Insert the menu unless it's the Help menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5204 #ifdef USE_HELPMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5205 if (menu->submenu_id != kHMHelpMenuID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5206 #endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5207 InsertMenu(menu->submenu_handle, menu_after_me); /* insert before */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5208 #if 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5209 /* Vim should normally update it. TODO: verify */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5210 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5211 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5212 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5213 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5214 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5215 /* Adding as a submenu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5216
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5217 index = gui_mac_get_menu_item_index(menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5219 /* Call InsertMenuItem followed by SetMenuItemText
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5220 * to avoid special character recognition by InsertMenuItem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5221 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5222 InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5223 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5224 SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5225 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5226 SetMenuItemText(parent->submenu_handle, idx+1, name);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5227 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5228 SetItemCmd(parent->submenu_handle, idx+1, 0x1B);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5229 SetItemMark(parent->submenu_handle, idx+1, menu->submenu_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5230 InsertMenu(menu->submenu_handle, hierMenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5231 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5232
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5233 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5234 CFRelease(name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5235 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5236 vim_free(name);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5237 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5239 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5240 /* Done by Vim later on */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5241 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5242 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5243 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5245 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5246 * Add a menu item to a menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5247 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5248 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5249 gui_mch_add_menu_item(menu, idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5250 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5251 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5252 {
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5253 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5254 CFStringRef name;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5255 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5256 char_u *name;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5257 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5258 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5259 int menu_inserted;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5260
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5261 /* Cannot add item, if the menu have not been created */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5262 if (parent->submenu_id == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5263 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5264
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5265 /* Could call SetMenuRefCon [CARBON] to associate with the Menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5266 for older OS call GetMenuItemData (menu, item, isCommandID?, data) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5267
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5268 /* Convert the name */
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5269 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5270 name = menu_title_removing_mnemonic(menu);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5271 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5272 name = C2Pascal_save(menu->dname);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5273 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5274
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5275 /* Where are just a menu item, so no handle, no id */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5276 menu->submenu_id = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5277 menu->submenu_handle = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5278
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5279 #ifdef USE_HELPMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5280 /* The index in the help menu are offseted */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5281 if (parent->submenu_id == kHMHelpMenuID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5282 idx += gui.MacOSHelpItems;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5283 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5285 menu_inserted = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5286 if (menu->actext)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5287 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5288 /* If the accelerator text for the menu item looks like it describes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5289 * a command key (e.g., "<D-S-t>" or "<C-7>"), display it as the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5290 * item's command equivalent.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5291 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5292 int key = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5293 int modifiers = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5294 char_u *p_actext;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5296 p_actext = menu->actext;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5297 key = find_special_key(&p_actext, &modifiers, /*keycode=*/0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5298 if (*p_actext != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5299 key = 0; /* error: trailing text */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5300 /* find_special_key() returns a keycode with as many of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5301 * specified modifiers as appropriate already applied (e.g., for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5302 * "<D-C-x>" it returns Ctrl-X as the keycode and MOD_MASK_CMD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5303 * as the only modifier). Since we want to display all of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5304 * modifiers, we need to convert the keycode back to a printable
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5305 * character plus modifiers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5306 * TODO: Write an alternative find_special_key() that doesn't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5307 * apply modifiers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5308 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5309 if (key > 0 && key < 32)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5310 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5311 /* Convert a control key to an uppercase letter. Note that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5312 * by this point it is no longer possible to distinguish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5313 * between, e.g., Ctrl-S and Ctrl-Shift-S.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5314 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5315 modifiers |= MOD_MASK_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5316 key += '@';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5317 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5318 /* If the keycode is an uppercase letter, set the Shift modifier.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5319 * If it is a lowercase letter, don't set the modifier, but convert
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5320 * the letter to uppercase for display in the menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5321 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5322 else if (key >= 'A' && key <= 'Z')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5323 modifiers |= MOD_MASK_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5324 else if (key >= 'a' && key <= 'z')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5325 key += 'A' - 'a';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5326 /* Note: keycodes below 0x22 are reserved by Apple. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5327 if (key >= 0x22 && vim_isprintc_strict(key))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5328 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5329 int valid = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5330 char_u mac_mods = kMenuNoModifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5331 /* Convert Vim modifier codes to Menu Manager equivalents. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5332 if (modifiers & MOD_MASK_SHIFT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5333 mac_mods |= kMenuShiftModifier;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5334 if (modifiers & MOD_MASK_CTRL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5335 mac_mods |= kMenuControlModifier;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5336 if (!(modifiers & MOD_MASK_CMD))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5337 mac_mods |= kMenuNoCommandModifier;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5338 if (modifiers & MOD_MASK_ALT || modifiers & MOD_MASK_MULTI_CLICK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5339 valid = 0; /* TODO: will Alt someday map to Option? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5340 if (valid)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5341 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5342 char_u item_txt[10];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5343 /* Insert the menu item after idx, with its command key. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5344 item_txt[0] = 3; item_txt[1] = ' '; item_txt[2] = '/';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5345 item_txt[3] = key;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5346 InsertMenuItem(parent->submenu_handle, item_txt, idx);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5347 /* Set the modifier keys. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5348 SetMenuItemModifiers(parent->submenu_handle, idx+1, mac_mods);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5349 menu_inserted = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5350 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5351 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5352 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5353 /* Call InsertMenuItem followed by SetMenuItemText
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5354 * to avoid special character recognition by InsertMenuItem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5355 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5356 if (!menu_inserted)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5357 InsertMenuItem(parent->submenu_handle, "\p ", idx); /* afterItem */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5358 /* Set the menu item name. */
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5359 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5360 SetMenuItemTextWithCFString(parent->submenu_handle, idx+1, name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5361 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5362 SetMenuItemText(parent->submenu_handle, idx+1, name);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5363 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5364
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5365 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5366 /* Called by Vim */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5367 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5368 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5369
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5370 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5371 CFRelease(name);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5372 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5373 /* TODO: Can name be freed? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5374 vim_free(name);
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
5375 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5376 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5377
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5378 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5379 gui_mch_toggle_tearoffs(enable)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5380 int enable;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5381 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5382 /* no tearoff menus */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5383 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5384
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5385 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5386 * Destroy the machine specific menu widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5387 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5388 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5389 gui_mch_destroy_menu(menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5390 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5391 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5392 short index = gui_mac_get_menu_item_index(menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5393
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5394 if (index > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5395 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5396 if (menu->parent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5397 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5398 #ifdef USE_HELPMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5399 if (menu->parent->submenu_handle != nil) /*gui.MacOSHelpMenu)*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5400 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5401 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5402 /* For now just don't delete help menu items. (Huh? Dany) */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5403 DeleteMenuItem(menu->parent->submenu_handle, index);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5404
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5405 /* Delete the Menu if it was a hierarchical Menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5406 if (menu->submenu_id != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5407 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5408 DeleteMenu(menu->submenu_id);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5409 DisposeMenu(menu->submenu_handle);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5410 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5411 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5412 #ifdef USE_HELPMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5413 # ifdef DEBUG_MAC_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5414 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5415 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5416 printf("gmdm 1\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5417 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5418 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5419 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5420 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5421 #ifdef DEBUG_MAC_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5422 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5423 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5424 printf("gmdm 2\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5425 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5426 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5427 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5428 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5429 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5430 /* Do not delete the Help Menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5431 #ifdef USE_HELPMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5432 if (menu->submenu_id != kHMHelpMenuID)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5433 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5434 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5435 DeleteMenu(menu->submenu_id);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5436 DisposeMenu(menu->submenu_handle);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5437 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5438 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5439 /* Shouldn't this be already done by Vim. TODO: Check */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5440 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5441 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5442
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5443 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5444 * Make a menu either grey or not grey.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5445 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5446 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5447 gui_mch_menu_grey(menu, grey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5448 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5449 int grey;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5450 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5451 /* TODO: Check if menu really exists */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5452 short index = gui_mac_get_menu_item_index(menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5453 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5454 index = menu->index;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5455 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5456 if (grey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5457 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5458 if (menu->children)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5459 DisableMenuItem(menu->submenu_handle, index);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5460 if (menu->parent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5461 if (menu->parent->submenu_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5462 DisableMenuItem(menu->parent->submenu_handle, index);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5463 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5464 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5465 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5466 if (menu->children)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5467 EnableMenuItem(menu->submenu_handle, index);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5468 if (menu->parent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5469 if (menu->parent->submenu_handle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5470 EnableMenuItem(menu->parent->submenu_handle, index);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5471 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5472 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5473
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5474 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5475 * Make menu item hidden or not hidden
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5476 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5477 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5478 gui_mch_menu_hidden(menu, hidden)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5479 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5480 int hidden;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5481 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5482 /* There's no hidden mode on MacOS */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5483 gui_mch_menu_grey(menu, hidden);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5484 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5485
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5486
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5487 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5488 * This is called after setting all the menus to grey/hidden or not.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5489 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5490 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5491 gui_mch_draw_menubar()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5492 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5493 DrawMenuBar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5494 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5495
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5497 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5498 * Scrollbar stuff.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5499 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5500
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5501 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5502 gui_mch_enable_scrollbar(sb, flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5503 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5504 int flag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5505 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5506 if (flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5507 ShowControl(sb->id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5508 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5509 HideControl(sb->id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5510
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5511 #ifdef DEBUG_MAC_SB
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5512 printf("enb_sb (%x) %x\n",sb->id, flag);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5513 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5514 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5515
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5516 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5517 gui_mch_set_scrollbar_thumb(sb, val, size, max)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5518 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5519 long val;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5520 long size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5521 long max;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5522 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5523 SetControl32BitMaximum (sb->id, max);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5524 SetControl32BitMinimum (sb->id, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5525 SetControl32BitValue (sb->id, val);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5526 #ifdef DEBUG_MAC_SB
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5527 printf("thumb_sb (%x) %x, %x,%x\n",sb->id, val, size, max);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5528 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5529 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5530
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5531 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5532 gui_mch_set_scrollbar_pos(sb, x, y, w, h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5533 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5534 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5535 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5536 int w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5537 int h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5538 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5539 gui_mch_set_bg_color(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5540 /* if (gui.which_scrollbars[SBAR_LEFT])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5541 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5542 MoveControl(sb->id, x-16, y);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5543 SizeControl(sb->id, w + 1, h);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5544 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5545 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5546 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5547 MoveControl(sb->id, x, y);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5548 SizeControl(sb->id, w + 1, h);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5549 }*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5550 if (sb == &gui.bottom_sbar)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5551 h += 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5552 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5553 w += 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5554
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5555 if (gui.which_scrollbars[SBAR_LEFT])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5556 x -= 15;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5557
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5558 MoveControl(sb->id, x, y);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5559 SizeControl(sb->id, w, h);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5560 #ifdef DEBUG_MAC_SB
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5561 printf("size_sb (%x) %x, %x, %x, %x\n",sb->id, x, y, w, h);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5562 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5563 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5564
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5565 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5566 gui_mch_create_scrollbar(sb, orient)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5567 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5568 int orient; /* SBAR_VERT or SBAR_HORIZ */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5569 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5570 Rect bounds;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5571
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5572 bounds.top = -16;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5573 bounds.bottom = -10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5574 bounds.right = -10;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5575 bounds.left = -16;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5576
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5577 sb->id = NewControl(gui.VimWindow,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5578 &bounds,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5579 "\pScrollBar",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5580 TRUE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5581 0, /* current*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5582 0, /* top */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5583 0, /* bottom */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5584 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5585 kControlScrollBarLiveProc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5586 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5587 scrollBarProc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5588 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5589 (long) sb->ident);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5590 #ifdef DEBUG_MAC_SB
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5591 printf("create_sb (%x) %x\n",sb->id, orient);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5592 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5593 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5594
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5595 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5596 gui_mch_destroy_scrollbar(sb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5597 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5598 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5599 gui_mch_set_bg_color(gui.back_pixel);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5600 DisposeControl(sb->id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5601 #ifdef DEBUG_MAC_SB
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5602 printf("dest_sb (%x) \n",sb->id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5603 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5604 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5605
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5606
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5607 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5608 * Cursor blink functions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5609 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5610 * This is a simple state machine:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5611 * BLINK_NONE not blinking at all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5612 * BLINK_OFF blinking, cursor is not shown
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5613 * BLINK_ON blinking, cursor is shown
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5614 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5615 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5616 gui_mch_set_blinking(long wait, long on, long off)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5617 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5618 /* TODO: TODO: TODO: TODO: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5619 /* blink_waittime = wait;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5620 blink_ontime = on;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5621 blink_offtime = off;*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5622 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5623
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5624 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5625 * Stop the cursor blinking. Show the cursor if it wasn't shown.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5626 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5627 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5628 gui_mch_stop_blink()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5629 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5630 gui_update_cursor(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5631 /* TODO: TODO: TODO: TODO: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5632 /* gui_w32_rm_blink_timer();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5633 if (blink_state == BLINK_OFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5634 gui_update_cursor(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5635 blink_state = BLINK_NONE;*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5636 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5637
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5638 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5639 * Start the cursor blinking. If it was already blinking, this restarts the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5640 * waiting time and shows the cursor.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5641 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5642 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5643 gui_mch_start_blink()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5644 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5645 gui_update_cursor(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5646 /* TODO: TODO: TODO: TODO: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5647 /* gui_w32_rm_blink_timer(); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5648
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5649 /* Only switch blinking on if none of the times is zero */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5650 /* if (blink_waittime && blink_ontime && blink_offtime)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5651 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5652 blink_timer = SetTimer(NULL, 0, (UINT)blink_waittime,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5653 (TIMERPROC)_OnBlinkTimer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5654 blink_state = BLINK_ON;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5655 gui_update_cursor(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5656 }*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5657 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5658
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5659 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5660 * Return the RGB value of a pixel as long.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5661 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5662 long_u
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5663 gui_mch_get_rgb(guicolor_T pixel)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5664 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5665 return (Red(pixel) << 16) + (Green(pixel) << 8) + Blue(pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5666 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5667
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5668
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5669
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5670 #ifdef FEAT_BROWSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5671 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5672 * Pop open a file browser and return the file selected, in allocated memory,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5673 * or NULL if Cancel is hit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5674 * saving - TRUE if the file will be saved to, FALSE if it will be opened.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5675 * title - Title message for the file browser dialog.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5676 * dflt - Default name of file.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5677 * ext - Default extension to be added to files without extensions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5678 * initdir - directory in which to open the browser (NULL = current dir)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5679 * filter - Filter for matched files to choose from.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5680 * Has a format like this:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5681 * "C Files (*.c)\0*.c\0"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5682 * "All Files\0*.*\0\0"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5683 * If these two strings were concatenated, then a choice of two file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5684 * filters will be selectable to the user. Then only matching files will
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5685 * be shown in the browser. If NULL, the default allows all files.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5686 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5687 * *NOTE* - the filter string must be terminated with TWO nulls.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5688 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5689 char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5690 gui_mch_browse(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5691 int saving,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5692 char_u *title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5693 char_u *dflt,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5694 char_u *ext,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5695 char_u *initdir,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5696 char_u *filter)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5697 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5698 #if defined (USE_NAVIGATION_SERVICE) || defined (USE_CARBONIZED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5699 /* TODO: Add Ammon's safety checl (Dany) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5700 NavReplyRecord reply;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5701 char_u *fname = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5702 char_u **fnames = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5703 long numFiles;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5704 NavDialogOptions navOptions;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5705 OSErr error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5706
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5707 /* Get Navigation Service Defaults value */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5708 NavGetDefaultDialogOptions(&navOptions);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5710
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5711 /* TODO: If we get a :browse args, set the Multiple bit. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5712 navOptions.dialogOptionFlags = kNavAllowInvisibleFiles
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5713 | kNavDontAutoTranslate
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5714 | kNavDontAddTranslateItems
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5715 /* | kNavAllowMultipleFiles */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5716 | kNavAllowStationery;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5717
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5718 (void) C2PascalString(title, &navOptions.message);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5719 (void) C2PascalString(dflt, &navOptions.savedFileName);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5720 /* Could set clientName?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5721 * windowTitle? (there's no title bar?)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5722 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5723
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5724 if (saving)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5725 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5726 /* Change first parm AEDesc (typeFSS) *defaultLocation to match dflt */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5727 NavPutFile(NULL, &reply, &navOptions, NULL, 'TEXT', 'VIM!', NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5728 if (!reply.validRecord)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5729 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5730 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5731 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5732 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5733 /* Change first parm AEDesc (typeFSS) *defaultLocation to match dflt */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5734 NavGetFile(NULL, &reply, &navOptions, NULL, NULL, NULL, NULL, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5735 if (!reply.validRecord)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5736 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5737 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5738
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5739 fnames = new_fnames_from_AEDesc(&reply.selection, &numFiles, &error);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5740
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5741 NavDisposeReply(&reply);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5742
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5743 if (fnames)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5744 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5745 fname = fnames[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5746 vim_free(fnames);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5747 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5748
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5749 /* TODO: Shorten the file name if possible */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5750 return fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5751 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5752 SFTypeList fileTypes;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5753 StandardFileReply reply;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5754 Str255 Prompt;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5755 Str255 DefaultName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5756 Str255 Directory;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5757
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5758 /* TODO: split dflt in path and filename */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5759
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5760 (void) C2PascalString(title, &Prompt);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5761 (void) C2PascalString(dflt, &DefaultName);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5762 (void) C2PascalString(initdir, &Directory);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5763
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5764 if (saving)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5765 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5766 /* Use a custon filter instead of nil FAQ 9-4 */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5767 StandardPutFile(Prompt, DefaultName, &reply);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5768 if (!reply.sfGood)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5769 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5770 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5771 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5772 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5773 StandardGetFile(nil, -1, fileTypes, &reply);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5774 if (!reply.sfGood)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5775 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5776 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5777
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5778 /* Work fine but append a : for new file */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5779 return (FullPathFromFSSpec_save(reply.sfFile));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5780
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5781 /* Shorten the file name if possible */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5782 /* mch_dirname(IObuff, IOSIZE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5783 p = shorten_fname(fileBuf, IObuff);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5784 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5785 p = fileBuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5786 return vim_strsave(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5787 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5788 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5789 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5790 #endif /* FEAT_BROWSE */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5791
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5792 #ifdef FEAT_GUI_DIALOG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5793 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5794 * Stuff for dialogues
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5795 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5796
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5797 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5798 * Create a dialogue dynamically from the parameter strings.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5799 * type = type of dialogue (question, alert, etc.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5800 * title = dialogue title. may be NULL for default title.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5801 * message = text to display. Dialogue sizes to accommodate it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5802 * buttons = '\n' separated list of button captions, default first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5803 * dfltbutton = number of default button.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5804 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5805 * This routine returns 1 if the first button is pressed,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5806 * 2 for the second, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5807 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5808 * 0 indicates Esc was pressed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5809 * -1 for unexpected error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5810 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5811 * If stubbing out this fn, return 1.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5812 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5813
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5814 typedef struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5815 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5816 short idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5817 short width; /* Size of the text in pixel */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5818 Rect box;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5819 } vgmDlgItm; /* Vim Gui_Mac.c Dialog Item */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5820
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5821 #define MoveRectTo(r,x,y) OffsetRect(r,x-r->left,y-r->top)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5822
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5823 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5824 macMoveDialogItem(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5825 DialogRef theDialog,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5826 short itemNumber,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5827 short X,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5828 short Y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5829 Rect *inBox)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5830 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5831 #if 0 /* USE_CARBONIZED */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5832 /* Untested */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5833 MoveDialogItem(theDialog, itemNumber, X, Y);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5834 if (inBox != nil)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5835 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, inBox);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5836 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5837 short itemType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5838 Handle itemHandle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5839 Rect localBox;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5840 Rect *itemBox = &localBox;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5841
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5842 if (inBox != nil)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5843 itemBox = inBox;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5844
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5845 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, itemBox);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5846 OffsetRect(itemBox, -itemBox->left, -itemBox->top);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5847 OffsetRect(itemBox, X, Y);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5848 /* To move a control (like a button) we need to call both
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5849 * MoveControl and SetDialogItem. FAQ 6-18 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5850 if (1) /*(itemType & kControlDialogItem) */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5851 MoveControl((ControlRef) itemHandle, X, Y);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5852 SetDialogItem(theDialog, itemNumber, itemType, itemHandle, itemBox);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5853 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5854 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5855
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5856 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5857 macSizeDialogItem(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5858 DialogRef theDialog,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5859 short itemNumber,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5860 short width,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5861 short height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5862 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5863 short itemType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5864 Handle itemHandle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5865 Rect itemBox;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5866
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5867 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, &itemBox);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5868
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5869 /* When width or height is zero do not change it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5870 if (width == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5871 width = itemBox.right - itemBox.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5872 if (height == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5873 height = itemBox.bottom - itemBox.top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5874
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5875 #if 0 /* USE_CARBONIZED */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5876 SizeDialogItem(theDialog, itemNumber, width, height); /* Untested */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5877 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5878 /* Resize the bounding box */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5879 itemBox.right = itemBox.left + width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5880 itemBox.bottom = itemBox.top + height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5881
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5882 /* To resize a control (like a button) we need to call both
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5883 * SizeControl and SetDialogItem. (deducted from FAQ 6-18) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5884 if (itemType & kControlDialogItem)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5885 SizeControl((ControlRef) itemHandle, width, height);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5886
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5887 /* Configure back the item */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5888 SetDialogItem(theDialog, itemNumber, itemType, itemHandle, &itemBox);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5889 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5890 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5891
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5892 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5893 macSetDialogItemText(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5894 DialogRef theDialog,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5895 short itemNumber,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5896 Str255 itemName)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5897 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5898 short itemType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5899 Handle itemHandle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5900 Rect itemBox;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5901
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5902 GetDialogItem(theDialog, itemNumber, &itemType, &itemHandle, &itemBox);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5903
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5904 if (itemType & kControlDialogItem)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5905 SetControlTitle((ControlRef) itemHandle, itemName);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5906 else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5907 SetDialogItemText(itemHandle, itemName);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5908 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5909
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5910 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5911 gui_mch_dialog(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5912 int type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5913 char_u *title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5914 char_u *message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5915 char_u *buttons,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5916 int dfltbutton,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5917 char_u *textfield)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5918 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5919 Handle buttonDITL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5920 Handle iconDITL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5921 Handle inputDITL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5922 Handle messageDITL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5923 Handle itemHandle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5924 Handle iconHandle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5925 DialogPtr theDialog;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5926 char_u len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5927 char_u PascalTitle[256]; /* place holder for the title */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5928 char_u name[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5929 GrafPtr oldPort;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5930 short itemHit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5931 char_u *buttonChar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5932 Rect box;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5933 short button;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5934 short lastButton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5935 short itemType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5936 short useIcon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5937 short width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5938 short totalButtonWidth = 0; /* the width of all button together incuding spacing */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5939 short widestButton = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5940 short dfltButtonEdge = 20; /* gut feeling */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5941 short dfltElementSpacing = 13; /* from IM:V.2-29 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5942 short dfltIconSideSpace = 23; /* from IM:V.2-29 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5943 short maximumWidth = 400; /* gut feeling */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5944 short maxButtonWidth = 175; /* gut feeling */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5945
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5946 short vertical;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5947 short dialogHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5948 short messageLines = 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5949 FontInfo textFontInfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5950
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5951 vgmDlgItm iconItm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5952 vgmDlgItm messageItm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5953 vgmDlgItm inputItm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5954 vgmDlgItm buttonItm;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5955
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5956 WindowRef theWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5957
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5958 /* Check 'v' flag in 'guioptions': vertical button placement. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5959 vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5960
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5961 /* Create a new Dialog Box from template. */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5962 theDialog = GetNewDialog(129, nil, (WindowRef) -1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5963
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5964 /* Get the WindowRef */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5965 theWindow = GetDialogWindow(theDialog);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5966
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5967 /* Hide the window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5968 * 1. to avoid seeing slow drawing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5969 * 2. to prevent a problem seen while moving dialog item
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5970 * within a visible window. (non-Carbon MacOS 9)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5971 * Could be avoided by changing the resource.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5972 */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5973 HideWindow(theWindow);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5974
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5975 /* Change the graphical port to the dialog,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5976 * so we can measure the text with the proper font */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5977 GetPort(&oldPort);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5978 #ifdef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5979 SetPortDialogPort(theDialog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5980 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5981 SetPort(theDialog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5982 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5983
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5984 /* Get the info about the default text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5985 * used to calculate the height of the message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5986 * and of the text field */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5987 GetFontInfo(&textFontInfo);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5988
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5989 /* Set the dialog title */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5990 if (title != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5991 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5992 (void) C2PascalString(title, &PascalTitle);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5993 SetWTitle(theWindow, PascalTitle);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5994 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5995
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5996 /* Creates the buttons and add them to the Dialog Box. */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5997 buttonDITL = GetResource('DITL', 130);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5998 buttonChar = buttons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5999 button = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6000
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6001 for (;*buttonChar != 0;)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6002 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6003 /* Get the name of the button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6004 button++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6005 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6006 for (;((*buttonChar != DLG_BUTTON_SEP) && (*buttonChar != 0) && (len < 255)); buttonChar++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6007 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6008 if (*buttonChar != DLG_HOTKEY_CHAR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6009 name[++len] = *buttonChar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6010 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6011 if (*buttonChar != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6012 buttonChar++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6013 name[0] = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6014
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6015 /* Add the button */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6016 AppendDITL(theDialog, buttonDITL, overlayDITL); /* appendDITLRight); */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6017
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6018 /* Change the button's name */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6019 macSetDialogItemText(theDialog, button, name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6020
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6021 /* Resize the button to fit its name */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6022 width = StringWidth(name) + 2 * dfltButtonEdge;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6023 /* Limite the size of any button to an acceptable value. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6024 /* TODO: Should be based on the message width */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6025 if (width > maxButtonWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6026 width = maxButtonWidth;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6027 macSizeDialogItem(theDialog, button, width, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6028
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6029 totalButtonWidth += width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6030
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6031 if (width > widestButton)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6032 widestButton = width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6033 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6034 ReleaseResource(buttonDITL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6035 lastButton = button;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6036
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6037 /* Add the icon to the Dialog Box. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6038 iconItm.idx = lastButton + 1;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6039 iconDITL = GetResource('DITL', 131);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6040 switch (type)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6041 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6042 case VIM_GENERIC: useIcon = kNoteIcon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6043 case VIM_ERROR: useIcon = kStopIcon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6044 case VIM_WARNING: useIcon = kCautionIcon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6045 case VIM_INFO: useIcon = kNoteIcon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6046 case VIM_QUESTION: useIcon = kNoteIcon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6047 default: useIcon = kStopIcon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6048 };
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6049 AppendDITL(theDialog, iconDITL, overlayDITL);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6050 ReleaseResource(iconDITL);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6051 GetDialogItem(theDialog, iconItm.idx, &itemType, &itemHandle, &box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6052 /* TODO: Should the item be freed? */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6053 iconHandle = GetIcon(useIcon);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6054 SetDialogItem(theDialog, iconItm.idx, itemType, iconHandle, &box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6055
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6056 /* Add the message to the Dialog box. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6057 messageItm.idx = lastButton + 2;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6058 messageDITL = GetResource('DITL', 132);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6059 AppendDITL(theDialog, messageDITL, overlayDITL);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6060 ReleaseResource(messageDITL);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6061 GetDialogItem(theDialog, messageItm.idx, &itemType, &itemHandle, &box);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6062 (void) C2PascalString(message, &name);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6063 SetDialogItemText(itemHandle, name);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6064 messageItm.width = StringWidth(name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6065
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6066 /* Add the input box if needed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6067 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6068 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6069 /* Cheat for now reuse the message and convet to text edit */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6070 inputItm.idx = lastButton + 3;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6071 inputDITL = GetResource('DITL', 132);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6072 AppendDITL(theDialog, inputDITL, overlayDITL);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6073 ReleaseResource(inputDITL);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6074 GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &box);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6075 /* SetDialogItem(theDialog, inputItm.idx, kEditTextDialogItem, itemHandle, &box);*/
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6076 (void) C2PascalString(textfield, &name);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6077 SetDialogItemText(itemHandle, name);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6078 inputItm.width = StringWidth(name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6079 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6080
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6081 /* Set the <ENTER> and <ESC> button. */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6082 SetDialogDefaultItem(theDialog, dfltbutton);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6083 SetDialogCancelItem(theDialog, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6084
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6085 /* Reposition element */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6086
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6087 /* Check if we need to force vertical */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6088 if (totalButtonWidth > maximumWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6089 vertical = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6090
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6091 /* Place icon */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6092 macMoveDialogItem(theDialog, iconItm.idx, dfltIconSideSpace, dfltElementSpacing, &box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6093 iconItm.box.right = box.right;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6094 iconItm.box.bottom = box.bottom;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6095
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6096 /* Place Message */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6097 messageItm.box.left = iconItm.box.right + dfltIconSideSpace;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6098 macSizeDialogItem(theDialog, messageItm.idx, 0, messageLines * (textFontInfo.ascent + textFontInfo.descent));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6099 macMoveDialogItem(theDialog, messageItm.idx, messageItm.box.left, dfltElementSpacing, &messageItm.box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6101 /* Place Input */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6102 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6103 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6104 inputItm.box.left = messageItm.box.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6105 inputItm.box.top = messageItm.box.bottom + dfltElementSpacing;
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6106 macSizeDialogItem(theDialog, inputItm.idx, 0, textFontInfo.ascent + textFontInfo.descent);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6107 macMoveDialogItem(theDialog, inputItm.idx, inputItm.box.left, inputItm.box.top, &inputItm.box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6108 /* Convert the static text into a text edit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6109 * For some reason this change need to be done last (Dany) */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6110 GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &inputItm.box);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6111 SetDialogItem(theDialog, inputItm.idx, kEditTextDialogItem, itemHandle, &inputItm.box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6112 SelectDialogItemText(theDialog, inputItm.idx, 0, 32767);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6113 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6114
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6115 /* Place Button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6116 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6117 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6118 buttonItm.box.left = inputItm.box.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6119 buttonItm.box.top = inputItm.box.bottom + dfltElementSpacing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6120 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6121 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6122 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6123 buttonItm.box.left = messageItm.box.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6124 buttonItm.box.top = messageItm.box.bottom + dfltElementSpacing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6125 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6126
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6127 for (button=1; button <= lastButton; button++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6128 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6129
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6130 macMoveDialogItem(theDialog, button, buttonItm.box.left, buttonItm.box.top, &box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6131 /* With vertical, it's better to have all button the same lenght */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6132 if (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6133 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6134 macSizeDialogItem(theDialog, button, widestButton, 0);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6135 GetDialogItem(theDialog, button, &itemType, &itemHandle, &box);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6136 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6137 /* Calculate position of next button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6138 if (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6139 buttonItm.box.top = box.bottom + dfltElementSpacing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6140 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6141 buttonItm.box.left = box.right + dfltElementSpacing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6142 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6144 /* Resize the dialog box */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6145 dialogHeight = box.bottom + dfltElementSpacing;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6146 SizeWindow(theWindow, maximumWidth, dialogHeight, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6147
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6148 #ifdef USE_CARBONIZED
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6149 /* Magic resize */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6150 AutoSizeDialog(theDialog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6151 /* Need a horizontal resize anyway so not that useful */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6152 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6153
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6154 /* Display it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6155 ShowWindow(theWindow);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6156 /* BringToFront(theWindow); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6157 SelectWindow(theWindow);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6158
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6159 /* DrawDialog(theDialog); */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6160 #if 0
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6161 GetPort(&oldPort);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6162 #ifdef USE_CARBONIZED
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6163 SetPortDialogPort(theDialog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6164 #else
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6165 SetPort(theDialog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6166 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6167 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6168
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6169 /* Hang until one of the button is hit */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6170 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6171 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6172 ModalDialog(nil, &itemHit);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6173 } while ((itemHit < 1) || (itemHit > lastButton));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6174
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6175 /* Copy back the text entered by the user into the param */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6176 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6177 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6178 GetDialogItem(theDialog, inputItm.idx, &itemType, &itemHandle, &box);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6179 GetDialogItemText(itemHandle, (char_u *) &name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6180 #if IOSIZE < 256
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6181 /* Truncate the name to IOSIZE if needed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6182 if (name[0] > IOSIZE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6183 name[0] = IOSIZE - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6184 #endif
418
84825cc6f049 updated for version 7.0109
vimboss
parents: 308
diff changeset
6185 vim_strncpy(textfield, &name[1], name[0]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6186 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6187
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6188 /* Restore the original graphical port */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6189 SetPort(oldPort);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6190
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6191 /* Get ride of th edialog (free memory) */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6192 DisposeDialog(theDialog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6194 return itemHit;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6195 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6196 * Usefull thing which could be used
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6197 * SetDialogTimeout(): Auto click a button after timeout
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6198 * SetDialogTracksCursor() : Get the I-beam cursor over input box
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6199 * MoveDialogItem(): Probably better than SetDialogItem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6200 * SizeDialogItem(): (but is it Carbon Only?)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6201 * AutoSizeDialog(): Magic resize of dialog based on text lenght
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6202 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6203 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6204 #endif /* FEAT_DIALOG_GUI */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6206 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6207 * Display the saved error message(s).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6208 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6209 #ifdef USE_MCH_ERRMSG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6210 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6211 display_errors()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6212 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6213 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6214 char_u pError[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6215
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6216 if (error_ga.ga_data != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6217 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6218 /* avoid putting up a message box with blanks only */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6219 for (p = (char *)error_ga.ga_data; *p; ++p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6220 if (!isspace(*p))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6221 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6222 if (STRLEN(p) > 255)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6223 pError[0] = 255;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6224 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6225 pError[0] = STRLEN(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6227 STRNCPY(&pError[1], p, pError[0]);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6228 ParamText(pError, nil, nil, nil);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6229 Alert(128, nil);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6230 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6231 /* TODO: handled message longer than 256 chars
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6232 * use auto-sizeable alert
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6233 * or dialog with scrollbars (TextEdit zone)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6234 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6235 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6236 ga_clear(&error_ga);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6237 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6238 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6239 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6240
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6241 /*
87
014ba200db86 updated for version 7.0035
vimboss
parents: 44
diff changeset
6242 * Get current mouse coordinates in text window.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6243 */
95
a2081e6febb8 updated for version 7.0037
vimboss
parents: 87
diff changeset
6244 void
a2081e6febb8 updated for version 7.0037
vimboss
parents: 87
diff changeset
6245 gui_mch_getmouse(int *x, int *y)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6246 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6247 Point where;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6248
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6249 GetMouse(&where);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6250
87
014ba200db86 updated for version 7.0035
vimboss
parents: 44
diff changeset
6251 *x = where.h;
014ba200db86 updated for version 7.0035
vimboss
parents: 44
diff changeset
6252 *y = where.v;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6253 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6255 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6256 gui_mch_setmouse(x, y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6257 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6258 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6259 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6260 /* TODO */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6261 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6262 /* From FAQ 3-11 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6263
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6264 CursorDevicePtr myMouse;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6265 Point where;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6266
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6267 if ( NGetTrapAddress(_CursorDeviceDispatch, ToolTrap)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6268 != NGetTrapAddress(_Unimplemented, ToolTrap))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6269 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6270 /* New way */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6271
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6272 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6273 * Get first devoice with one button.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6274 * This will probably be the standad mouse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6275 * startat head of cursor dev list
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6276 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6277 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6278
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6279 myMouse = nil;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6280
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6281 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6282 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6283 /* Get the next cursor device */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6284 CursorDeviceNextDevice(&myMouse);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6285 }
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6286 while ((myMouse != nil) && (myMouse->cntButtons != 1));
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6287
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6288 CursorDeviceMoveTo(myMouse, x, y);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6289 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6290 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6291 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6292 /* Old way */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6293 where.h = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6294 where.v = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6296 *(Point *)RawMouse = where;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6297 *(Point *)MTemp = where;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6298 *(Ptr) CrsrNew = 0xFFFF;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6299 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6300 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6301 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6302
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6303 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6304 gui_mch_show_popupmenu(menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6305 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6306 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6307 #ifdef USE_CTRLCLICKMENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6308 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6309 * Clone PopUp to use menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6310 * Create a object descriptor for the current selection
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6311 * Call the procedure
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6312 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6314 MenuHandle CntxMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6315 Point where;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6316 OSStatus status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6317 UInt32 CntxType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6318 SInt16 CntxMenuID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6319 UInt16 CntxMenuItem;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6320 Str255 HelpName = "";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6321 GrafPtr savePort;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6322
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6323 /* Save Current Port: On MacOS X we seem to lose the port */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6324 GetPort(&savePort); /*OSX*/
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6325
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6326 GetMouse(&where);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6327 LocalToGlobal(&where); /*OSX*/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6328 CntxMenu = menu->submenu_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6330 /* TODO: Get the text selection from Vim */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6331
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6332 /* Call to Handle Popup */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6333 status = ContextualMenuSelect(CntxMenu, where, false, kCMHelpItemNoHelp, HelpName, NULL, &CntxType, &CntxMenuID, &CntxMenuItem);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6334
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6335 if (status == noErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6336 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6337 if (CntxType == kCMMenuItemSelected)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6338 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6339 /* Handle the menu CntxMenuID, CntxMenuItem */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6340 /* The submenu can be handle directly by gui_mac_handle_menu */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6341 /* But what about the current menu, is the menu changed by ContextualMenuSelect */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6342 gui_mac_handle_menu((CntxMenuID << 16) + CntxMenuItem);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6343 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6344 else if (CntxMenuID == kCMShowHelpSelected)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6345 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6346 /* Should come up with the help */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6347 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6348 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6349
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6350 /* Restore original Port */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6351 SetPort(savePort); /*OSX*/
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6352 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6353 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6354
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6355 #if defined(FEAT_CW_EDITOR) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6356 /* TODO: Is it need for MACOS_X? (Dany) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6357 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6358 mch_post_buffer_write(buf_T *buf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6359 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6360 # ifdef USE_SIOUX
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6361 printf("Writing Buf...\n");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6362 # endif
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6363 GetFSSpecFromPath(buf->b_ffname, &buf->b_FSSpec);
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6364 Send_KAHL_MOD_AE(buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6365 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6366 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6367
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6368 #ifdef FEAT_TITLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6369 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6370 * Set the window title and icon.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6371 * (The icon is not taken care of).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6372 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6373 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6374 gui_mch_settitle(title, icon)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6375 char_u *title;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6376 char_u *icon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6377 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6378 /* TODO: Get vim to make sure maxlen (from p_titlelen) is smaller
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6379 * that 256. Even better get it to fit nicely in the titlebar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6380 */
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6381 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6382 CFStringRef windowTitle;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6383 size_t windowTitleLen;
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6384 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6385 char_u *pascalTitle;
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6386 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6388 if (title == NULL) /* nothing to do */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6389 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6390
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6391 #if defined(USE_CARBONIZED) && defined(FEAT_MBYTE)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6392 windowTitleLen = STRLEN(title);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6393 windowTitle = mac_enc_to_cfstring(title, windowTitleLen);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6394
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6395 if (windowTitle)
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6396 {
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6397 SetWindowTitleWithCFString(gui.VimWindow, windowTitle);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6398 CFRelease(windowTitle);
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6399 }
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6400 #else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6401 pascalTitle = C2Pascal_save(title);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6402 if (pascalTitle != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6403 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6404 SetWTitle(gui.VimWindow, pascalTitle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6405 vim_free(pascalTitle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6406 }
168
4d9eabb1396e updated for version 7.0051
vimboss
parents: 95
diff changeset
6407 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6408 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6409 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6410
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6411 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6412 * Transfered from os_mac.c for MacOS X using os_unix.c prep work
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6413 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6414
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6415 int
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6416 C2PascalString(CString, PascalString)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6417 char_u *CString;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6418 Str255 *PascalString;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6419 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6420 char_u *PascalPtr = (char_u *) PascalString;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6421 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6422 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6423
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6424 PascalPtr[0] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6425 if (CString == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6426 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6427
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6428 len = STRLEN(CString);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6429 if (len > 255)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6430 len = 255;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6431
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6432 for (i = 0; i < len; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6433 PascalPtr[i+1] = CString[i];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6434
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6435 PascalPtr[0] = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6436
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6437 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6438 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6439
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6440 int
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6441 GetFSSpecFromPath(file, fileFSSpec)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6442 char_u *file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6443 FSSpec *fileFSSpec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6444 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6445 /* From FAQ 8-12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6446 Str255 filePascal;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6447 CInfoPBRec myCPB;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6448 OSErr err;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6449
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6450 (void) C2PascalString(file, &filePascal);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6451
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6452 myCPB.dirInfo.ioNamePtr = filePascal;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6453 myCPB.dirInfo.ioVRefNum = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6454 myCPB.dirInfo.ioFDirIndex = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6455 myCPB.dirInfo.ioDrDirID = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6456
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6457 err= PBGetCatInfo(&myCPB, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6458
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6459 /* vRefNum, dirID, name */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6460 FSMakeFSSpec(0, 0, filePascal, fileFSSpec);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6462 /* TODO: Use an error code mechanism */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6463 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6464 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6465
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6466 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6467 * Convert a FSSpec to a fuill path
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6468 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6469
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6470 char_u *FullPathFromFSSpec_save(FSSpec file)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6471 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6472 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6473 * TODO: Add protection for 256 char max.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6474 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6475
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6476 CInfoPBRec theCPB;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6477 char_u fname[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6478 char_u *filenamePtr = fname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6479 OSErr error;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6480 int folder = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6481 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6482 SInt16 dfltVol_vRefNum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6483 SInt32 dfltVol_dirID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6484 FSRef refFile;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6485 OSStatus status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6486 UInt32 pathSize = 256;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6487 char_u pathname[256];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6488 char_u *path = pathname;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6489 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6490 Str255 directoryName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6491 char_u temporary[255];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6492 char_u *temporaryPtr = temporary;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6493 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6494
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6495 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6496 /* Get the default volume */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6497 /* TODO: Remove as this only work if Vim is on the Boot Volume*/
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6498 error=HGetVol(NULL, &dfltVol_vRefNum, &dfltVol_dirID);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6500 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6501 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6502 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6503
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6504 /* Start filling fname with file.name */
418
84825cc6f049 updated for version 7.0109
vimboss
parents: 308
diff changeset
6505 vim_strncpy(filenamePtr, &file.name[1], file.name[0]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6506
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6507 /* Get the info about the file specified in FSSpec */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6508 theCPB.dirInfo.ioFDirIndex = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6509 theCPB.dirInfo.ioNamePtr = file.name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6510 theCPB.dirInfo.ioVRefNum = file.vRefNum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6511 /*theCPB.hFileInfo.ioDirID = 0;*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6512 theCPB.dirInfo.ioDrDirID = file.parID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6513
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6514 /* As ioFDirIndex = 0, get the info of ioNamePtr,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6515 which is relative to ioVrefNum, ioDirID */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6516 error = PBGetCatInfo(&theCPB, false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6517
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6518 /* If we are called for a new file we expect fnfErr */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6519 if ((error) && (error != fnfErr))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6520 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6521
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6522 /* Check if it's a file or folder */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6523 /* default to file if file don't exist */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6524 if (((theCPB.hFileInfo.ioFlAttrib & ioDirMask) == 0) || (error))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6525 folder = 0; /* It's not a folder */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6526 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6527 folder = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6528
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6529 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6530 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6531 * The function used here are available in Carbon, but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6532 * do nothing une MacOS 8 and 9
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6533 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6534 if (error == fnfErr)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6535 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6536 /* If the file to be saved does not already exist, it isn't possible
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6537 to convert its FSSpec into an FSRef. But we can construct an
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6538 FSSpec for the file's parent folder (since we have its volume and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6539 directory IDs), and since that folder does exist, we can convert
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6540 that FSSpec into an FSRef, convert the FSRef in turn into a path,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6541 and, finally, append the filename. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6542 FSSpec dirSpec;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6543 FSRef dirRef;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6544 Str255 emptyFilename = "\p";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6545 error = FSMakeFSSpec(theCPB.dirInfo.ioVRefNum,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6546 theCPB.dirInfo.ioDrDirID, emptyFilename, &dirSpec);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6547 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6548 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6549
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6550 error = FSpMakeFSRef(&dirSpec, &dirRef);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6551 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6552 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6553
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6554 status = FSRefMakePath(&dirRef, (UInt8*)path, pathSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6555 if (status)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6556 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6557
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6558 STRCAT(path, "/");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6559 STRCAT(path, filenamePtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6560 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6561 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6562 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6563 /* If the file to be saved already exists, we can get its full path
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6564 by converting its FSSpec into an FSRef. */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6565 error=FSpMakeFSRef(&file, &refFile);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6566 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6567 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6568
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6569 status=FSRefMakePath(&refFile, (UInt8 *) path, pathSize);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6570 if (status)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6571 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6572 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6573
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6574 /* Add a slash at the end if needed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6575 if (folder)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6576 STRCAT(path, "/");
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6577
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6578 return (vim_strsave(path));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6579 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6580 /* TODO: Get rid of all USE_UNIXFILENAME below */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6581 /* Set ioNamePtr, it's the same area which is always reused. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6582 theCPB.dirInfo.ioNamePtr = directoryName;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6583
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6584 /* Trick for first entry, set ioDrParID to the first value
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6585 * we want for ioDrDirID*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6586 theCPB.dirInfo.ioDrParID = file.parID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6587 theCPB.dirInfo.ioDrDirID = file.parID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6588
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6589 if ((TRUE) && (file.parID != fsRtDirID /*fsRtParID*/))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6590 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6591 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6592 theCPB.dirInfo.ioFDirIndex = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6593 /* theCPB.dirInfo.ioNamePtr = directoryName; Already done above. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6594 theCPB.dirInfo.ioVRefNum = file.vRefNum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6595 /* theCPB.dirInfo.ioDirID = irrevelant when ioFDirIndex = -1 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6596 theCPB.dirInfo.ioDrDirID = theCPB.dirInfo.ioDrParID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6597
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6598 /* As ioFDirIndex = -1, get the info of ioDrDirID, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6599 /* *ioNamePtr[0 TO 31] will be updated */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6600 error = PBGetCatInfo(&theCPB,false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6601
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6602 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6603 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6604
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6605 /* Put the new directoryName in front of the current fname */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6606 STRCPY(temporaryPtr, filenamePtr);
418
84825cc6f049 updated for version 7.0109
vimboss
parents: 308
diff changeset
6607 vim_strncpy(filenamePtr, &directoryName[1], directoryName[0]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6608 STRCAT(filenamePtr, ":");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6609 STRCAT(filenamePtr, temporaryPtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6610 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6611 #if 1 /* def USE_UNIXFILENAME */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6612 while ((theCPB.dirInfo.ioDrParID != fsRtDirID) /* && */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6613 /* (theCPB.dirInfo.ioDrDirID != fsRtDirID)*/);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6614 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6615 while (theCPB.dirInfo.ioDrDirID != fsRtDirID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6616 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6617
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6618 /* Get the information about the volume on which the file reside */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6619 theCPB.dirInfo.ioFDirIndex = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6620 /* theCPB.dirInfo.ioNamePtr = directoryName; Already done above. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6621 theCPB.dirInfo.ioVRefNum = file.vRefNum;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6622 /* theCPB.dirInfo.ioDirID = irrevelant when ioFDirIndex = -1 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6623 theCPB.dirInfo.ioDrDirID = theCPB.dirInfo.ioDrParID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6624
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6625 /* As ioFDirIndex = -1, get the info of ioDrDirID, */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6626 /* *ioNamePtr[0 TO 31] will be updated */
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6627 error = PBGetCatInfo(&theCPB,false);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6628
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6629 if (error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6630 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6631
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6632 /* For MacOS Classic always add the volume name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6633 /* For MacOS X add the volume name preceded by "Volumes" */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6634 /* when we are not refering to the boot volume */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6635 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6636 if (file.vRefNum != dfltVol_vRefNum)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6637 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6638 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6639 /* Add the volume name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6640 STRCPY(temporaryPtr, filenamePtr);
418
84825cc6f049 updated for version 7.0109
vimboss
parents: 308
diff changeset
6641 vim_strncpy(filenamePtr, &directoryName[1], directoryName[0]);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6642 STRCAT(filenamePtr, ":");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6643 STRCAT(filenamePtr, temporaryPtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6644
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6645 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6646 STRCPY(temporaryPtr, filenamePtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6647 filenamePtr[0] = 0; /* NULL terminate the string */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6648 STRCAT(filenamePtr, "Volumes:");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6649 STRCAT(filenamePtr, temporaryPtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6650 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6651 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6652
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6653 /* Append final path separator if it's a folder */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6654 if (folder)
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6655 STRCAT(fname, ":");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6656
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6657 /* As we use Unix File Name for MacOS X convert it */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6658 #ifdef USE_UNIXFILENAME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6659 /* Need to insert leading / */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6660 /* TODO: get the above code to use directly the / */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6661 STRCPY(&temporaryPtr[1], filenamePtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6662 temporaryPtr[0] = '/';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6663 STRCPY(filenamePtr, temporaryPtr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6664 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6665 char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6666 for (p = fname; *p; p++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6667 if (*p == ':')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6668 *p = '/';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6669 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6670 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6671
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
6672 return (vim_strsave(fname));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6673 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6674 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6675
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6676 #if defined(USE_IM_CONTROL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6677 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6678 * Input Method Control functions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6679 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6680
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6681 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6682 * Notify cursor position to IM.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6683 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6684 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6685 im_set_position(int row, int col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6686 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6687 /* TODO: Implement me! */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6688 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6689
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6690 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6691 * Set IM status on ("active" is TRUE) or off ("active" is FALSE).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6692 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6693 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6694 im_set_active(int active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6695 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6696 KeyScript(active ? smKeySysScript : smKeyRoman);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6697 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6698
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6699 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6700 * Get IM status. When IM is on, return not 0. Else return 0.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6701 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6702 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6703 im_get_status()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6704 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6705 SInt32 script = GetScriptManagerVariable(smKeyScript);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6706 return (script != smRoman
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6707 && script == GetScriptManagerVariable(smSysScript)) ? 1 : 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6708 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6709 #endif /* defined(USE_IM_CONTROL) || defined(PROTO) */