blob: 22fd164d7f0d6ec63e3c7163bdf3e19f6df24ef6 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001/* 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.
Bram Moolenaarab79bcb2004-07-18 21:34:53 +000021 *
22 * Include the Mac header files, unless also compiling with X11 (the header
23 * files have many conflicts).
Bram Moolenaar071d4272004-06-13 20:20:40 +000024 */
Bram Moolenaarab79bcb2004-07-18 21:34:53 +000025#ifndef FEAT_X11
26# include <QuickDraw.h>
27# include <ToolUtils.h>
28# include <LowMem.h>
29# include <Scrap.h>
30# include <Sound.h>
31# include <TextUtils.h>
32# include <Memory.h>
33# include <OSUtils.h>
34# include <Files.h>
35# ifdef FEAT_MBYTE
36# include <Script.h>
37# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +000038#endif
39
40/*
41 * Unix interface
42 */
Bram Moolenaar071d4272004-06-13 20:20:40 +000043#if defined(__APPLE_CC__) /* for Project Builder and ... */
44# include <unistd.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +000045/* Get stat.h or something similar. Comment: How come some OS get in in vim.h */
Bram Moolenaar071d4272004-06-13 20:20:40 +000046# include <sys/stat.h>
Bram Moolenaar0fd92892006-03-09 22:27:48 +000047/* && defined(HAVE_CURSE) */
Bram Moolenaar071d4272004-06-13 20:20:40 +000048/* The curses.h from MacOS X provides by default some BACKWARD compatibilty
49 * definition which can cause us problem later on. So we undefine a few of them. */
50# include <curses.h>
51# undef reg
52# undef ospeed
53/* OK defined to 0 in MacOS X 10.2 curses! Remove it, we define it to be 1. */
54# undef OK
55#endif
56#include <signal.h>
57#include <errno.h>
58#include <stdio.h>
59#include <stdlib.h>
60#include <time.h>
Bram Moolenaar0fd92892006-03-09 22:27:48 +000061#include <dirent.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +000062
63/*
64 * MacOS specific #define
65 */
66
67/* This will go away when CMD_KEY fully tested */
68#define USE_CMD_KEY
69/* On MacOS X use the / not the : */
70/* TODO: Should file such as ~/.vimrc reside instead in
71 * ~/Library/Vim or ~/Library/Preferences/org.vim.vim/ ? (Dany)
72 */
73/* When compiled under MacOS X (including CARBON version)
Bram Moolenaar5eb86f92004-07-26 12:53:41 +000074 * we use the Unix File path style. Also when UNIX is defined. */
Bram Moolenaar071d4272004-06-13 20:20:40 +000075# define USE_UNIXFILENAME
Bram Moolenaar071d4272004-06-13 20:20:40 +000076
77
78/*
79 * Generic Vim #define
80 */
81
82#define FEAT_SOURCE_FFS
83#define FEAT_SOURCE_FF_MAC
84
85#define USE_EXE_NAME /* to find $VIM */
86#define CASE_INSENSITIVE_FILENAME /* ignore case when comparing file names */
87#define SPACE_IN_FILENAME
88#define BREAKCHECK_SKIP 32 /* call mch_breakcheck() each time, it's
Bram Moolenaar5eb86f92004-07-26 12:53:41 +000089 quite fast. Did I forgot to update the
90 comment */
Bram Moolenaar071d4272004-06-13 20:20:40 +000091
92
Bram Moolenaar43abc522005-12-10 20:15:02 +000093#define USE_FNAME_CASE /* make ":e os_Mac.c" open the file in its
94 original case, as "os_mac.c" */
Bram Moolenaar071d4272004-06-13 20:20:40 +000095#define BINARY_FILE_IO
96#define EOL_DEFAULT EOL_MAC
Bram Moolenaar5eb86f92004-07-26 12:53:41 +000097#ifndef MACOS_X_UNIX /* I hope that switching these two lines */
98# define USE_CR /* does what I want -- BNF */
Bram Moolenaar071d4272004-06-13 20:20:40 +000099# define NO_CONSOLE /* don't include console mode */
100#endif
101#define HAVE_AVAIL_MEM
102
103#ifndef HAVE_CONFIG_H
104/* #define SYNC_DUP_CLOSE sync() a file with dup() and close() */
105# define HAVE_STRING_H
106# define HAVE_STRCSPN
107# define HAVE_MEMSET
108# define USE_TMPNAM /* use tmpnam() instead of mktemp() */
109# define HAVE_FCNTL_H
110# define HAVE_QSORT
111# define HAVE_ST_MODE /* have stat.st_mode */
112
113# if defined(__DATE__) && defined(__TIME__)
114# define HAVE_DATE_TIME
115# endif
116# define HAVE_STRFTIME
117#endif
118
Bram Moolenaar071d4272004-06-13 20:20:40 +0000119/*
120 * Names for the EXRC, HELP and temporary files.
121 * Some of these may have been defined in the makefile.
122 */
123
124#ifndef SYS_VIMRC_FILE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000125# define SYS_VIMRC_FILE "$VIM/vimrc"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000126#endif
127#ifndef SYS_GVIMRC_FILE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000128# define SYS_GVIMRC_FILE "$VIM/gvimrc"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000129#endif
130#ifndef SYS_MENU_FILE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000131# define SYS_MENU_FILE "$VIMRUNTIME/menu.vim"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000132#endif
133#ifndef SYS_OPTWIN_FILE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000134# define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000135#endif
136#ifndef EVIM_FILE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000137# define EVIM_FILE "$VIMRUNTIME/evim.vim"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000138#endif
139
140#ifdef FEAT_GUI
141# ifndef USR_GVIMRC_FILE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000142# define USR_GVIMRC_FILE "~/.gvimrc"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000143# endif
144# ifndef GVIMRC_FILE
145# define GVIMRC_FILE "_gvimrc"
146# endif
147#endif
148#ifndef USR_VIMRC_FILE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000149# define USR_VIMRC_FILE "~/.vimrc"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000150#endif
151
152#ifndef USR_EXRC_FILE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000153# define USR_EXRC_FILE "~/.exrc"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000154#endif
155
156#ifndef VIMRC_FILE
157# define VIMRC_FILE "_vimrc"
158#endif
159
160#ifndef EXRC_FILE
161# define EXRC_FILE "_exrc"
162#endif
163
164#ifndef DFLT_HELPFILE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000165# define DFLT_HELPFILE "$VIMRUNTIME/doc/help.txt"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000166#endif
167
168#ifndef FILETYPE_FILE
169# define FILETYPE_FILE "filetype.vim"
170#endif
171#ifndef FTPLUGIN_FILE
172# define FTPLUGIN_FILE "ftplugin.vim"
173#endif
174#ifndef INDENT_FILE
175# define INDENT_FILE "indent.vim"
176#endif
177#ifndef FTOFF_FILE
178# define FTOFF_FILE "ftoff.vim"
179#endif
180#ifndef FTPLUGOF_FILE
181# define FTPLUGOF_FILE "ftplugof.vim"
182#endif
183#ifndef INDOFF_FILE
184# define INDOFF_FILE "indoff.vim"
185#endif
186
187#ifndef SYNTAX_FNAME
Bram Moolenaar071d4272004-06-13 20:20:40 +0000188# define SYNTAX_FNAME "$VIMRUNTIME/syntax/%s.vim"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000189#endif
190
191#ifdef FEAT_VIMINFO
192# ifndef VIMINFO_FILE
Bram Moolenaar071d4272004-06-13 20:20:40 +0000193# define VIMINFO_FILE "~/.viminfo"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000194# endif
195#endif /* FEAT_VIMINFO */
196
197#ifndef DFLT_BDIR
198# define DFLT_BDIR "." /* default for 'backupdir' */
199#endif
200
201#ifndef DFLT_DIR
202# define DFLT_DIR "." /* default for 'directory' */
203#endif
204
205#ifndef DFLT_VDIR
Bram Moolenaar071d4272004-06-13 20:20:40 +0000206# define DFLT_VDIR "$VIM/vimfiles/view" /* default for 'viewdir' */
Bram Moolenaar071d4272004-06-13 20:20:40 +0000207#endif
208
209#define DFLT_ERRORFILE "errors.err"
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000210
211#ifndef DFLT_RUNTIMEPATH
Bram Moolenaarab79bcb2004-07-18 21:34:53 +0000212# define DFLT_RUNTIMEPATH "~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000213#endif
214
215/*
216 * Macintosh has plenty of memory, use large buffers
217 */
218#define CMDBUFFSIZE 1024 /* size of the command processing buffer */
219
220#if defined(MACOS_X_UNIX)
221# define MAXPATHL 1024
222# define BASENAMELEN (MAXNAMLEN - 5) /* length of base of filename */
223#else
224# define MAXPATHL 256 /* Limited by the Pascal Strings */
225# define BASENAMELEN (32-5-1) /* length of base of filename */
226#endif
227
228#ifndef DFLT_MAXMEM
229# define DFLT_MAXMEM 512 /* use up to 512 Kbyte for buffer */
230#endif
231
232#ifndef DFLT_MAXMEMTOT
233# define DFLT_MAXMEMTOT 2048 /* use up to 2048 Kbyte for Vim */
234#endif
235
236#define WILDCHAR_LIST "*?[{`$"
237
238/**************/
239#define mch_rename(src, dst) rename(src, dst)
240#define mch_remove(x) unlink((char *)(x))
241#ifndef mch_getenv
242# if defined(__MRC__) || defined(__SC__)
243# define mch_getenv(name) ((char_u *)getenv((char *)(name)))
244# define mch_setenv(name, val, x) setenv((name), (val))
245# elif defined(__APPLE_CC__)
246# define mch_getenv(name) ((char_u *)getenv((char *)(name)))
247/*# define mch_setenv(name, val, x) setenv((name), (val)) */ /* Obsoleted by Dany on Oct 30, 2001 */
248# define mch_setenv(name, val, x) setenv(name, val, x)
249# else
250 /* vim_getenv() is in pty.c */
251# define USE_VIMPTY_GETENV
252# define mch_getenv(x) vimpty_getenv(x)
253# define mch_setenv(name, val, x) setenv(name, val, x)
254# endif
255#endif
256
257#ifndef HAVE_CONFIG_H
258# ifdef __APPLE_CC__
259/* Assuming compiling for MacOS X */
260/* Trying to take advantage of the prebinding */
261# define HAVE_TGETENT
262# define OSPEED_EXTERN
263# define UP_BC_PC_EXTERN
264# endif
265#endif
266
267/* Some "prep work" definition to be able to compile the MacOS X
268 * version with os_unix.x instead of os_mac.c. Based on the result
269 * of ./configure for console MacOS X.
270 */
271
272#ifdef MACOS_X_UNIX
273# define SIGPROTOARG (int)
274# define SIGDEFARG(s) (s) int s;
275# define SIGDUMMYARG 0
276# undef HAVE_AVAIL_MEM
277# ifndef HAVE_CONFIG_H
278# define RETSIGTYPE void
279# define SIGRETURN return
280/*# define USE_SYSTEM */ /* Output ship do debugger :(, but ot compile */
281# define HAVE_SYS_WAIT_H 1 /* Attempt */
282# define HAVE_TERMIOS_H 1
283# define SYS_SELECT_WITH_SYS_TIME 1
284# define HAVE_SELECT 1
285# define HAVE_SYS_SELECT_H 1
286# define HAVE_PUTENV
287# define HAVE_SETENV
288# define HAVE_RENAME
289# endif
290# define mch_chdir(s) chdir(s)
291#endif
292
293#if defined(MACOS_X) && !defined(HAVE_CONFIG_H)
294# define HAVE_PUTENV
295#endif
296
297/* A Mac constant causing big problem to syntax highlighting */
298#define UNKNOWN_CREATOR '\?\?\?\?'
299
300/*
301 * for debugging
302 */
303#ifdef MACOS_X
304# ifdef _DEBUG
305# define TRACE Trace
306 void Trace(char *fmt, ...);
307# else
308# define TRACE 1 ? (void)0 : printf
309# endif
310#endif