xref: /vim-8.2.3635/src/os_mac.h (revision 94688b8a)
1 /* vi:set ts=8 sts=4 sw=4 noet:
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 /* Include MAC_OS_X_VERSION_* macros */
20 #ifdef HAVE_AVAILABILITYMACROS_H
21 # include <AvailabilityMacros.h>
22 #endif
23 
24 /*
25  * Macintosh machine-dependent things.
26  *
27  * Include the Mac header files, unless also compiling with X11 (the header
28  * files have many conflicts).
29  */
30 #ifdef FEAT_GUI_MAC
31 # include <Quickdraw.h>	    /* Apple calls it QuickDraw.h... */
32 # include <ToolUtils.h>
33 # include <LowMem.h>
34 # include <Scrap.h>
35 # include <Sound.h>
36 # include <TextUtils.h>
37 # include <Memory.h>
38 # include <OSUtils.h>
39 # include <Files.h>
40 # include <Script.h>
41 #endif
42 
43 /*
44  * Unix interface
45  */
46 #if defined(__APPLE_CC__) /* for Project Builder and ... */
47 # include <unistd.h>
48 /* Get stat.h or something similar. Comment: How come some OS get in in vim.h */
49 # include <sys/stat.h>
50 /* && defined(HAVE_CURSE) */
51 /* The curses.h from MacOS X provides by default some BACKWARD compatibility
52  * definition which can cause us problem later on. So we undefine a few of them. */
53 # include <curses.h>
54 # undef reg
55 # undef ospeed
56 /* OK defined to 0 in MacOS X 10.2 curses!  Remove it, we define it to be 1. */
57 # undef OK
58 #endif
59 #include <signal.h>
60 #include <errno.h>
61 #include <stdio.h>
62 #include <stdlib.h>
63 #include <time.h>
64 #include <dirent.h>
65 
66 /*
67  * MacOS specific #define
68  */
69 
70 /* This will go away when CMD_KEY fully tested */
71 #define USE_CMD_KEY
72 /* On MacOS X use the / not the : */
73 /* TODO: Should file such as ~/.vimrc reside instead in
74  *       ~/Library/Vim or ~/Library/Preferences/org.vim.vim/ ? (Dany)
75  */
76 /* When compiled under MacOS X (including CARBON version)
77  * we use the Unix File path style.  Also when UNIX is defined. */
78 #define USE_UNIXFILENAME
79 
80 
81 /*
82  * Generic Vim #define
83  */
84 
85 #define FEAT_SOURCE_FFS
86 #define FEAT_SOURCE_FF_MAC
87 
88 #define USE_EXE_NAME		    /* to find  $VIM */
89 #define CASE_INSENSITIVE_FILENAME   /* ignore case when comparing file names */
90 #define SPACE_IN_FILENAME
91 #define BREAKCHECK_SKIP	   32	    /* call mch_breakcheck() each time, it's
92 				       quite fast. Did I forgot to update the
93 				       comment */
94 
95 #define USE_FNAME_CASE		/* make ":e os_Mac.c" open the file in its
96 				   original case, as "os_mac.c" */
97 #define BINARY_FILE_IO
98 #define EOL_DEFAULT EOL_MAC
99 #define HAVE_AVAIL_MEM
100 
101 #ifndef HAVE_CONFIG_H
102 # define HAVE_STRING_H
103 # define HAVE_STRCSPN
104 # define HAVE_MEMSET
105 # define USE_TMPNAM		/* use tmpnam() instead of mktemp() */
106 # define HAVE_FCNTL_H
107 # define HAVE_QSORT
108 # define HAVE_ST_MODE		/* have stat.st_mode */
109 # define HAVE_MATH_H
110 
111 # if defined(__DATE__) && defined(__TIME__)
112 #  define HAVE_DATE_TIME
113 # endif
114 # define HAVE_STRFTIME
115 #endif
116 
117 /*
118  * Names for the EXRC, HELP and temporary files.
119  * Some of these may have been defined in the makefile.
120  */
121 
122 #ifndef SYS_VIMRC_FILE
123 # define SYS_VIMRC_FILE "$VIM/vimrc"
124 #endif
125 #ifndef SYS_GVIMRC_FILE
126 # define SYS_GVIMRC_FILE "$VIM/gvimrc"
127 #endif
128 #ifndef SYS_MENU_FILE
129 # define SYS_MENU_FILE	"$VIMRUNTIME/menu.vim"
130 #endif
131 #ifndef SYS_OPTWIN_FILE
132 # define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim"
133 #endif
134 #ifndef VIM_DEFAULTS_FILE
135 # define VIM_DEFAULTS_FILE "$VIMRUNTIME/defaults.vim"
136 #endif
137 #ifndef EVIM_FILE
138 # define EVIM_FILE	"$VIMRUNTIME/evim.vim"
139 #endif
140 
141 #ifdef FEAT_GUI
142 # ifndef USR_GVIMRC_FILE
143 #  define USR_GVIMRC_FILE "~/.gvimrc"
144 # endif
145 # ifndef GVIMRC_FILE
146 #  define GVIMRC_FILE	"_gvimrc"
147 # endif
148 #endif
149 #ifndef USR_VIMRC_FILE
150 # define USR_VIMRC_FILE	"~/.vimrc"
151 #endif
152 
153 #ifndef USR_EXRC_FILE
154 # define USR_EXRC_FILE	"~/.exrc"
155 #endif
156 
157 #ifndef VIMRC_FILE
158 # define VIMRC_FILE	"_vimrc"
159 #endif
160 
161 #ifndef EXRC_FILE
162 # define EXRC_FILE	"_exrc"
163 #endif
164 
165 #ifndef DFLT_HELPFILE
166 # define DFLT_HELPFILE	"$VIMRUNTIME/doc/help.txt"
167 #endif
168 
169 #ifndef FILETYPE_FILE
170 # define FILETYPE_FILE	"filetype.vim"
171 #endif
172 #ifndef FTPLUGIN_FILE
173 # define FTPLUGIN_FILE	"ftplugin.vim"
174 #endif
175 #ifndef INDENT_FILE
176 # define INDENT_FILE	"indent.vim"
177 #endif
178 #ifndef FTOFF_FILE
179 # define FTOFF_FILE	"ftoff.vim"
180 #endif
181 #ifndef FTPLUGOF_FILE
182 # define FTPLUGOF_FILE	"ftplugof.vim"
183 #endif
184 #ifndef INDOFF_FILE
185 # define INDOFF_FILE	"indoff.vim"
186 #endif
187 
188 #ifndef SYNTAX_FNAME
189 # define SYNTAX_FNAME	"$VIMRUNTIME/syntax/%s.vim"
190 #endif
191 
192 #ifdef FEAT_VIMINFO
193 # ifndef VIMINFO_FILE
194 #  define VIMINFO_FILE	"~/.viminfo"
195 # endif
196 #endif /* FEAT_VIMINFO */
197 
198 #ifndef DFLT_BDIR
199 # define DFLT_BDIR	"."	/* default for 'backupdir' */
200 #endif
201 
202 #ifndef DFLT_DIR
203 # define DFLT_DIR	"."	/* default for 'directory' */
204 #endif
205 
206 #ifndef DFLT_VDIR
207 # define DFLT_VDIR	"$VIM/vimfiles/view"	/* default for 'viewdir' */
208 #endif
209 
210 #define DFLT_ERRORFILE		"errors.err"
211 
212 #ifndef DFLT_RUNTIMEPATH
213 # define DFLT_RUNTIMEPATH	"~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after"
214 #endif
215 #ifndef CLEAN_RUNTIMEPATH
216 # define CLEAN_RUNTIMEPATH	"$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
217 #endif
218 
219 /*
220  * Macintosh has plenty of memory, use large buffers
221  */
222 #define CMDBUFFSIZE 1024	/* size of the command processing buffer */
223 
224 #ifndef DFLT_MAXMEM
225 # define DFLT_MAXMEM	512	/* use up to  512 Kbyte for buffer */
226 #endif
227 
228 #ifndef DFLT_MAXMEMTOT
229 # define DFLT_MAXMEMTOT	2048	/* use up to 2048 Kbyte for Vim */
230 #endif
231 
232 #define WILDCHAR_LIST "*?[{`$"
233 
234 /**************/
235 #define mch_rename(src, dst) rename(src, dst)
236 #define mch_remove(x) unlink((char *)(x))
237 #ifndef mch_getenv
238 # if defined(__APPLE_CC__)
239 #  define mch_getenv(name)  ((char_u *)getenv((char *)(name)))
240 #  define mch_setenv(name, val, x) setenv(name, val, x)
241 # else
242   /* vim_getenv() is in pty.c */
243 #  define USE_VIMPTY_GETENV
244 #  define mch_getenv(x) vimpty_getenv(x)
245 #  define mch_setenv(name, val, x) setenv(name, val, x)
246 # endif
247 #endif
248 
249 #ifndef HAVE_CONFIG_H
250 # ifdef __APPLE_CC__
251 /* Assuming compiling for MacOS X */
252 /* Trying to take advantage of the prebinding */
253 #  define HAVE_TGETENT
254 #  define OSPEED_EXTERN
255 #  define UP_BC_PC_EXTERN
256 # endif
257 #endif
258 
259 /* Some "prep work" definition to be able to compile the MacOS X
260  * version with os_unix.c instead of os_mac.c. Based on the result
261  * of ./configure for console MacOS X.
262  */
263 
264 #ifndef SIGPROTOARG
265 # define SIGPROTOARG	(int)
266 #endif
267 #ifndef SIGDEFARG
268 # define SIGDEFARG(s)	(s) int s UNUSED;
269 #endif
270 #ifndef SIGDUMMYARG
271 # define SIGDUMMYARG	0
272 #endif
273 #undef  HAVE_AVAIL_MEM
274 #ifndef HAVE_CONFIG_H
275 # define RETSIGTYPE void
276 # define SIGRETURN  return
277 /*# define USE_SYSTEM */  /* Output ship do debugger :(, but ot compile */
278 # define HAVE_SYS_WAIT_H 1 /* Attempt */
279 # define HAVE_TERMIOS_H 1
280 # define SYS_SELECT_WITH_SYS_TIME 1
281 # define HAVE_SELECT 1
282 # define HAVE_SYS_SELECT_H 1
283 # define HAVE_PUTENV
284 # define HAVE_SETENV
285 # define HAVE_RENAME
286 #endif
287 
288 #if !defined(HAVE_CONFIG_H)
289 # define HAVE_PUTENV
290 #endif
291 
292 /* A Mac constant causing big problem to syntax highlighting */
293 #define UNKNOWN_CREATOR '\?\?\?\?'
294