Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 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. |
Bram Moolenaar | ab79bcb | 2004-07-18 21:34:53 +0000 | [diff] [blame] | 21 | * |
| 22 | * Include the Mac header files, unless also compiling with X11 (the header |
| 23 | * files have many conflicts). |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 24 | */ |
Bram Moolenaar | ab79bcb | 2004-07-18 21:34:53 +0000 | [diff] [blame] | 25 | #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 Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 38 | #endif |
| 39 | |
| 40 | /* |
| 41 | * Unix interface |
| 42 | */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 43 | #if defined(__APPLE_CC__) /* for Project Builder and ... */ |
| 44 | # include <unistd.h> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 45 | /* Get stat.h or something similar. Comment: How come some OS get in in vim.h */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 46 | # include <sys/stat.h> |
Bram Moolenaar | 0fd9289 | 2006-03-09 22:27:48 +0000 | [diff] [blame] | 47 | /* && defined(HAVE_CURSE) */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 48 | /* 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 Moolenaar | 0fd9289 | 2006-03-09 22:27:48 +0000 | [diff] [blame] | 61 | #include <dirent.h> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 62 | |
| 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 Moolenaar | 5eb86f9 | 2004-07-26 12:53:41 +0000 | [diff] [blame] | 74 | * we use the Unix File path style. Also when UNIX is defined. */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 75 | # define USE_UNIXFILENAME |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 76 | |
| 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 Moolenaar | 5eb86f9 | 2004-07-26 12:53:41 +0000 | [diff] [blame] | 89 | quite fast. Did I forgot to update the |
| 90 | comment */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 91 | |
| 92 | |
Bram Moolenaar | 43abc52 | 2005-12-10 20:15:02 +0000 | [diff] [blame] | 93 | #define USE_FNAME_CASE /* make ":e os_Mac.c" open the file in its |
| 94 | original case, as "os_mac.c" */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 95 | #define BINARY_FILE_IO |
| 96 | #define EOL_DEFAULT EOL_MAC |
Bram Moolenaar | 5eb86f9 | 2004-07-26 12:53:41 +0000 | [diff] [blame] | 97 | #ifndef MACOS_X_UNIX /* I hope that switching these two lines */ |
| 98 | # define USE_CR /* does what I want -- BNF */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 99 | # 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 Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 119 | /* |
| 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 Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 125 | # define SYS_VIMRC_FILE "$VIM/vimrc" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 126 | #endif |
| 127 | #ifndef SYS_GVIMRC_FILE |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 128 | # define SYS_GVIMRC_FILE "$VIM/gvimrc" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 129 | #endif |
| 130 | #ifndef SYS_MENU_FILE |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 131 | # define SYS_MENU_FILE "$VIMRUNTIME/menu.vim" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 132 | #endif |
| 133 | #ifndef SYS_OPTWIN_FILE |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 134 | # define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 135 | #endif |
| 136 | #ifndef EVIM_FILE |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 137 | # define EVIM_FILE "$VIMRUNTIME/evim.vim" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 138 | #endif |
| 139 | |
| 140 | #ifdef FEAT_GUI |
| 141 | # ifndef USR_GVIMRC_FILE |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 142 | # define USR_GVIMRC_FILE "~/.gvimrc" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 143 | # endif |
| 144 | # ifndef GVIMRC_FILE |
| 145 | # define GVIMRC_FILE "_gvimrc" |
| 146 | # endif |
| 147 | #endif |
| 148 | #ifndef USR_VIMRC_FILE |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 149 | # define USR_VIMRC_FILE "~/.vimrc" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 150 | #endif |
| 151 | |
| 152 | #ifndef USR_EXRC_FILE |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 153 | # define USR_EXRC_FILE "~/.exrc" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 154 | #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 Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 165 | # define DFLT_HELPFILE "$VIMRUNTIME/doc/help.txt" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 166 | #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 Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 188 | # define SYNTAX_FNAME "$VIMRUNTIME/syntax/%s.vim" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 189 | #endif |
| 190 | |
| 191 | #ifdef FEAT_VIMINFO |
| 192 | # ifndef VIMINFO_FILE |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 193 | # define VIMINFO_FILE "~/.viminfo" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 194 | # 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 Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 206 | # define DFLT_VDIR "$VIM/vimfiles/view" /* default for 'viewdir' */ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 207 | #endif |
| 208 | |
| 209 | #define DFLT_ERRORFILE "errors.err" |
Bram Moolenaar | ab79bcb | 2004-07-18 21:34:53 +0000 | [diff] [blame] | 210 | |
| 211 | #ifndef DFLT_RUNTIMEPATH |
Bram Moolenaar | ab79bcb | 2004-07-18 21:34:53 +0000 | [diff] [blame] | 212 | # define DFLT_RUNTIMEPATH "~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 213 | #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 |