comparison src/os_mac.h @ 7:3fc0f57ecb91 v7.0001

updated for version 7.0001
author vimboss
date Sun, 13 Jun 2004 20:20:40 +0000
parents
children 293621502c4d
comparison
equal deleted inserted replaced
6:c2daee826b8f 7:3fc0f57ecb91
1 /* vi:set ts=8 sts=4 sw=4:
2 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 */
8
9 /* Before Including the MacOS specific files,
10 * lets set the OPAQUE_TOOLBOX_STRUCTS to 0 so we
11 * can access the internal structures.
12 * (Until fully Carbon compliant)
13 * TODO: Can we remove this? (Dany)
14 */
15 #if 0
16 # define OPAQUE_TOOLBOX_STRUCTS 0
17 #endif
18
19 /*
20 * Macintosh machine-dependent things.
21 */
22 #include <QuickDraw.h>
23 #include <ToolUtils.h>
24 #include <LowMem.h>
25 #include <Scrap.h>
26 #include <Sound.h>
27 #include <TextUtils.h>
28 #include <Memory.h>
29 #include <OSUtils.h>
30 #include <Files.h>
31 #ifdef FEAT_MBYTE
32 # include <Script.h>
33 #endif
34
35 /*
36 * Unix interface
37 */
38 #if defined(__MWERKS__) /* for CodeWarrior */
39 # include <unistd.h>
40 # include <utsname.h>
41 # include <unix.h>
42 #endif
43 #if defined(__APPLE_CC__) /* for Project Builder and ... */
44 # include <unistd.h>
45 #endif
46 /* Get stat.h or something similar. Comment: How come some OS get in in vim.h */
47 #if defined(__MWERKS__)
48 # include <stat.h>
49 #endif
50 #if defined(__APPLE_CC__)
51 # include <sys/stat.h>
52 #endif
53 #if defined(__MRC__) || defined(__SC__) /* for Apple MPW Compilers */
54 /* There's no stat.h for MPW? */
55 # ifdef powerc
56 # pragma options align=power
57 # endif
58 struct stat
59 {
60 UInt32 st_mtime;
61 UInt32 st_mode;
62 UInt32 st_size;
63 };
64 # ifdef powerc
65 # pragma options align=reset
66 # endif
67 #endif
68 #if defined(__APPLE_CC__) /* && defined(HAVE_CURSE) */
69 /* The curses.h from MacOS X provides by default some BACKWARD compatibilty
70 * definition which can cause us problem later on. So we undefine a few of them. */
71 # include <curses.h>
72 # undef reg
73 # undef ospeed
74 /* OK defined to 0 in MacOS X 10.2 curses! Remove it, we define it to be 1. */
75 # undef OK
76 #endif
77 #include <signal.h>
78 #include <errno.h>
79 #include <stdio.h>
80 #include <stdlib.h>
81 #include <time.h>
82 #ifdef MACOS_X
83 # include <dirent.h>
84 #endif
85
86 /*
87 * Incompatibility checks
88 */
89
90 /* Got problem trying to use shared library in 68k */
91 #if !defined(__POWERPC__) && defined(FEAT_PYTHON)
92 # undef FEAT_PYTHON
93 # warning Auto-disabling Python. Not yet supported in 68k.
94 #endif
95
96 #if !defined(__POWERPC__) && !defined(__ppc__)
97 # if !__option(enumsalwaysint)
98 # error "You must compile with enums always int!"
99 # endif
100 # if defined(__MWERKS__) && !defined(__fourbyteints__)
101 # error "You must compile the project with 4-byte ints"
102 /* MPW ints are always 4 byte long */
103 # endif
104 #endif
105
106 /*
107 * MacOS specific #define
108 */
109
110 /* This will go away when CMD_KEY fully tested */
111 #define USE_CMD_KEY
112 /* On MacOS X use the / not the : */
113 /* TODO: Should file such as ~/.vimrc reside instead in
114 * ~/Library/Vim or ~/Library/Preferences/org.vim.vim/ ? (Dany)
115 */
116 /* When compiled under MacOS X (including CARBON version)
117 * we use the Unix File path style */
118 #if defined(TARGET_API_MAC_OSX) && TARGET_API_MAC_OSX
119 # undef COLON_AS_PATHSEP
120 # define USE_UNIXFILENAME
121 #else
122 # define COLON_AS_PATHSEP
123 # define DONT_ADD_PATHSEP_TO_DIR
124 #endif
125
126
127 /*
128 * Generic Vim #define
129 */
130
131 #define FEAT_SOURCE_FFS
132 #define FEAT_SOURCE_FF_MAC
133
134 #define USE_EXE_NAME /* to find $VIM */
135 #define CASE_INSENSITIVE_FILENAME /* ignore case when comparing file names */
136 #define SPACE_IN_FILENAME
137 #define BREAKCHECK_SKIP 32 /* call mch_breakcheck() each time, it's
138 quite fast. Did I forgot to update the comment */
139
140
141 #undef USE_FNAME_CASE /* So that :e os_Mac.c, :w, save back the file as os_mac.c */
142 #define BINARY_FILE_IO
143 #define EOL_DEFAULT EOL_MAC
144 #ifndef MACOS_X_UNIX /* I hope that switching these two lines */
145 # define USE_CR /* does what I want -- BNF */
146 # define NO_CONSOLE /* don't include console mode */
147 #endif
148 #define HAVE_AVAIL_MEM
149
150 #ifndef HAVE_CONFIG_H
151 /* #define SYNC_DUP_CLOSE sync() a file with dup() and close() */
152 # define HAVE_STRING_H
153 # define HAVE_STRCSPN
154 # define HAVE_MEMSET
155 # define USE_TMPNAM /* use tmpnam() instead of mktemp() */
156 # define HAVE_FCNTL_H
157 # define HAVE_QSORT
158 # define HAVE_ST_MODE /* have stat.st_mode */
159
160 # if defined(__DATE__) && defined(__TIME__)
161 # define HAVE_DATE_TIME
162 # endif
163 # define HAVE_STRFTIME
164 #endif
165
166
167 /*
168 * Names for the EXRC, HELP and temporary files.
169 * Some of these may have been defined in the makefile.
170 */
171
172 #ifndef SYS_VIMRC_FILE
173 # ifdef COLON_AS_PATHSEP
174 # define SYS_VIMRC_FILE "$VIM:vimrc"
175 # else
176 # define SYS_VIMRC_FILE "$VIM/vimrc"
177 # endif
178 #endif
179 #ifndef SYS_GVIMRC_FILE
180 # ifdef COLON_AS_PATHSEP
181 # define SYS_GVIMRC_FILE "$VIM:gvimrc"
182 # else
183 # define SYS_GVIMRC_FILE "$VIM/gvimrc"
184 # endif
185 #endif
186 #ifndef SYS_MENU_FILE
187 # ifdef COLON_AS_PATHSEP
188 # define SYS_MENU_FILE "$VIMRUNTIME:menu.vim"
189 # else
190 # define SYS_MENU_FILE "$VIMRUNTIME/menu.vim"
191 # endif
192 #endif
193 #ifndef SYS_OPTWIN_FILE
194 # ifdef COLON_AS_PATHSEP
195 # define SYS_OPTWIN_FILE "$VIMRUNTIME:optwin.vim"
196 # else
197 # define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim"
198 # endif
199 #endif
200 #ifndef EVIM_FILE
201 # ifdef COLON_AS_PATHSEP
202 # define EVIM_FILE "$VIMRUNTIME:evim.vim"
203 # else
204 # define EVIM_FILE "$VIMRUNTIME/evim.vim"
205 # endif
206 #endif
207
208 #ifdef FEAT_GUI
209 # ifndef USR_GVIMRC_FILE
210 # ifdef COLON_AS_PATHSEP
211 # define USR_GVIMRC_FILE "$VIM:.gvimrc"
212 # else
213 # define USR_GVIMRC_FILE "~/.gvimrc"
214 # endif
215 # endif
216 # ifndef GVIMRC_FILE
217 # define GVIMRC_FILE "_gvimrc"
218 # endif
219 #endif
220 #ifndef USR_VIMRC_FILE
221 # ifdef COLON_AS_PATHSEP
222 # define USR_VIMRC_FILE "$VIM:.vimrc"
223 # else
224 # define USR_VIMRC_FILE "~/.vimrc"
225 # endif
226 #endif
227
228 #ifndef USR_EXRC_FILE
229 # ifdef COLON_AS_PATHSEP
230 # define USR_EXRC_FILE "$VIM:.exrc"
231 # else
232 # define USR_EXRC_FILE "~/.exrc"
233 # endif
234 #endif
235
236 #ifndef VIMRC_FILE
237 # define VIMRC_FILE "_vimrc"
238 #endif
239
240 #ifndef EXRC_FILE
241 # define EXRC_FILE "_exrc"
242 #endif
243
244 #ifndef DFLT_HELPFILE
245 # ifdef COLON_AS_PATHSEP
246 # define DFLT_HELPFILE "$VIMRUNTIME:doc:help.txt"
247 # else
248 # define DFLT_HELPFILE "$VIMRUNTIME/doc/help.txt"
249 # endif
250 #endif
251
252 #ifndef FILETYPE_FILE
253 # define FILETYPE_FILE "filetype.vim"
254 #endif
255 #ifndef FTPLUGIN_FILE
256 # define FTPLUGIN_FILE "ftplugin.vim"
257 #endif
258 #ifndef INDENT_FILE
259 # define INDENT_FILE "indent.vim"
260 #endif
261 #ifndef FTOFF_FILE
262 # define FTOFF_FILE "ftoff.vim"
263 #endif
264 #ifndef FTPLUGOF_FILE
265 # define FTPLUGOF_FILE "ftplugof.vim"
266 #endif
267 #ifndef INDOFF_FILE
268 # define INDOFF_FILE "indoff.vim"
269 #endif
270
271 #ifndef SYNTAX_FNAME
272 # ifdef COLON_AS_PATHSEP
273 # define SYNTAX_FNAME "$VIMRUNTIME:syntax:%s.vim"
274 # else
275 # define SYNTAX_FNAME "$VIMRUNTIME/syntax/%s.vim"
276 # endif
277 #endif
278
279 #ifdef FEAT_VIMINFO
280 # ifndef VIMINFO_FILE
281 # ifdef COLON_AS_PATHSEP
282 # define VIMINFO_FILE "$VIM:viminfo"
283 # else
284 # define VIMINFO_FILE "~/.viminfo"
285 # endif
286 # endif
287 #endif /* FEAT_VIMINFO */
288
289 #ifndef DFLT_BDIR
290 # define DFLT_BDIR "." /* default for 'backupdir' */
291 #endif
292
293 #ifndef DFLT_DIR
294 # define DFLT_DIR "." /* default for 'directory' */
295 #endif
296
297 #ifndef DFLT_VDIR
298 # ifdef COLON_AS_PATHSEP
299 # define DFLT_VDIR "$VIM:vimfiles:view" /* default for 'viewdir' */
300 # else
301 # define DFLT_VDIR "$VIM/vimfiles/view" /* default for 'viewdir' */
302 # endif
303 #endif
304
305 #define DFLT_ERRORFILE "errors.err"
306 #ifdef COLON_AS_PATHSEP
307 # define DFLT_RUNTIMEPATH "$VIM:vimfiles,$VIMRUNTIME,$VIM:vimfiles:after"
308 #else
309 # define DFLT_RUNTIMEPATH "~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after"
310 #endif
311
312 /*
313 * Macintosh has plenty of memory, use large buffers
314 */
315 #define CMDBUFFSIZE 1024 /* size of the command processing buffer */
316
317 #if defined(MACOS_X_UNIX)
318 # define MAXPATHL 1024
319 # define BASENAMELEN (MAXNAMLEN - 5) /* length of base of filename */
320 #else
321 # define MAXPATHL 256 /* Limited by the Pascal Strings */
322 # define BASENAMELEN (32-5-1) /* length of base of filename */
323 #endif
324
325 #ifndef DFLT_MAXMEM
326 # define DFLT_MAXMEM 512 /* use up to 512 Kbyte for buffer */
327 #endif
328
329 #ifndef DFLT_MAXMEMTOT
330 # define DFLT_MAXMEMTOT 2048 /* use up to 2048 Kbyte for Vim */
331 #endif
332
333 #define WILDCHAR_LIST "*?[{`$"
334
335 /**************/
336 #define mch_rename(src, dst) rename(src, dst)
337 #define mch_remove(x) unlink((char *)(x))
338 #ifndef mch_getenv
339 # if defined(__MRC__) || defined(__SC__)
340 # define mch_getenv(name) ((char_u *)getenv((char *)(name)))
341 # define mch_setenv(name, val, x) setenv((name), (val))
342 # elif defined(__APPLE_CC__)
343 # define mch_getenv(name) ((char_u *)getenv((char *)(name)))
344 /*# define mch_setenv(name, val, x) setenv((name), (val)) */ /* Obsoleted by Dany on Oct 30, 2001 */
345 # define mch_setenv(name, val, x) setenv(name, val, x)
346 # else
347 /* vim_getenv() is in pty.c */
348 # define USE_VIMPTY_GETENV
349 # define mch_getenv(x) vimpty_getenv(x)
350 # define mch_setenv(name, val, x) setenv(name, val, x)
351 # endif
352 #endif
353
354 #ifndef HAVE_CONFIG_H
355 # ifdef __APPLE_CC__
356 /* Assuming compiling for MacOS X */
357 /* Trying to take advantage of the prebinding */
358 # define HAVE_TGETENT
359 # define OSPEED_EXTERN
360 # define UP_BC_PC_EXTERN
361 # endif
362 #endif
363
364 /* Some "prep work" definition to be able to compile the MacOS X
365 * version with os_unix.x instead of os_mac.c. Based on the result
366 * of ./configure for console MacOS X.
367 */
368
369 #ifdef MACOS_X_UNIX
370 # define SIGPROTOARG (int)
371 # define SIGDEFARG(s) (s) int s;
372 # define SIGDUMMYARG 0
373 # undef HAVE_AVAIL_MEM
374 # ifndef HAVE_CONFIG_H
375 # define RETSIGTYPE void
376 # define SIGRETURN return
377 /*# define USE_SYSTEM */ /* Output ship do debugger :(, but ot compile */
378 # define HAVE_SYS_WAIT_H 1 /* Attempt */
379 # define HAVE_TERMIOS_H 1
380 # define SYS_SELECT_WITH_SYS_TIME 1
381 # define HAVE_SELECT 1
382 # define HAVE_SYS_SELECT_H 1
383 # define HAVE_PUTENV
384 # define HAVE_SETENV
385 # define HAVE_RENAME
386 # endif
387 # define mch_chdir(s) chdir(s)
388 #endif
389
390 #if defined(MACOS_X) && !defined(HAVE_CONFIG_H)
391 # define HAVE_PUTENV
392 #endif
393
394 /* A Mac constant causing big problem to syntax highlighting */
395 #define UNKNOWN_CREATOR '\?\?\?\?'
396
397 /*
398 * for debugging
399 */
400 #ifdef MACOS_X
401 # ifdef _DEBUG
402 # define TRACE Trace
403 void Trace(char *fmt, ...);
404 # else
405 # define TRACE 1 ? (void)0 : printf
406 # endif
407 #endif
408
409 #ifdef MACOS_CLASSIC
410 # define TRACE 1 ? (int)0 : printf
411 #endif