home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume44 / vim / part16 < prev    next >
Internet Message Format  |  1994-08-18  |  70KB

  1. From: mool@oce.nl (Bram Moolenaar)
  2. Newsgroups: comp.sources.misc
  3. Subject: v44i035:  vim - Vi IMproved editor, v3.0, Part16/26
  4. Date: 18 Aug 1994 14:02:52 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <330b8s$e5k@sparky.sterling.com>
  9. X-Md4-Signature: 414a2bdbd016e3a0c2653cbed1d0440a
  10.  
  11. Submitted-by: mool@oce.nl (Bram Moolenaar)
  12. Posting-number: Volume 44, Issue 35
  13. Archive-name: vim/part16
  14. Environment: UNIX, AMIGA, MS-DOS, Windows NT
  15. Supersedes: vim: Volume 41, Issue 50-75
  16.  
  17. #! /bin/sh
  18. # This is a shell archive.  Remove anything before this line, then feed it
  19. # into a shell via "sh file" or similar.  To overwrite existing files,
  20. # type "sh file -c".
  21. # Contents:  vim/readme3.0 vim/src/winnt.c
  22. # Wrapped by kent@sparky on Mon Aug 15 21:44:09 1994
  23. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  24. echo If this archive is complete, you will see the following message:
  25. echo '          "shar: End of archive 16 (of 26)."'
  26. if test -f 'vim/readme3.0' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'vim/readme3.0'\"
  28. else
  29.   echo shar: Extracting \"'vim/readme3.0'\" \(34259 characters\)
  30.   sed "s/^X//" >'vim/readme3.0' <<'END_OF_FILE'
  31. XThis file contains an overview of changes from Vim version 2.0 to 3.0
  32. X
  33. XThe changes new in version 2.x are marked with (2.x).
  34. XSome changes from Robert Webb are marked with (Webb 2.5).
  35. X
  36. XBig improvements
  37. X================
  38. X
  39. XAdded multiple windows and multiple buffers! See doc/windows.doc for an
  40. Xoverview of the new and changed commands.
  41. X
  42. XAdded hidden buffers. 'hidden' option can be set to create a hidden buffer
  43. Xinstead of abandoning a buffer. Added ":bnext", ":bprev", ":bNext" and
  44. X"brewind" commands to go to other buffer. Added ":buffers" command to show all
  45. Xbuffers. Added ":bmod" command: go to next modified buffer. Added ":bdelete"
  46. Xcommand: delete buffer from list. (2.4)
  47. X
  48. XAdded a lot of commands to manipulate buffers:
  49. X- Added commands to open a window for all arguments, all active buffers, all
  50. X  buffers: ":all", ":sall", ":unhide", ":sunhide", ":ball", ":sball". (2.5)
  51. X- Added ":bunload" command: Unload buffer from memory. The ":bdelete" command
  52. X  does the same plus deletes the buffer from the buffer list. (2.5)
  53. X- Arguments from command line are always put in buffer list. (2.5)
  54. X- Added ":sbuffer", ":sbnext", ":sbNext", ":sbprevious", ":sbmodified",
  55. X  ":sbrewind", ":sblast": split window and go to specified buffer. (2.5)
  56. X- Added ":wNext" and ":wprevious": write file and go back in argument list.
  57. X  (2.5)
  58. X- Added ":wqall" and ":xall", write all change buffers and exit. (2.5)
  59. X
  60. X
  61. XWhen all changes have been undone the buffer is not considered to be changed.
  62. XVim can then be exit with ":q" instead of ":q!".
  63. X
  64. XAdded simple "more" facility to listings. Can be switched on/off with the
  65. X'more' option.
  66. X
  67. XAdded Webb's code for command line completion, with "#ifdef WEBB_COMPLETE".
  68. X(Webb 2.5)
  69. X
  70. X
  71. XChanges incompatible with previous versions
  72. X===========================================
  73. X
  74. XCommand lines starting with '#' are no longer considered to be comments. '#'
  75. Xis a synonym for :number.
  76. X
  77. XEmbedded newline characters in command lines are considered to be the end of a
  78. Xcommand line. To use newline characters in a command, precede it with CTRL-V
  79. X(you have to type CTRL-V two times to get one).
  80. X
  81. XThe ":files" command is now the same as the ":buffers" command. The file list
  82. Xand the buffer list have been integrated into one list. The buffer number and
  83. Xthe file number are equal and will not change during an editing session. (2.5)
  84. X
  85. X":buffer" does not accept a file name but a buffer number. Use ":set hid" and
  86. X":e file". (2.5)
  87. X
  88. XMade 'laststatus' a numeric option. It says when to use a status line for last
  89. Xwindow: 0 is never, 1 if more than one window, 2 is always. (2.5)
  90. X
  91. XReplaced CTRL-P in insert mode by CTRL-B (for Backwards). CTRL-P can now be
  92. Xused for keyword completion. (2.5)
  93. X
  94. XThe search pattern for the :tag command does not replace the search pattern
  95. Xthat is remembered for the next search command. (Webb 2.5)
  96. X
  97. XUse CTRL-X instead of CTRL-S (subtract). Do not switch off xon/xoff in unix.c.
  98. XFixes problems with CTRL-S on some terminals. (2.4)
  99. X
  100. XUsing >> will not shift lines that start with '#' when 'si' is set. (Webb 2.5)
  101. X
  102. X"\?" in expressions (match exactly one time) replaced by "\=", makes "?\?\?"
  103. Xwork.
  104. X
  105. XThe commands "*" and "#" only search for whole words, using "\<ident\>". (Webb
  106. X2.5)
  107. X
  108. XWhen doing a ":ta" command after CTRL-T, the tag stack is truncated, rather
  109. Xthan keeping old tags at the top. Now repeating CTRL-T will get you back to
  110. Xthe first ":ta" and stop there. (Webb 2.5)
  111. X
  112. XMade argument list global, not local to each window. ":quit" works when there
  113. Xare more files to edit, except when there is only one window. (2.4)
  114. X
  115. XThe ".vim" file is not used for recovery with the "-r" argument. Use
  116. X"Vim -s file.vim file" instead.
  117. X
  118. XFirst page of swap file has changed, cannot recover files from older versions.
  119. XThe swap file can now be recognized by its start: "b0VIM 3.0", where 3.0 is
  120. Xthe version number. (3.0)
  121. X
  122. X
  123. XNew commands and functionality
  124. X==============================
  125. X
  126. XAdded insert-mode keyword completion commands CTRL-P and CTRL-N inside #ifdef
  127. XWEBB_KEYWORD_COMPL. (Webb 2.5)
  128. X
  129. XUpdated error messages for keyword completion in insert mode. (2.7)
  130. X
  131. XAdded "]f" command: Edit file whose name is under the cursor. Added CTRL-W
  132. XCTRL-F and CTRL-W f: split window and edit file whose name is
  133. Xunder the cursor. (Webb 2.5)
  134. X
  135. XChanged "]f" into "gf". Mnemonic: goto file. (2.7)
  136. X
  137. XPut "]f" and "[f" back in, they do the same as "gf". For people that have the
  138. X'g' key remapped. (2.9)
  139. X
  140. XAdded CTRL-W CTRL-R, CTRL-W r, CTRL-W R: rotate windows upwards/downwards
  141. X(2.5)
  142. X
  143. XAdded CTRL-W CTRL-X and CTRL-W x: exchange current window with next one. (Webb
  144. X2.5)
  145. X
  146. XAdded window title for xterm.
  147. X
  148. XAdded termcap options 't_so' (standout) and 't_se' (standout end). Use 't_so'
  149. Xand 't_se' if inversion is not possible and for highlighting directories.
  150. XAt some places standout mode is used instead of inversion. (Webb 2.5)
  151. X
  152. XDo wait_return() message and the message used when asked for 'y' or 'n' is now
  153. Xin standout mode. (Webb 2.5)
  154. X
  155. XAdded termcap option 't_ms' (save to move cursor in reverse mode). Makes
  156. Xinversion work on some terminals.
  157. X
  158. XAdded ":mode" command. Under Amiga and Unix this only re-sets the screen
  159. Xsize. With MSDOS it is possible to switch screen mode.
  160. X
  161. XNow also "%<", "#31<", alternate file name without extension.
  162. X
  163. XAdded ':' register. Contains last command line. "@:" repeats last command
  164. Xline.
  165. X
  166. XAdded ":exit" as synonym for ":xit". More logical, isn't it?
  167. X
  168. XAdded ":swapname". Show swap file name for current buffer.
  169. X
  170. X":args" can have arguments for redefining the argument list, just like
  171. X":next". (2.5)
  172. X
  173. XWhen the command for the tag is a search and it fails, try searching for the
  174. Xtag itself with pattern "^tag(" and "^[#a-zA-Z_].*tag(". (Webb 2.5)
  175. X
  176. X"%" will now go to matching comment delimiters (/ *, * /) and find matches for
  177. Xthe preprocessing lines #ifdef, #else, #elif and #endif. (Webb 2.5)
  178. X
  179. XUsing '%' on #if/#else/#endif makes the movement linewise. (2.7)
  180. X
  181. X"[p", "[P", "]p" and "]P" work like "p" and "P" but adjust the indent of the
  182. Xputted lines to match the context. (Webb 2.5)
  183. X
  184. XChanged put indented: "[p" and "]p" is "]p" (put forward), "[P" and "]P" is
  185. X"[p" (put backward). (2.7)
  186. X
  187. X"[(" and "[{" may be used to go to the (count'th) last unclosed ( or {.
  188. X"])" and "]}" may be used to jump to the (count'th) next unopen) or }. Can be
  189. Xused to jump to the start/end of the innermost c-code block (Webb 2.5)
  190. X
  191. XAdded count to ":", "count:" translates into ":.,.+(count - 1)". (Webb 2.5)
  192. X
  193. XAdded ":sleep" command. (2.4)
  194. X
  195. X"g" is to be used for a new series of commands. First one: "gs" sleeps for a
  196. Xmoment (Mnemonic: Go to Sleep). Give count for that many seconds. Can be
  197. Xinterrupted with CTRL-C. (2.5)
  198. X
  199. XAdded ":last" and ":slast", go to last argument. (2.5)
  200. XAdded ":argument [N]" and ":sargument [N]", go to Nth argument. (2.5)
  201. XAdded ":blast" and ":sblast", go to last buffer. (2.5)
  202. X
  203. XAdded "-o[N]" command line argument: Open N windows on startup. (2.5)
  204. X
  205. XAdded ":only", CTRL-W CTRL-O, CTRL-O o: Close all but current window. (2.5)
  206. X
  207. XAdded default digraph: <space> <char> is meta-char. (2.4)
  208. X
  209. XDigraphs with CTRL-H do not make meta characters. Use CTRL-K <space>
  210. X<char>. Fixes problem with abbreviations when 'digraph' set. (2.5)
  211. X
  212. XDon't allow digraphs with ESC. Hitting ESC in digraph exits insert mode. (2.5)
  213. X
  214. XAdded ":snext", ":sNext", ":sprev" and ":srewind" commands, split window and
  215. Xgo to next/previous file in argument list. (2.4)
  216. X
  217. XAdded CTRL-W CTRL-P and CTRL-W p, jump to previous window. (2.4)
  218. X
  219. XAdded "zz", "zt" and "zb", same as "z.", "zCR" and "z-" but without moving the
  220. Xcursor to the start of the line. (2.4)
  221. X
  222. X":bdelete" and ":bunload" accept a range of buffers and a list of buffer
  223. Xnumbers. (2.7)
  224. X
  225. X
  226. XImprovements
  227. X============
  228. X
  229. XCursor up/down in insert mode keep the same column. Also for "CTRL-O j" and
  230. Xthe like.
  231. X
  232. XAdded column number to :file.
  233. X
  234. XImproved listing of ":set" command. The columns are now sorted top to bottom.
  235. XLong string options are listed at the end (idea comes from nvi).
  236. X
  237. XRenamed directory "macros" to "tools". Moved doc/vim132 to tools/vim132.
  238. X
  239. X"ref" program added for "K" command (in the tools directory. Does simple
  240. Xspelling check.
  241. X
  242. XVim arguments "-c command" and "+command" are now options that can be given
  243. Xanywhere on the command line before the file names. Makes it possible to do
  244. X"Vim "+set ic" -t FuncTion".
  245. X
  246. XImproved Usage message.
  247. X
  248. XAdded check for negative line numbers in colon commands.
  249. X
  250. XRemoved 'n' offset to search patterns. Avoiding pcmark set is now down with
  251. Xtag_busy flag.
  252. X
  253. XImproved error messages for file access.
  254. X
  255. X":args" does not call wait_return() when message is short.
  256. X
  257. XWhen doing :paste twice the option values are saved only once.
  258. X
  259. XAccept '\n' to separate Ex commands, just like '|'.
  260. X
  261. XWith search also accept 'b' for begin, like 's' for start.
  262. XWhen 'e' used the operator is inclusive. 
  263. X
  264. XVisual shift accepts a count for number of indents.
  265. X
  266. XNo "hit return to continue" while filtering and only once when reading/writing
  267. Xfiles.
  268. X
  269. XFor Amiga and MSDOS lines longer than 32000 characters are split when reading.
  270. XUsed to give problems (out of memory errors).
  271. X
  272. XWhen ':' entered after "hit return to continue" don't redraw the screen.
  273. X
  274. XIn regexp: made '$' in front of '\|' also end-of-line.
  275. X
  276. XAdded "+command" argument to ":next", ":prev", ":rewind" and ":Next".
  277. X
  278. XGive better error message when "/" did not found pattern and 'wrapscan' off.
  279. X
  280. XAdded message "search hit BOTTOM, continuing at TOP" when search wraps. Don't
  281. Xdisplay this message when 'terse' option is on.
  282. X
  283. XMade ":&" work like ":s//~/".
  284. X
  285. XConsider mapped characters for terminal codes, makes "map <key-code1>
  286. X<key-code2>" work.
  287. X
  288. XRemember two search patterns: One for substitute and one for the rest. This is
  289. Xhow vi works. ":global" command sets both patterns.
  290. X
  291. XError messages during global command are listed below each other. (2.4)
  292. X
  293. XDon't redisplay the "INSERT" message when getting out of insert mode.
  294. X
  295. XWith escape in insert mode and auto-indent the cursor is put in the correct
  296. Xcolumn right away instead of after one second.
  297. X
  298. XAdded "Permission denied" message to readfile().
  299. X
  300. XAdded preserve command. Writes all text into the swap file.
  301. X
  302. XNamed marks are saved for undo, restored for redo.
  303. X
  304. XReduced terminal I/O by using screen_char() instead of outchar() for messages.
  305. X
  306. XAdded count to quickfix commands :cn and :cp. :cl and :cf can be interrupted
  307. Xby CTRL-C.
  308. X
  309. XFor MSDOS ignore CTRL-Z at end of file in textmode.
  310. X
  311. XNo mapping for CR when waiting for "hit return to continue".
  312. X
  313. XUse 'ignorecase' option when searching for tag in tag file.
  314. X
  315. XWhen count given for undo or redo, redraw screen only once.
  316. X
  317. XClear message on command line when scrolling, otherwise it will stay there
  318. Xuntil the screen is cleared. (2.5)
  319. X
  320. XMarks are remembered for buffers that are unloaded. (2.5)
  321. X
  322. XImplemented scroll regions, using "CS" termcap entry. Also works for pc
  323. Xconsole. Does not work for Amiga. (2.5)
  324. X
  325. XMade searches starting with "\<" quite a bit faster, by using regmust in
  326. Xregexp.c. (2.5)
  327. X
  328. XDon't output an extra line when reading a file and screen has been scrolled up
  329. X(e.g. after CTRL-D). (2.5)
  330. X
  331. XAfter "dG" "''" still works (when previous context mark is deleted, use
  332. Xprevious one). (2.5)
  333. X
  334. XA count can be given after an ex command for all commands that do not use a
  335. Xline number or range, e.g. ":sleep 2" is the same as :2sleep". Do not accept a
  336. Xcount where a file name is expected, because file names can be numbers. For
  337. Xexample ":next 4". (2.5)
  338. X
  339. X"~/" is expanded to $HOME, wherever an environment variable is allowed. (2.5)
  340. X
  341. XWhen the start of a filename matches $HOME, it is replaced with "~/" for the
  342. Xwindow title, status line, message from ":read", ":write", CTRL-G, ":file",
  343. X":marks" and ":jumps". Also for string options shown with ":set" that can be a
  344. Xfile name. (2.5)
  345. X
  346. XPrevious context mark for each window instead of for each buffer. (Webb 2.5)
  347. X
  348. XSet previous context mark only if line number changed. (Webb 2.5)
  349. X
  350. XMade tagstack local to each window. (Webb 2.5)
  351. X
  352. XIn the status line of a modified buffer "[+]" is shown. (Webb 2.5)
  353. X
  354. XRemember cursor position in tag stack for :tag command without argument. (Webb
  355. X2.5)
  356. X
  357. XWhen backwards range given for ":" command, ask for confirmation to swap it
  358. Xand continue. (Webb 2.5)
  359. X
  360. XAfter CTRL-T set curswant, so we stay in that column when moving up/down.
  361. X(Webb 2.5)
  362. X
  363. XWith :s/../../c show ruler when waiting for reply. (Webb 2.5)
  364. X
  365. XGive file name message for commands ":bnext", ":bmod" and the like. (2.5)
  366. X
  367. XMade index in argument list local to each window. (2.5)
  368. X
  369. XShow visual selection only in current window. (2.5)
  370. X
  371. XWhen a window is split, redraw both windows with cursor in middle. (2.4)
  372. X
  373. XIncluded code to save the xterm title. Need to define USE_X11, because
  374. Xspecific include file and library are needed. (2.4)
  375. X
  376. XMade "search hit BOT.." messages redisplay after screen redraw. (2.4)
  377. X
  378. XDon't do textwidth formatting when in replace mode and replacing an existing
  379. Xcharacter. (2.4)
  380. X
  381. XPrint message about the file when starting to edit an existing buffer. Fixes
  382. Xnot giving a message when doing ":n" to file being edited in other window.
  383. X(2.4)
  384. X
  385. XWhen lines are deleted/inserted, adjust topline and cursor position of other
  386. Xwindows on same buffer to stay in the same place (if possible). (2.4)
  387. X
  388. XIf CTRL-W CTRL-] is done on a tag that does not exist, the window is not
  389. Xsplit. (2.4)
  390. X
  391. XMoved column number in CTRL-G to the end and adjusted the number. (2.4)
  392. X
  393. XAdded "-- more --" message to listing of mappings. (2.4)
  394. X
  395. XAccept 'q' with "-- more --" message. Interrupts current listing. (2.4)
  396. X
  397. XWhen end of Visual area is on an empty line, minlc is FALSE, makes
  398. X"d}P" and "v}dP" do the same. (2.4)
  399. X
  400. XWhen the commands '*' and '#' do not find an identifier after the cursor, a
  401. Xsearch is done for a non-identifier string. (2.5)
  402. X
  403. XMade the ":buffers" listing nicer by putting the "line" string in column 40.
  404. X(2.7)
  405. X
  406. XUpdated error messages for keyword completion. (2.8)
  407. X
  408. XIf 'winheight' set spread extra lines over other windows. (2.8)
  409. X
  410. XWhen 'updatecount' changed from zero to non-zero, create swap file for all
  411. Xloaded buffers. (2.8)
  412. X
  413. XWhen command line completion found more than one match, beep. (3.0)
  414. X
  415. XChanged "still more files to edit" into "6 more files to edit". (2.9)
  416. X
  417. XWhen :bdel is used with a range and errors occur, still delete the other
  418. Xbuffers. (3.0)
  419. X
  420. XAdded version string to .swp file. (3.0)
  421. X
  422. XIn MSDOS version: After calling a shell, check screen size. Now it is possible
  423. Xto set the screen size with a command like ":!setmode xxx". (3.0)
  424. X
  425. XDon't try to open an X11 display if WINDOWID is not set, makes startup a bit
  426. Xquicker sometimes. (3.0)
  427. X
  428. X
  429. XNew and changed options
  430. X=======================
  431. X
  432. XDefault 'updatetime' is 10000, 10sec. Default 'updatecount' is 1000. This
  433. Xfeels more comfortable. But if you keep on typing, more will be lost when
  434. Xcrashing.
  435. X
  436. XChanged default for 'updatecount' to 200 (1000 was too much). Default for
  437. X'updatetime' is now four seconds (more than three seconds means that your
  438. Xattention is drawn away). (2.7)
  439. X
  440. XAdded 'cmdheight' option ('ch'), number of lines for command line. Set it to 2
  441. Xor 3 if you are annoyed by "hit return to continue" questions for long
  442. Xmessages.
  443. X
  444. XAdded 'winheight' option ('wh'), number of lines for active window. Set it to
  445. X999 to make the current window always fill the screen.
  446. X
  447. XMade 'winheight' option a "minimal window height" option, only set height if
  448. Xcurrent height is smaller. (2.4)
  449. X
  450. XAdded 'laststatus' option ('ls'). When set to 2 last window always has a
  451. Xstatus line. When set to 1 (which is the default) the last window only has a
  452. Xstatus line if there are two or more windows. When set to 0 there is never a
  453. Xstatus line. The screen looks nicer with a status line if you have several
  454. Xwindows, but takes another screen line.
  455. X
  456. XAdded optional '>' to 'directory' and 'backupdir' option, e.g. ">/tmp". When
  457. Xused, 'directory' option is always used for swap file. When not used
  458. X'directory' is only used when swap file cannot be created in current
  459. Xdirectory. The default is that the swap file will be in the current directory
  460. Xwhen possible, in 'directory' otherwise. 'directory' defaults to "/tmp" for
  461. Xunix, "t:" for Amiga and "c:\tmp" for MSDOS. The 'backupdir' option works in
  462. Xthe same way, but is currently only available for Unix.
  463. X
  464. XAdded 'nobuf' option ('nb'). When set one character is send to the terminal
  465. Xat a time (does not work for MSDOS). For debugging purposes.
  466. X
  467. XAdded 'shellpipe' option ('sp'). String to use for the make command to store
  468. Xthe error messages. For Amiga and MSDOS it defaults to ">". For Unix it
  469. Xdefaults to "| tee". For "csh", "tcsh" and "zsh" it is changed into "|& tee".
  470. XFor "sh", "ksh" and "bash" it is changed into "2>&1| tee". Fixes problem with
  471. X:make when not using csh. 
  472. X
  473. XAdded 'maxmem' option ('mm'), maximal Kbyte to use for one buffer.
  474. X
  475. XAdded 'smarttab' option ('sta'). When set a TAB in front of a line inserts
  476. X'shiftwidth' positions, 'tabstop' in other places. When not set a TAB always
  477. Xinserts 'tabstop' positions, 'shiftwidth' is only used for ">>" and the like.
  478. X
  479. XAdded 'maxmemtot' option ('mmt'), maximal Kbyte to use for all buffers.
  480. X
  481. XAdded 'ttyfast' option ('tf'). When set the terminal is assumed to be fast,
  482. Xscrolling windows is done by redrawing. When not set windows are scrolled with
  483. Xinsert/delete line commands, causing the windows below it to jump up and down
  484. Xif threre is no support for a scrolling region.
  485. X
  486. XAdded 'equalalways' option: When windows split or closed, always do CTRL-W =.
  487. X(2.5)
  488. X
  489. XAdded 'splitbelow': When set new window from split is below current one. (2.5)
  490. X
  491. XAdded 'tagrelative' option (default ON!). When using tag file in other
  492. Xdirectory, file names are relative to the directory where the tag file is.
  493. X(Webb 2.5)
  494. X
  495. XWhen setting 'winheight' adjust current window straight away. Check for
  496. Xnegative value. (Webb 2.5)
  497. X
  498. XAdded 'gdefault' option: make /g default for :s command (default off). (2.4)
  499. X
  500. XAdded 'title' option (default on). When off, window title is not set. (2.4)
  501. X
  502. XAdded NOTITLE compile time option for Vera: When defined the title option is
  503. Xdefault off. (2.7)
  504. X
  505. XAdded 'icon' option (default off): when set xterm icon is set to file name.
  506. X(2.4)
  507. X
  508. XAdded 'invertweird' option, for terminals that have a weird inversion method.
  509. XMakes the start/end invert code outputted before every character. (2.4)
  510. X
  511. XChanged 'invertweird' to 'weirdinvert', because an option starting with 'inv'
  512. Xis illegal. ":set invertweird" gives an error message. (2.7)
  513. X
  514. XAdded 'endofline' 'eol' option. If not set and in binary mode, last line will
  515. Xnot get an end of line when writing. (2.4)
  516. X
  517. XAdded 'bswrap' option: Backspace (CTRL-H) and space wrap to previous/next line
  518. Xin command mode. Default is ON! Should have been added long ago! (2.4)
  519. X
  520. XWhen 'bswrap' option set, left/right cursor keys in insert mode also wrap to
  521. Xprevious/next line. (2.7)
  522. X
  523. XChanged toggle 'bswrap' option to number 'whichwrap' option: Add numbers to
  524. Xallow specific keys to wrap to next/previous line: 1 for backspace, 2 for
  525. Xspace, 4 for 'h' and 'l', 8 for cursor left/right, 16 for cursor left/right in
  526. Xinsert mode. (2.7)
  527. X
  528. XAdded 'patchmode' option. Oldest version of a file is kept. (2.4)
  529. X
  530. XAdded 't_csc' termcap option: when set (to anything) the cursor positioning is
  531. Xdone relative to the start of the scrolling region. Otherwise it is relative
  532. Xto the start of the screen. Unfortunately there is no termcap entry for this.
  533. XWe are just guessing its value. Currently only MSDOS pcterm is know to need
  534. Xthis set. This fixes doing 'o' not getting the new line in the right place for
  535. XMSDOS. (2.7)
  536. X
  537. XAdded 'highlight' ('hl') option: Can set highlighting mode for various
  538. Xoccasions. 'i' for invert, 'b' for bold, 's' for standout; 'v' = visual mode,
  539. X'd' = directories in CTRL-D listing, 'e' = error messages, 's' = status lines,
  540. X'h' = help file headers, 'r' = return to continue message. They have to be
  541. Xgiven in pairs, separated with a comma. For example:
  542. X":set hl=ds,vb,ei,si,hb,ri". Invert is used for occasions that are not
  543. Xincluded. Default is "ds,es,hs,rs,vi,si". (2.6)
  544. X
  545. XChanged the default highlight mode for directories to bold. (2.7)
  546. X
  547. XAdded 'n' to 'highlight' option: no highlighting. (2.7)
  548. X
  549. XAdded 'bold' termcap option as t_tb. (2.6)
  550. X
  551. X
  552. XVi compatibility fixes
  553. X======================
  554. X
  555. X":>", ":<" and ":yank" leave cursor on the last line.
  556. X
  557. XAbbreviations recognized like vi, fixes abbreviation of "#i" to "#include".
  558. X
  559. X"d]]" also stops at '{'.
  560. X
  561. X']' and '[' are not linewise.
  562. X
  563. X"z." and "z-" move cursor to start of line. "zz" does the same as "z.".
  564. X
  565. X":>>" shifts two indents, ":>>>" three, etc.
  566. X
  567. XWhen no file name yet and giving a ":read fname" command, use that file name.
  568. X(2.4) When no file name yet and giving a ":write fname" command, use that file
  569. Xname. (2.5)
  570. X
  571. X":3,3join" does nothing, fixes "g/^$/.,/./-j" to delete only multiple empty
  572. Xlines. (2.5)
  573. X
  574. X":wnext" does not go to next file in argument list if write fails. (2.5)
  575. X
  576. XCTRL-W CURSOR-UP and CTRL-W CURSOR-DOWN do the same as CTRL-W k and CTRL-W j.
  577. X(2.5)
  578. X
  579. X'smartindent' is improved: When '}' is typed as the first char on a line,
  580. Xit is moved to line up with the line containing the matching '{' (rather than
  581. Xjust moving back one shift-width no matter what).  If '#' is the first
  582. Xcharacter typed on a line, then the line is moved all the way to the left.
  583. X(Webb 2.5)
  584. X
  585. XWhen 'smartindent' set, '#' removes all indent. Now the existing indent is
  586. Xremembered for the next line (like with ^ CTRL-D). (2.7)
  587. X
  588. XWhen ESC is used to cancel a command, don't beep. (Webb 2.5)
  589. X
  590. XWhen 'autoindent' set and inserting a CR, delete white space after the cursor.
  591. X(Webb 2.5)
  592. X
  593. XDon't set curswant when 'h' or 'l' fails. (Webb 2.5)
  594. X
  595. XWith "70|" command set curswant to 70, also when line is shorter. (Webb 2.5)
  596. X
  597. XFixed "cc" to delete the text linewise, but keep the indent when 'ai' is set.
  598. X(2.5)
  599. X
  600. X"dTx" and "dFx" do not include cursor position.
  601. X
  602. X":r" without a file name specified reads current file.
  603. X
  604. X"ce" when on the end of a word changes until the end of the next word
  605. X(but "cw" not).
  606. X
  607. XAfter "dd" put cursor on first non-blank in line.
  608. X
  609. XAbbreviations are never recursive, makes ":ab f f-o" work.
  610. X
  611. X'#' is not the start of an ex comment but an abbreviation for ":number".
  612. X
  613. XPut redo for "p" and "P" back in. It is not completely compatible, because vi
  614. Xdoesn't always redo putting less then a line (but that is considered to be a
  615. Xbug in vi). (2.5)
  616. X
  617. XAdjusted comp_col() for when 'laststatus' is set. Reduces need for "hit return
  618. Xto continue". (2.5)
  619. X
  620. XWith ":global" command, don't display "n more lines" messages until the end.
  621. X(2.5)
  622. X
  623. XDon't reset yank buffer with "." command. Makes dwu"a. work. (2.4)
  624. X
  625. XDon't check for abbreviation when a (non-id) character is entered with CTRL-V.
  626. X(2.4)
  627. X
  628. XWith change command put deleted text in "1, even with text within one line.
  629. X(2.4)
  630. X
  631. XWhen deleting and a register is specified, also yank into buffer "1. (2.4)
  632. X
  633. X":3|" prints line 3 instead of jumping to it. (2.4)
  634. X
  635. XSeparated 'wrapmargin' and 'textwidth'. Both can be used, if textwidth is set
  636. Xit overrides 'wrapmargin'. (2.8)
  637. X
  638. X
  639. XBug fixes
  640. X=========
  641. X
  642. XFixed problem in memmove for __sgi.
  643. X
  644. XFixed ":cd" not working for unix.
  645. X
  646. XMade incrementing hex numbers with CTRL-A work on systems that don't accept 0x
  647. Xin scanf for "%x".
  648. X
  649. XReset p_ro in readfile() when starting to edit a new file.
  650. X
  651. Xinchar() also calls flushbuf when waiting for a second, fixes screen not
  652. Xupdated while waiting for a mapping to be completed.
  653. X
  654. XFixed ":/pat/s/x/X/"; 's' was seen as option to search command.
  655. X
  656. XFixed search patterns where delimiter is inside of a range, e.g. "/[/]".
  657. X
  658. XFixed ignoring 'ignorecase' option for "/[a-z]". Fixed mixing upper/lower case
  659. Xwhen 'ignorecase' option not set (just slowed down the searching).
  660. X
  661. XUse iswhite() instead of isspace() for "^" and set_indent().
  662. X
  663. XAllow pipe in ":r !cmd" and ":w !cmd".
  664. XAdjusted check for '|' in ":e +cmd".
  665. X
  666. XFixed insertchar() lookahead for digraph not working when using mapped
  667. Xcharacters.
  668. X
  669. XFixed :unab and :unmap for rhs with spaces.
  670. X
  671. XFixed not accepting ambiguous abbreviations.
  672. X
  673. XAdded check for valid abbreviations.
  674. X
  675. XFixed crash for AmigaDOS 1.3 when giving more than one file on the command
  676. Xline.
  677. X
  678. XUpdated isidchar for meta chars.
  679. X
  680. XAdded setting of Changed flag to :move and :copy.
  681. X
  682. XNumber after search pattern (e.g. "/pattern/3") is line offset.
  683. X
  684. X"cc<ESC>" when 'ai' is set, deletes the indent.
  685. X
  686. XFixed ":s/1/1^M/gc" on "111" and ":s/O/oO/gc" looping.
  687. X
  688. XFixed trailing "\" in substitute string (produced garbage).
  689. X
  690. XFixed yanking control characters (like "^B") with block visual mode.
  691. X
  692. XFixed cursor left of line with "i<ESC>" when 'number' set.
  693. X
  694. XMSDOS: isdir() adjusted for trailing backslash, fixes CTRL-D listing.
  695. X
  696. XMSDOS: Fixed call to lalloc() in addfile() in msdos.c, could only do 32 files.
  697. X
  698. XMSDOS: Fixed setting archive bit in setperm() in msdos.c.
  699. X
  700. XMSDOS: Do not eat backslashes in ":next" command.
  701. X
  702. XFixed bug in makescriptname: alloc 1 byte extra.
  703. X
  704. XFixed bug in doaddsub(): Line truncated 30 chars after number.
  705. X
  706. XFixed CTRL-O in insert mode moving cursor when it is after end of line.
  707. X
  708. XVertical movement in insert mode can put cursor one char after the line.
  709. X
  710. XFixed not inverting 0xa0 in visual mode when scrolling. This caused gaps in
  711. Xthe inverted region.
  712. X
  713. XFixed hangup for "?$" command.
  714. X
  715. XFixed keyword macros: ^B must be ^R.
  716. X
  717. X":set all" and ":set termcap" do not look for other arguments.
  718. X
  719. X{count}% puts cursor on first non-blank.
  720. X
  721. XWhen ":ta" to tag in same file, start search in line 1. Fixes problem when
  722. X'wrapscan' is not set.
  723. X
  724. XFixed setting of pcmark for "(" and ")".
  725. X
  726. XFixed setting pcmark with :e command.
  727. X
  728. XFixed a crash on Unix when terminal type unknown. (2.5)
  729. X
  730. XFixed 'showmatch', the cursor was off. (2.5)
  731. X
  732. XSolved crash when 'lines' was set in .exrc. (2.5)
  733. X
  734. XFixed memory leak for mf_xfname. (2.5)
  735. X
  736. XFixed a problem in the Unix part for making backup files. Strange that this
  737. Xdid not cause the compiler to complain. (2.5)
  738. X
  739. XFilename expansion is now done into NameBuff instead of IObuff. Fixes bugs
  740. Xwhere file name was scrambled or Vim crashed some time after ":next file".
  741. X(2.5)
  742. X
  743. XFixed deleting the file message when 't_tp' was set in .vimrc. (2.5)
  744. X
  745. XFixed cursor positioning problem when :s/../../gc made line go past end of
  746. Xscreen. (Webb 2.5)
  747. X
  748. XDon't nag about swap file not existing when preserving, except for
  749. X":preserve". (2.5)
  750. X
  751. XFixed loosing changes without warning when 'hidden' option set and re-editing
  752. Xthe same file with a command like ":rewind". (2.5)
  753. X
  754. XClear commandline with ":buffers" command. (2.5)
  755. X
  756. XFixed ":1buf" to go to first buffer instead of second one. (2.5)
  757. X
  758. XFixed default for ":sleep" to be 1 instead of current line number. (2.5)
  759. X
  760. XWhen the 'hidden' option is set don't give error message for changed file on
  761. Xseveral commands (:ta). (2.5)
  762. X
  763. XUpdate timestamp in swap file when the file has been written. (2.5)
  764. X
  765. XFixed a problem not updating the time stamp in the swap file when writing
  766. Xanother but the current buffer. (2.7)
  767. X
  768. XFixed bug: not-edited file could be written with ":w". (2.5)
  769. X
  770. XFixed invering Visual part when 'nowrap' set and start is left of window.
  771. X(2.4)
  772. X
  773. XFixed problem with join: Deleted leading spaces in the 2nd line when it
  774. Xshouldn't. (2.4)
  775. X
  776. XMSDOS: Trailing CTRL-V in sourced ex file now handled correctly. (2.4)
  777. X
  778. XImproved check for readonly files, now "466" is not readonly for others. (2.4)
  779. X
  780. XFixed not inverting one char with "1v" when cursor cannot be made invisible.
  781. X(2.4)
  782. X
  783. XStop Visual mode before exiting a window. (2.4)
  784. X
  785. XChanged "short_u" to "unsigned" in data block. Fixes problem with lines longer
  786. Xthan 64K characters on Unix. Disadvantage: Need 2 bytes extra for each line.
  787. X(2.4)
  788. X
  789. XFixed plines_win() and chartabsize() for lines that are almost 32768
  790. Xcharacters. (2.4)
  791. X
  792. XReplace MAX_INT by INT_MAX, fixes problem with "$" not getting very far. (2.4)
  793. X
  794. XStatus lines also redrawn after ":set". Needed when 'ruler' option was
  795. Xchanged. (2.4)
  796. X
  797. XFixed fname freed twice in mf_open(). Fixes crash/hang when editing a file in
  798. Xa readonly directory. (2.4)
  799. X
  800. XUpdate mf_neg_count in mf_free, fixes "line count wrong in block 1" errors.
  801. X(2.4)
  802. X
  803. XFixed bug when in replace mode and beyond the end of the line. (2.4)
  804. X
  805. XFixed a problem for 'r' with a count. Could corrupt the text in the buffer!
  806. X(2.4)
  807. X
  808. XScroll options adjusted after CTRL-W =. (2.4)
  809. X
  810. XIf a tag is found, but the associated file does not exist, do not start
  811. Xediting an empty file. (2.4)
  812. X
  813. Xsc_col and ru_col cannot become negative anymore, fixes crash with ":win 1".
  814. X(2.4)
  815. X
  816. XCheck_winsize makes Rows at least 2. (2.4)
  817. X
  818. X'o' and 'O' commands did not update marks for the line just below the new
  819. Xline. (2.4)
  820. X
  821. XFixed truncated displaying of string options. (2.4)
  822. X
  823. XFixed chmod for help file in makefile.unix. (2.4)
  824. X
  825. XHighlighting of directories for CTRL-D on command line no longer highlights
  826. Xsome spaces. (2.4)
  827. X
  828. XMoved #endif in param.c from below to above p_wh, fixes problem when
  829. XCOMPATIBLE is defined. (2.4)
  830. X
  831. XDon't reset msg_scrolled in UpdateScreen() when redrawing is disabled. (2.4)
  832. X
  833. XFixed cursor positioning error when cursor is on first char of non-empty
  834. Xcmdline. (2.4)
  835. X
  836. XFixed problem with redraw when filename completion fails under unix. (2.4)
  837. X
  838. XNo "hit return to continue" while editing a command line
  839. X(e.g. when filename completion fails). (2.4)
  840. X
  841. XFixed bug: Errors while reading file caused big problems. (2.4)
  842. X
  843. XDon't try to preserve if there is no swap file. (2.4)
  844. X
  845. XDont' complain about .swp file existing without a file name. (2.4)
  846. X
  847. XFixed endless loop for CTRL-R a in insert mode while register a contained
  848. XCTRL-R a. Can now be interrupted with CTRL-C. (2.6)
  849. X
  850. XFixed ":n *" in MSDOS not finding file names with dot. (2.7)
  851. X
  852. XFixed cursor not moved to the right column when scrolling with CTRL-E and
  853. XCTRL-Y. (2.7)
  854. X
  855. XFixed bug when using CTRL-A to increment a decimal number after incrementing
  856. Xan upper case hexadecimal number. (2.7)
  857. X
  858. XOnly reset the 'notedited' flag when writing to the current file name, not
  859. Xwhen writing to another file. (2.7)
  860. X
  861. XFixed screen redraw when window resized, was sometimes done only after
  862. Xcharacter typed. (2.7)
  863. X
  864. XCorrected the order of the options to be alfabetical. (2.7)
  865. X
  866. XFixed using CTRL-D on the command line when there are no matches at all. (2.7)
  867. X
  868. XFixed beeping always when doing CTRL-A on command line. (2.7)
  869. X
  870. XFixed the line number for the alternate file being used for the next command.
  871. Xe.g. ":w #", ":e file" when # is file. (2.7)
  872. X
  873. XMoved the fileinfo() in doecmd() to after the place where the cursor is set.
  874. XFixes reporting the wrong cursor position when entering a hidden buffer. (2.7)
  875. X
  876. XFixed compilation problem in unix.c when compiling without WEBB_COMPLETE.
  877. X(2.7)
  878. X
  879. XWhen going to previous line with backspace, set curswant. (2.7)
  880. X
  881. XFixed status line showing "[No File] [+] [+]": two plusses. (2.7)
  882. X
  883. XThe 'changed' flag was not reset for other buffers with :wall. (2.7)
  884. X
  885. XSolved bug in 'r': The change was not written to the swap file, which made the
  886. Xchange to be lost sometimes. (2.6)
  887. X
  888. XDon't ask for swapping the command line range when in global command. (2.6)
  889. X
  890. XFixed :bdelete, it did't work. :bdelete and :bunload cannot remove a buffer
  891. Xwith an open window, unless it is only the current window. (2.6)
  892. X
  893. XFixed .swp files not deleted when starting to edit a file when the current
  894. Xbuffer is empty and has no name. This also fixes the problem which happens
  895. Xwhen starting vim without a file name and the starting to edit a file that
  896. Xdoes not exist. (2.6)
  897. X
  898. XWhen error encountered while loading files for "-o" option or ":all", continue
  899. Xloading the other files. (2.8)
  900. X
  901. XIf cursor is in column 0, always reset horizontal scrolling. Makes tabs
  902. Xcompletely visible. (2.8)
  903. X
  904. XFixed problem in mf_release_all, empty used list not detected properly. (2.8)
  905. X
  906. XFixed crash with command ":@:", repeat last command line. (2.8)
  907. X
  908. XFixed cursor in wrong column when matched string from search was just one line
  909. Xbelow the window. (2.8)
  910. X
  911. X":m+1" on the last line in the file silently deleted that line. (3.0)
  912. X
  913. XFixed command line completion of ":s<TAB>". (3.0)
  914. X
  915. XThe ":srewind" command did not work. (3.0)
  916. X
  917. XThe ":k" command did not work. (3.0)
  918. X
  919. XWhen making windows for ":all" or "-o" argument, ignore 'splitbelow' option.
  920. X(3.0)
  921. X
  922. XFixed a problem when recovering with a swap file that has a page size
  923. Xdifferent from the default page size. (3.0)
  924. X
  925. XThe ":bdelete" command did not delete the last buffer. (3.0)
  926. X
  927. XWhen using a range with ":bdelete" that included the current buffer, all the
  928. Xbuffers after it would get loaded before being deleted (3.0)
  929. X
  930. XFixed <SPACE>, wrapping to first char of next line, not setting the wanted
  931. Xcolumn, causing the next 'k' to go to the wrong column. Same for <BACKSPACE>
  932. Xon the first column, sticking in the last column. (3.0)
  933. X
  934. X
  935. XInternals
  936. X=========
  937. X
  938. XRenamed u_char to char_u, u_short to short_u. Avoids problems with systems
  939. Xwhere these are already defined.
  940. X
  941. XReplaced almost all char by char_u, solves some problems with characters above
  942. X127.
  943. X
  944. XRemoved ptr2nr(). This means that line numbers are adjusted when
  945. Xinserting/deleting lines. Marks remember line number instead of pointer; undo
  946. Xuses line count to compute ue_bot.
  947. X
  948. XMoved all objects files into "obj" directory.
  949. X
  950. XAdded "window.c" for multiple window code.
  951. X
  952. XAdded "memfile.c" and "memline.c" for swap file code.
  953. X
  954. XMoved what was remaining of "storage.c" to "undo.c", deleted "storage.c".
  955. X
  956. XDeleted autoscript file stuff.
  957. X
  958. XRenamed "buffers.c" to "getchar.c".
  959. X
  960. XCreated "buffer.c". Deleted "script.c".
  961. X
  962. XMoved a few functions from "cmdline.c" to "cmdcmds.c" to reduce the size of
  963. X"cmdline.c".
  964. X
  965. XIntegrated file list into buffer list. ":buffers" and ":files" do the same.
  966. XMoved functions from "filelist.c" to "buffer.c", deleted "filelist.c". (2.5)
  967. X
  968. XRemove mch_start_listing() and mch_stop_listing(), replaced by "--more--".
  969. X(2.5)
  970. X
  971. X
  972. XPortability
  973. X===========
  974. X
  975. XA few patches, the file "winnt.c" and "makefile.nt" for windows NT. (2.4)
  976. X
  977. XAdded support for Archimedes. It probably doesn't work, because "archie.h" was
  978. Xmissing, and the patches are for Vim version 2.0. Included them anyway, so
  979. Xpeople can make patches to make it working. (2.9)
  980. X
  981. XAdded a few changes for USL in unix.c.
  982. X
  983. XMade makefile for unix more easy to change for a specific system.
  984. X
  985. XIncluded small patches for gcc on HPUX 9. (2.4)
  986. X
  987. XSet the SIGWINCH signal, when receiving that signal, for all systems. (Webb
  988. X2.5)
  989. X
  990. XChanged Visual into VIsual, because it is also used by X11. (2.4)
  991. X
  992. XAdded some changes for USL and picky gcc. (2.4)
  993. X
  994. XIncluded patches for SCO 3.2. (2.4)
  995. X
  996. XRemoved the use of the 'obj' directory from makefile.unix. Some versions of
  997. Xmake and cc were having problems with it. (2.7)
  998. END_OF_FILE
  999.   if test 34259 -ne `wc -c <'vim/readme3.0'`; then
  1000.     echo shar: \"'vim/readme3.0'\" unpacked with wrong size!
  1001.   fi
  1002.   # end of 'vim/readme3.0'
  1003. fi
  1004. if test -f 'vim/src/winnt.c' -a "${1}" != "-c" ; then 
  1005.   echo shar: Will not clobber existing file \"'vim/src/winnt.c'\"
  1006. else
  1007.   echo shar: Extracting \"'vim/src/winnt.c'\" \(31469 characters\)
  1008.   sed "s/^X//" >'vim/src/winnt.c' <<'END_OF_FILE'
  1009. X/* vi:ts=4:sw=4
  1010. X *
  1011. X * VIM - Vi IMproved
  1012. X *
  1013. X */
  1014. X
  1015. X/*
  1016. X * winnt.c
  1017. X *
  1018. X * Windows NT system-dependent routines.
  1019. X * A reasonable approximation of the amiga dependent code.
  1020. X * Portions lifted from SDK samples, from the MSDOS dependent code,
  1021. X * and from NetHack 3.1.3.
  1022. X *
  1023. X * rogerk@wonderware.com
  1024. X */
  1025. X
  1026. X#include <io.h>
  1027. X#include "vim.h"
  1028. X#include "globals.h"
  1029. X#include "param.h"
  1030. X#include "proto.h"
  1031. X#include <fcntl.h>
  1032. X#include <sys/types.h>
  1033. X#include <sys/stat.h>
  1034. X#include <errno.h>
  1035. X#include <stdlib.h>
  1036. X#include <windows.h>
  1037. X#include <wincon.h>
  1038. X
  1039. Xstatic int WaitForChar __ARGS((int));
  1040. Xstatic int cbrk_handler __ARGS(());
  1041. X
  1042. X/* Win32 Console handles for input and output */
  1043. XHANDLE          hConIn;
  1044. XHANDLE          hConOut;
  1045. X
  1046. X/* Win32 Screen buffer,coordinate,console I/O information */
  1047. XCONSOLE_SCREEN_BUFFER_INFO csbi;
  1048. XCOORD           ntcoord;
  1049. XINPUT_RECORD    ir;
  1050. X
  1051. X/* The attribute of the screen when the editor was started */
  1052. XWORD            DefaultAttribute;
  1053. X
  1054. Xtypedef struct filelist {
  1055. X    char          **file;
  1056. X    int             nfiles;
  1057. X    int             maxfiles;
  1058. X}               FileList;
  1059. X
  1060. Xstatic void addfile __ARGS((FileList *, char *, int));
  1061. Xstatic int      pstrcmp();      /* __ARGS((char **, char **)); BCC does not
  1062. X                                 * like this */
  1063. Xstatic void strlowcpy __ARGS((char *, char *));
  1064. Xstatic int expandpath __ARGS((FileList *, char *, int, int, int));
  1065. X
  1066. Xstatic int      cbrk_pressed = FALSE;   /* set by ctrl-break interrupt */
  1067. Xstatic int      ctrlc_pressed = FALSE;  /* set when ctrl-C or ctrl-break
  1068. X                                         * detected */
  1069. X
  1070. Xvoid            vim_delay()
  1071. X{
  1072. X    delay(500);
  1073. X}
  1074. X
  1075. X/*
  1076. X * this version of remove is not scared by a readonly (backup) file
  1077. X */
  1078. Xint             vim_remove(name)
  1079. X    char           *name;
  1080. X{
  1081. X    setperm(name, _S_IWRITE);   /* default permissions */
  1082. X    return unlink(name);
  1083. X}
  1084. X
  1085. X/*
  1086. X * mch_write(): write the output buffer to the screen
  1087. X */
  1088. Xvoid            mch_write(s, len)
  1089. X    char           *s;
  1090. X    int             len;
  1091. X{
  1092. X    char           *p;
  1093. X    int             row,
  1094. X                    col;
  1095. X
  1096. X    s[len] = '\0';
  1097. X    if (term_console)           /* translate ESC | sequences into bios calls */
  1098. X        while (len--) {
  1099. X
  1100. X            /* optimization: use one single WriteConsole for runs of text,
  1101. X               rather than calling putch() multiple times.  It ain't curses,
  1102. X               but it helps. */
  1103. X
  1104. X            DWORD           prefix = strcspn(s, "\n\r\a\033");
  1105. X
  1106. X            if (prefix) {
  1107. X                DWORD           nwritten;
  1108. X
  1109. X                if (WriteConsole(hConOut, s, prefix, &nwritten, 0)) {
  1110. X
  1111. X                    len -= (nwritten - 1);
  1112. X                    s += nwritten;
  1113. X                }
  1114. X                continue;
  1115. X            }
  1116. X
  1117. X            if (s[0] == '\n') {
  1118. X                if (ntcoord.Y == (Rows - 1)) {
  1119. X                    gotoxy(1, ntcoord.Y + 1);
  1120. X                    scroll();
  1121. X                } else {
  1122. X                    gotoxy(1, ntcoord.Y + 2);
  1123. X                }
  1124. X                s++;
  1125. X                continue;
  1126. X            } else if (s[0] == '\r') {
  1127. X                gotoxy(1, ntcoord.Y + 1);
  1128. X                s++;
  1129. X                continue;
  1130. X            } else if (s[0] == '\a') {
  1131. X                vbell();
  1132. X                s++;
  1133. X                continue;
  1134. X            } else if (s[0] == ESC && len > 1 && s[1] == '|') {
  1135. X                switch (s[2]) {
  1136. X
  1137. X                case 'v':
  1138. X                    cursor_visible(0);
  1139. X                    goto got3;
  1140. X
  1141. X                case 'V':
  1142. X                    cursor_visible(1);
  1143. X                    goto got3;
  1144. X
  1145. X                case 'J':
  1146. X                    clrscr();
  1147. X                    goto got3;
  1148. X
  1149. X                case 'K':
  1150. X                    clreol();
  1151. X                    goto got3;
  1152. X
  1153. X                case 'L':
  1154. X                    insline(1);
  1155. X                    goto got3;
  1156. X
  1157. X                case 'M':
  1158. X                    delline(1);
  1159. X            got3:   s += 3;
  1160. X                    len -= 2;
  1161. X                    continue;
  1162. X
  1163. X                case '0':
  1164. X                case '1':
  1165. X                case '2':
  1166. X                case '3':
  1167. X                case '4':
  1168. X                case '5':
  1169. X                case '6':
  1170. X                case '7':
  1171. X                case '8':
  1172. X                case '9':
  1173. X                    p = s + 2;
  1174. X                    row = getdigits(&p);        /* no check for length! */
  1175. X                    if (p > s + len)
  1176. X                        break;
  1177. X                    if (*p == ';') {
  1178. X                        ++p;
  1179. X                        col = getdigits(&p);    /* no check for length! */
  1180. X                        if (p > s + len)
  1181. X                            break;
  1182. X                        if (*p == 'H') {
  1183. X                            gotoxy(col, row);
  1184. X                            len -= p - s;
  1185. X                            s = p + 1;
  1186. X                            continue;
  1187. X                        }
  1188. X                    } else if (*p == 'm') {
  1189. X                        if (row == 0)
  1190. X                            normvideo();
  1191. X                        else
  1192. X                            textattr(row);
  1193. X                        len -= p - s;
  1194. X                        s = p + 1;
  1195. X                        continue;
  1196. X                    } else if (*p == 'L') {
  1197. X                        insline(row);
  1198. X                        len -= p - s;
  1199. X                        s = p + 1;
  1200. X                        continue;
  1201. X                    } else if (*p == 'M') {
  1202. X                        delline(row);
  1203. X                        len -= p - s;
  1204. X                        s = p + 1;
  1205. X                        continue;
  1206. X                    }
  1207. X                }
  1208. X            }
  1209. X            putch(*s++);
  1210. X        }
  1211. X    else
  1212. X        write(1, s, (unsigned) len);
  1213. X}
  1214. X/*
  1215. X *  Keyboard translation tables.
  1216. X *  (Adopted from the MSDOS port)
  1217. X */
  1218. X
  1219. X#define KEYPADLO    0x47
  1220. X#define KEYPADHI    0x53
  1221. X
  1222. X#define PADKEYS     (KEYPADHI - KEYPADLO + 1)
  1223. X#define iskeypad(x)    (KEYPADLO <= (x) && (x) <= KEYPADHI)
  1224. X
  1225. X/*
  1226. X * Wait until console input is available
  1227. X */
  1228. X
  1229. Xstatic int      WaitForChar(msec)
  1230. X    int             msec;
  1231. X{
  1232. X    int             count;
  1233. X    int             ch;
  1234. X    int             scan;
  1235. X    int             shiftstate;
  1236. X    int             altseq;
  1237. X    int             retval = 0;
  1238. X
  1239. X    if (WaitForSingleObject(hConIn, msec) == WAIT_OBJECT_0) {
  1240. X        count = 0;
  1241. X        PeekConsoleInput(hConIn, &ir, 1, &count);
  1242. X        if (count > 0) {
  1243. X            ch = ir.Event.KeyEvent.uChar.AsciiChar;
  1244. X            scan = ir.Event.KeyEvent.wVirtualScanCode;
  1245. X            shiftstate = ir.Event.KeyEvent.dwControlKeyState;
  1246. X            if (((ir.EventType == KEY_EVENT) && ir.Event.KeyEvent.bKeyDown) &&
  1247. X                (ch || (iskeypad(scan)))) {
  1248. X                retval = 1;     /* Found what we sought */
  1249. X            }
  1250. X        } else {                /* There are no events in console event queue */
  1251. X            retval = 0;
  1252. X        }
  1253. X    }
  1254. X    return retval;
  1255. X}
  1256. X
  1257. Xstatic int pending = 0;
  1258. X
  1259. Xint             tgetch()
  1260. X{
  1261. X    int             valid = 0;
  1262. X    int             metaflags = 0;
  1263. X    int             count;
  1264. X    unsigned short int scan;
  1265. X    unsigned char   ch;
  1266. X    unsigned long   shiftstate;
  1267. X    const struct pad *kpad;
  1268. X    char            keymess[100];
  1269. X
  1270. X    if (pending)
  1271. X    {
  1272. X        ch = pending;
  1273. X        pending = 0;
  1274. X    }
  1275. X    else
  1276. X    {
  1277. X
  1278. X        valid = 0;
  1279. X        while (!valid) {
  1280. X            ReadConsoleInput(hConIn, &ir, 1, &count);
  1281. X            if (ir.EventType == WINDOW_BUFFER_SIZE_EVENT) {
  1282. X                set_winsize(Rows, Columns, FALSE);
  1283. X            } 
  1284. X            else
  1285. X            {
  1286. X                if ((ir.EventType == KEY_EVENT) && ir.Event.KeyEvent.bKeyDown) 
  1287. X                {
  1288. X                    ch = ir.Event.KeyEvent.uChar.AsciiChar;
  1289. X                    scan = ir.Event.KeyEvent.wVirtualScanCode;
  1290. X                    if (ch || (iskeypad(scan)))
  1291. X                        valid = 1;
  1292. X                }
  1293. X            }
  1294. X        }
  1295. X        if (!ch)
  1296. X        {
  1297. X            pending = scan;
  1298. X            ch = 0;
  1299. X        }
  1300. X    }
  1301. X    return ch;
  1302. X}
  1303. X
  1304. X
  1305. Xint             kbhit()
  1306. X{
  1307. X    int             done = 0;   /* true =  "stop searching"        */
  1308. X    int             retval;     /* true =  "we had a match"        */
  1309. X    int             count;
  1310. X    unsigned short int scan;
  1311. X    unsigned char   ch;
  1312. X    unsigned long   shiftstate;
  1313. X
  1314. X    if (pending)
  1315. X        return 1;
  1316. X
  1317. X    done = 0;
  1318. X    retval = 0;
  1319. X    while (!done) {
  1320. X        count = 0;
  1321. X        PeekConsoleInput(hConIn, &ir, 1, &count);
  1322. X        if (count > 0) {
  1323. X            ch = ir.Event.KeyEvent.uChar.AsciiChar;
  1324. X            scan = ir.Event.KeyEvent.wVirtualScanCode;
  1325. X            shiftstate = ir.Event.KeyEvent.dwControlKeyState;
  1326. X            if (((ir.EventType == KEY_EVENT) && ir.Event.KeyEvent.bKeyDown) &&
  1327. X                (ch || (iskeypad(scan)) )) {
  1328. X                done = 1;       /* Stop looking         */
  1329. X                retval = 1;     /* Found what we sought */
  1330. X            } else              /* Discard it, its an insignificant event */
  1331. X                ReadConsoleInput(hConIn, &ir, 1, &count);
  1332. X        } else {                /* There are no events in console event queue */
  1333. X            done = 1;           /* Stop looking               */
  1334. X            retval = 0;
  1335. X        }
  1336. X    }
  1337. X    return retval;
  1338. X}
  1339. X
  1340. X
  1341. X/*
  1342. X * GetChars(): low level input funcion.
  1343. X * Get a characters from the keyboard.
  1344. X * If time == 0 do not wait for characters.
  1345. X * If time == n wait a short time for characters.
  1346. X * If time == -1 wait forever for characters.
  1347. X */
  1348. Xint             GetChars(buf, maxlen, time)
  1349. X    char           *buf;
  1350. X    int             maxlen;
  1351. X    int             time;
  1352. X{
  1353. X    int             len = 0;
  1354. X    int             c;
  1355. X
  1356. X    if (time >= 0) {
  1357. X        if (time == 0)          /* don't know if time == 0 is allowed */
  1358. X            time = 1;
  1359. X        if (WaitForChar(time) == 0)     /* no character available */
  1360. X            return 0;
  1361. X    } else {                    /* time == -1 */
  1362. X        /* If there is no character available within 2 seconds (default)
  1363. X         * write the autoscript file to disk */
  1364. X        if (WaitForChar((int) p_ut) == 0)
  1365. X            updatescript(0);
  1366. X    }
  1367. X
  1368. X/*
  1369. X * Try to read as many characters as there are.
  1370. X * Works for the controlling tty only.
  1371. X */
  1372. X    --maxlen;                   /* may get two chars at once */
  1373. X    /* we will get at least one key. Get more if they are available After a
  1374. X     * ctrl-break we have to read a 0 (!) from the buffer. bioskey(1) will
  1375. X     * return 0 if no key is available and when a ctrl-break was typed. When
  1376. X     * ctrl-break is hit, this does not always implies a key hit. */
  1377. X    cbrk_pressed = FALSE;
  1378. X    while ((len == 0 || kbhit()) && len < maxlen) {
  1379. X        switch (c = tgetch()) {
  1380. X        case 0:
  1381. X            *buf++ = K_NUL;
  1382. X            break;
  1383. X        case 3:
  1384. X            cbrk_pressed = TRUE;
  1385. X            /* FALLTHROUGH */
  1386. X        default:
  1387. X            *buf++ = c;
  1388. X        }
  1389. X        len++;
  1390. X    }
  1391. X    return len;
  1392. X}
  1393. X
  1394. X/*
  1395. X * We have no job control, fake it by starting a new shell.
  1396. X */
  1397. Xvoid            mch_suspend()
  1398. X{
  1399. X    outstr("new shell started\n");
  1400. X    call_shell(NULL, 0, TRUE);
  1401. X}
  1402. X
  1403. Xextern int      _fmode;
  1404. Xchar            OrigTitle[256];
  1405. X/*
  1406. X */
  1407. Xvoid            mch_windinit()
  1408. X{
  1409. X    CONSOLE_SCREEN_BUFFER_INFO csbi;
  1410. X
  1411. X    _fmode = O_BINARY;          /* we do our own CR-LF translation */
  1412. X    flushbuf();
  1413. X
  1414. X    /* Obtain handles for the standard Console I/O devices */
  1415. X    hConIn = CreateFile("CONIN$",
  1416. X                        GENERIC_READ | GENERIC_WRITE,
  1417. X                        FILE_SHARE_READ | FILE_SHARE_WRITE,
  1418. X                        NULL, OPEN_EXISTING, 0, NULL);
  1419. X
  1420. X    hConOut = CreateFile("CONOUT$",
  1421. X                         GENERIC_READ | GENERIC_WRITE,
  1422. X                         FILE_SHARE_READ | FILE_SHARE_WRITE,
  1423. X                         NULL, OPEN_EXISTING, 0, NULL);
  1424. X
  1425. X    GetConsoleTitle(OrigTitle, sizeof(OrigTitle));
  1426. X
  1427. X    /* get current attributes and fill out CHAR_INFO structure for fill char */
  1428. X    GetConsoleScreenBufferInfo(hConOut, &csbi);
  1429. X    DefaultAttribute = csbi.wAttributes;
  1430. X
  1431. X    mch_get_winsize();
  1432. X}
  1433. X
  1434. Xvoid            check_win(argc, argv)
  1435. X    int             argc;
  1436. X    char          **argv;
  1437. X{
  1438. X    if (!isatty(0) || !isatty(1)) {
  1439. X        fprintf(stderr, "VIM: no controlling terminal\n");
  1440. X        exit(2);
  1441. X    }
  1442. X    /* In some cases with DOS 6.0 on a NEC notebook there is a 12 seconds
  1443. X     * delay when starting up that can be avoided by the next two lines.
  1444. X     * Don't ask me why! This could be fixed by removing setver.sys from
  1445. X     * config.sys. Forget it. gotoxy(1,1); cputs(" "); */
  1446. X}
  1447. X
  1448. X/*
  1449. X * fname_case(): Set the case of the filename, if it already exists.
  1450. X *                 msdos filesystem is far to primitive for that. do nothing.
  1451. X */
  1452. Xvoid            fname_case(name)
  1453. X    char           *name;
  1454. X{
  1455. X}
  1456. X
  1457. X
  1458. X/*
  1459. X * mch_settitle(): set titlebar of our window
  1460. X * Can the icon also be set?
  1461. X */
  1462. Xvoid         mch_settitle(title, icon)
  1463. X    char           *title;
  1464. X    char           *icon;
  1465. X{
  1466. X    if (title != NULL)
  1467. X        SetConsoleTitle(title);
  1468. X}
  1469. X
  1470. X/*
  1471. X * Restore the window/icon title.
  1472. X * which is one of:
  1473. X *    1  Just restore title
  1474. X *  2  Just restore icon (which we don't have)
  1475. X *    3  Restore title and icon (which we don't have)
  1476. X */
  1477. X    void
  1478. Xmch_restore_title(which)
  1479. X    int which;
  1480. X{
  1481. X    mch_settitle((which & 1) ? OrigTitle : NULL, NULL);
  1482. X}
  1483. X
  1484. X/*
  1485. X * Get name of current directory into buffer 'buf' of length 'len' bytes.
  1486. X * Return non-zero for success.
  1487. X */
  1488. Xint             vim_dirname(buf, len)
  1489. X    char           *buf;
  1490. X    int             len;
  1491. X{
  1492. X    return (_getcwd(buf, len) != NULL);
  1493. X}
  1494. X
  1495. X/*
  1496. X * get absolute filename into buffer 'buf' of length 'len' bytes
  1497. X */
  1498. Xint             FullName(fname, buf, len)
  1499. X    char           *fname,
  1500. X                   *buf;
  1501. X    int             len;
  1502. X{
  1503. X    if (fname == NULL)          /* always fail */
  1504. X        return FAIL;
  1505. X
  1506. X    if (_fullpath(buf, fname, len) == NULL) {
  1507. X        strncpy(buf, fname, len);       /* failed, use the relative path name */
  1508. X        return FAIL;
  1509. X    }
  1510. X    return OK;
  1511. X}
  1512. X
  1513. X/*
  1514. X * return TRUE is fname is an absolute path name
  1515. X */
  1516. X    int
  1517. XisFullName(fname)
  1518. X    char_u        *fname;
  1519. X{
  1520. X    return (STRCHR(fname, ':') != NULL);
  1521. X}
  1522. X
  1523. X/*
  1524. X * get file permissions for 'name'
  1525. X * -1 : error
  1526. X * else FA_attributes defined in dos.h
  1527. X */
  1528. Xlong            getperm(name)
  1529. X    char           *name;
  1530. X{
  1531. X    int             r;
  1532. X    struct stat     sb;
  1533. X
  1534. X    r = _stat(name, &sb);       /* get file mode */
  1535. X
  1536. X    if (r)
  1537. X        return r;
  1538. X    else
  1539. X        return sb.st_mode;
  1540. X}
  1541. X
  1542. X/*
  1543. X * set file permission for 'name' to 'perm'
  1544. X */
  1545. Xint             setperm(name, perm)
  1546. X    char           *name;
  1547. X    long            perm;
  1548. X{
  1549. X    return _chmod(name, (int) perm);
  1550. X}
  1551. X
  1552. X/*
  1553. X * check if "name" is a directory
  1554. X */
  1555. Xint             isdir(name)
  1556. X    char           *name;
  1557. X{
  1558. X    int             f;
  1559. X
  1560. X    f = getperm(name);
  1561. X    if (f == -1)
  1562. X        return -1;              /* file does not exist at all */
  1563. X    if ((f & _S_IFDIR) == 0)
  1564. X        return FAIL;               /* not a directory */
  1565. X    return OK;
  1566. X}
  1567. X
  1568. X/*
  1569. X * Careful: mch_windexit() may be called before mch_windinit()!
  1570. X */
  1571. Xvoid            mch_windexit(r)
  1572. X    int             r;
  1573. X{
  1574. X    settmode(0);
  1575. X    stoptermcap();
  1576. X    flushbuf();
  1577. X    ml_close_all();                 /* remove all memfiles */
  1578. X    mch_restore_title(3);
  1579. X    exit(r);
  1580. X}
  1581. X
  1582. X/*
  1583. X * function for ctrl-break interrupt
  1584. X */
  1585. XBOOL WINAPI     handler_routine(DWORD dwCtrlType)
  1586. X{
  1587. X    cbrk_pressed = TRUE;
  1588. X    ctrlc_pressed = TRUE;
  1589. X}
  1590. X
  1591. X/*
  1592. X * set the tty in (raw) ? "raw" : "cooked" mode
  1593. X *
  1594. X */
  1595. X
  1596. Xvoid            mch_settmode(raw)
  1597. X    int             raw;
  1598. X{
  1599. X    long            cmodein;
  1600. X    long            cmodeout;
  1601. X    long            mask;
  1602. X
  1603. X    GetConsoleMode(hConIn, &cmodein);
  1604. X    GetConsoleMode(hConOut, &cmodeout);
  1605. X
  1606. X    if (raw) {
  1607. X        if (term_console)
  1608. X            outstr(T_TP);       /* set colors */
  1609. X
  1610. X        cmodein &= ~(ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT |
  1611. X                     ENABLE_ECHO_INPUT);
  1612. X        cmodein |= ENABLE_WINDOW_INPUT;
  1613. X
  1614. X        SetConsoleMode(hConIn, cmodein);
  1615. X
  1616. X        cmodeout &= ~(ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT);
  1617. X        SetConsoleMode(hConOut, cmodeout);
  1618. X        SetConsoleCtrlHandler(handler_routine, TRUE);
  1619. X    } else {
  1620. X
  1621. X        if (term_console)
  1622. X            normvideo();        /* restore screen colors */
  1623. X
  1624. X        cmodein |= (ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT |
  1625. X                    ENABLE_ECHO_INPUT);
  1626. X        cmodein &= ~(ENABLE_WINDOW_INPUT);
  1627. X
  1628. X        SetConsoleMode(hConIn, cmodein);
  1629. X
  1630. X        cmodeout |= (ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT);
  1631. X
  1632. X        SetConsoleMode(hConOut, cmodeout);
  1633. X
  1634. X        SetConsoleCtrlHandler(handler_routine, FALSE);
  1635. X    }
  1636. X}
  1637. X
  1638. Xint             mch_get_winsize()
  1639. X{
  1640. X    int             i;
  1641. X/*
  1642. X * Use the console mode API
  1643. X */
  1644. X    if (GetConsoleScreenBufferInfo(hConOut, &csbi)) {
  1645. X        Rows = csbi.dwSize.Y;
  1646. X        Columns = csbi.dwSize.X;
  1647. X        DefaultAttribute = csbi.wAttributes;
  1648. X    } else {
  1649. X        Rows = 25;
  1650. X        Columns = 80;
  1651. X    }
  1652. X
  1653. X    if (Columns < 5 || Columns > MAX_COLUMNS ||
  1654. X        Rows < 2 || Rows > MAX_COLUMNS) {
  1655. X        /* these values are overwritten by termcap size or default */
  1656. X        Columns = 80;
  1657. X        Rows = 25;
  1658. X        return OK;
  1659. X    }
  1660. X    /* Rows_max = Rows;            /* remember physical max height */
  1661. X
  1662. X    check_winsize();
  1663. X    /*script_winsize();*/
  1664. X
  1665. X    return OK;
  1666. X}
  1667. X
  1668. X/*********************************************************************
  1669. X* FUNCTION: perr(PCHAR szFileName, int line, PCHAR szApiName,        *
  1670. X*                DWORD dwError)                                      *
  1671. X*                                                                    *
  1672. X* PURPOSE: report API errors. Allocate a new console buffer, display *
  1673. X*          error number and error text, restore previous console     *
  1674. X*          buffer                                                    *
  1675. X*                                                                    *
  1676. X* INPUT: current source file name, current line number, name of the  *
  1677. X*        API that failed, and the error number                       *
  1678. X*                                                                    *
  1679. X* RETURNS: none                                                      *
  1680. X*********************************************************************/
  1681. X
  1682. X/* maximum size of the buffer to be returned from FormatMessage */
  1683. X#define MAX_MSG_BUF_SIZE 512
  1684. X
  1685. Xvoid            perr(PCHAR szFileName, int line, PCHAR szApiName, DWORD dwError)
  1686. X{
  1687. X    CHAR            szTemp[1024];
  1688. X    DWORD           cMsgLen;
  1689. X    CHAR           *msgBuf;     /* buffer for message text from system */
  1690. X    int             iButtonPressed;     /* receives button pressed in the
  1691. X                                         * error box */
  1692. X
  1693. X    /* format our error message */
  1694. X    sprintf(szTemp, "%s: Error %d from %s on line %d:\n", szFileName,
  1695. X            dwError, szApiName, line);
  1696. X    /* get the text description for that error number from the system */
  1697. X    cMsgLen = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
  1698. X                         FORMAT_MESSAGE_ALLOCATE_BUFFER | 40, NULL, dwError,
  1699. X     MAKELANGID(0, SUBLANG_ENGLISH_US), (LPTSTR) & msgBuf, MAX_MSG_BUF_SIZE,
  1700. X                            NULL);
  1701. X    if (!cMsgLen)
  1702. X        sprintf(szTemp + strlen(szTemp), "Unable to obtain error message text! \n"
  1703. X                "%s: Error %d from %s on line %d", __FILE__,
  1704. X                GetLastError(), "FormatMessage", __LINE__);
  1705. X    else
  1706. X        strcat(szTemp, msgBuf);
  1707. X    strcat(szTemp, "\n\nContinue execution?");
  1708. X    MessageBeep(MB_ICONEXCLAMATION);
  1709. X    iButtonPressed = MessageBox(NULL, szTemp, "Console API Error",
  1710. X                          MB_ICONEXCLAMATION | MB_YESNO | MB_SETFOREGROUND);
  1711. X    /* free the message buffer returned to us by the system */
  1712. X    if (cMsgLen)
  1713. X        LocalFree((HLOCAL) msgBuf);
  1714. X    if (iButtonPressed == IDNO)
  1715. X        exit(1);
  1716. X    return;
  1717. X}
  1718. X#define PERR(bSuccess, api) {if (!(bSuccess)) perr(__FILE__, __LINE__, \
  1719. X    api, GetLastError());}
  1720. X
  1721. X
  1722. Xvoid            resizeConBufAndWindow(HANDLE hConsole, SHORT xSize, SHORT ySize)
  1723. X{
  1724. X    CONSOLE_SCREEN_BUFFER_INFO csbi;    /* hold current console buffer info */
  1725. X    BOOL            bSuccess;
  1726. X    SMALL_RECT      srWindowRect;       /* hold the new console size */
  1727. X    COORD           coordScreen;
  1728. X
  1729. X    bSuccess = GetConsoleScreenBufferInfo(hConsole, &csbi);
  1730. X    PERR(bSuccess, "GetConsoleScreenBufferInfo");
  1731. X    /* get the largest size we can size the console window to */
  1732. X    coordScreen = GetLargestConsoleWindowSize(hConsole);
  1733. X    PERR(coordScreen.X | coordScreen.Y, "GetLargestConsoleWindowSize");
  1734. X    /* define the new console window size and scroll position */
  1735. X    srWindowRect.Right = (SHORT) (min(xSize, coordScreen.X) - 1);
  1736. X    srWindowRect.Bottom = (SHORT) (min(ySize, coordScreen.Y) - 1);
  1737. X    srWindowRect.Left = srWindowRect.Top = (SHORT) 0;
  1738. X    /* define the new console buffer size */
  1739. X    coordScreen.X = xSize;
  1740. X    coordScreen.Y = ySize;
  1741. X    /* if the current buffer is larger than what we want, resize the */
  1742. X    /* console window first, then the buffer */
  1743. X    if ((DWORD) csbi.dwSize.X * csbi.dwSize.Y > (DWORD) xSize * ySize) {
  1744. X        bSuccess = SetConsoleWindowInfo(hConsole, TRUE, &srWindowRect);
  1745. X        PERR(bSuccess, "SetConsoleWindowInfo");
  1746. X        bSuccess = SetConsoleScreenBufferSize(hConsole, coordScreen);
  1747. X        PERR(bSuccess, "SetConsoleScreenBufferSize");
  1748. X    }
  1749. X    /* if the current buffer is smaller than what we want, resize the */
  1750. X    /* buffer first, then the console window */
  1751. X    if ((DWORD) csbi.dwSize.X * csbi.dwSize.Y < (DWORD) xSize * ySize) {
  1752. X        bSuccess = SetConsoleScreenBufferSize(hConsole, coordScreen);
  1753. X        PERR(bSuccess, "SetConsoleScreenBufferSize");
  1754. X        bSuccess = SetConsoleWindowInfo(hConsole, TRUE, &srWindowRect);
  1755. X        PERR(bSuccess, "SetConsoleWindowInfo");
  1756. X    }
  1757. X    /* if the current buffer *is* the size we want, don't do anything! */
  1758. X    return;
  1759. X}
  1760. X
  1761. Xvoid            mch_set_winsize()
  1762. X{
  1763. X    resizeConBufAndWindow(hConOut, Columns, Rows);
  1764. X}
  1765. X
  1766. Xint             call_shell(cmd, filter, cooked)
  1767. X    char           *cmd;
  1768. X    int             filter;     /* if != 0: called by dofilter() */
  1769. X    int             cooked;
  1770. X{
  1771. X    int             x;
  1772. X    char            newcmd[200];
  1773. X
  1774. X    flushbuf();
  1775. X
  1776. X    if (cooked)
  1777. X        settmode(0);            /* set to cooked mode */
  1778. X
  1779. X    if (cmd == NULL)
  1780. X        x = system(p_sh);
  1781. X    else {                      /* we use "command" to start the shell, slow
  1782. X                                 * but easy */
  1783. X        sprintf(newcmd, "%s /c %s", p_sh, cmd);
  1784. X        x = system(newcmd);
  1785. X    }
  1786. X    outchar('\n');
  1787. X    if (cooked)
  1788. X        settmode(1);            /* set to raw mode */
  1789. X
  1790. X#ifdef WEBB_COMPLETE
  1791. X    if (x && !expand_interactively)
  1792. X#else
  1793. X    if (x)
  1794. X#endif
  1795. X    {
  1796. X        smsg("%d returned", x);
  1797. X        outchar('\n');
  1798. X    }
  1799. X    resettitle();
  1800. X    return x;
  1801. X}
  1802. X
  1803. X#define FL_CHUNK 32
  1804. X
  1805. Xstatic void     addfile(fl, f, isdir)
  1806. X    FileList       *fl;
  1807. X    char           *f;
  1808. X    int             isdir;
  1809. X{
  1810. X    char           *p;
  1811. X
  1812. X    if (!fl->file) {
  1813. X        fl->file = (char **) alloc(sizeof(char *) * FL_CHUNK);
  1814. X        if (!fl->file)
  1815. X            return;
  1816. X        fl->nfiles = 0;
  1817. X        fl->maxfiles = FL_CHUNK;
  1818. X    }
  1819. X    if (fl->nfiles >= fl->maxfiles) {
  1820. X        char          **t;
  1821. X        int             i;
  1822. X
  1823. X        t = (char **) lalloc(sizeof(char *) * (fl->maxfiles + FL_CHUNK), TRUE);
  1824. X        if (!t)
  1825. X            return;
  1826. X        for (i = fl->nfiles - 1; i >= 0; i--)
  1827. X            t[i] = fl->file[i];
  1828. X        free(fl->file);
  1829. X        fl->file = t;
  1830. X        fl->maxfiles += FL_CHUNK;
  1831. X    }
  1832. X    p = alloc((unsigned) (strlen(f) + 1 + isdir));
  1833. X    if (p) {
  1834. X        strcpy(p, f);
  1835. X        if (isdir)
  1836. X            strcat(p, "/");
  1837. X    }
  1838. X    fl->file[fl->nfiles++] = p;
  1839. X}
  1840. X
  1841. Xstatic int      pstrcmp(a, b)
  1842. X    char          **a,
  1843. X                  **b;
  1844. X{
  1845. X    return (strcmp(*a, *b));
  1846. X}
  1847. X
  1848. Xint             has_wildcard(s)
  1849. X    char           *s;
  1850. X{
  1851. X    if (s)
  1852. X        for (; *s; ++s)
  1853. X            if (*s == '?' || *s == '*')
  1854. X                return 1;
  1855. X    return 0;
  1856. X}
  1857. X
  1858. Xstatic void     strlowcpy(d, s)
  1859. X    char           *d,
  1860. X                   *s;
  1861. X{
  1862. X    while (*s)
  1863. X        *d++ = tolower(*s++);
  1864. X    *d = '\0';
  1865. X}
  1866. X
  1867. Xstatic int      expandpath(fl, path, fonly, donly, notf)
  1868. X    FileList       *fl;
  1869. X    char           *path;
  1870. X    int             fonly,
  1871. X                    donly,
  1872. X                    notf;
  1873. X{
  1874. X    char            buf[MAX_PATH];
  1875. X    char           *p,
  1876. X                   *s,
  1877. X                   *e;
  1878. X    int             lastn,
  1879. X                    c = 1,
  1880. X                    r;
  1881. X    WIN32_FIND_DATA fb;
  1882. X    HANDLE          hFind;
  1883. X
  1884. X    lastn = fl->nfiles;
  1885. X
  1886. X/*
  1887. X * Find the first part in the path name that contains a wildcard.
  1888. X * Copy it into buf, including the preceding characters.
  1889. X */
  1890. X    p = buf;
  1891. X    s = NULL;
  1892. X    e = NULL;
  1893. X    while (*path) {
  1894. X        if (*path == '\\' || *path == ':' || *path == '/') {
  1895. X            if (e)
  1896. X                break;
  1897. X            else
  1898. X                s = p;
  1899. X        }
  1900. X        if (*path == '*' || *path == '?')
  1901. X            e = p;
  1902. X        *p++ = *path++;
  1903. X    }
  1904. X    e = p;
  1905. X    if (s)
  1906. X        s++;
  1907. X    else
  1908. X        s = buf;
  1909. X
  1910. X    /* now we have one wildcard component between s and e */
  1911. X    *e = '\0';
  1912. X    r = 0;
  1913. X    /* If we are expanding wildcards we try both files and directories */
  1914. X    if ((hFind = FindFirstFile(buf, &fb)) == INVALID_HANDLE_VALUE) {
  1915. X        /* not found */
  1916. X        strcpy(e, path);
  1917. X        if (notf)
  1918. X            addfile(fl, buf, FALSE);
  1919. X        return 1;               /* unexpanded or empty */
  1920. X    }
  1921. X    while (c) {
  1922. X        strlowcpy(s, fb.cFileName);
  1923. X        if (*s != '.' || (s[1] != '\0' && (s[1] != '.' || s[2] != '\0'))) {
  1924. X            strcat(buf, path);
  1925. X            if (!has_wildcard(path))
  1926. X                addfile(fl, buf, (isdir(buf) > 0));
  1927. X            else
  1928. X                r |= expandpath(fl, buf, fonly, donly, notf);
  1929. X        }
  1930. X        c = FindNextFile(hFind, &fb);
  1931. X    }
  1932. X    qsort(fl->file + lastn, fl->nfiles - lastn, sizeof(char *), pstrcmp);
  1933. X    FindClose(hFind);
  1934. X    return r;
  1935. X}
  1936. X
  1937. X/*
  1938. X * MSDOS rebuilt of Scott Ballantynes ExpandWildCard for amiga/arp.
  1939. X * jw
  1940. X */
  1941. X
  1942. Xint             ExpandWildCards(num_pat, pat, num_file, file, files_only, list_notfound)
  1943. X    int             num_pat;
  1944. X    char          **pat;
  1945. X    int            *num_file;
  1946. X    char         ***file;
  1947. X    int             files_only,
  1948. X                    list_notfound;
  1949. X{
  1950. X    int             i,
  1951. X                    r = 0;
  1952. X    FileList        f;
  1953. X
  1954. X    f.file = NULL;
  1955. X    f.nfiles = 0;
  1956. X    for (i = 0; i < num_pat; i++) {
  1957. X        if (!has_wildcard(pat[i]))
  1958. X            addfile(&f, pat[i], files_only ? FALSE : (isdir(pat[i]) > 0));
  1959. X        else
  1960. X            r |= expandpath(&f, pat[i], files_only, 0, list_notfound);
  1961. X    }
  1962. X    if (r == 0) {
  1963. X        *num_file = f.nfiles;
  1964. X        *file = f.file;
  1965. X    } else {
  1966. X        *num_file = 0;
  1967. X        *file = NULL;
  1968. X    }
  1969. X    return (r ? FAIL : OK);
  1970. X}
  1971. X
  1972. Xvoid            FreeWild(num, file)
  1973. X    int             num;
  1974. X    char          **file;
  1975. X{
  1976. X    if (file == NULL || num <= 0)
  1977. X        return;
  1978. X    while (num--)
  1979. X        free(file[num]);
  1980. X    free(file);
  1981. X}
  1982. X
  1983. X/*
  1984. X * The normal chdir() does not change the default drive.
  1985. X * This one does.
  1986. X */
  1987. X#undef chdir
  1988. Xint             vim_chdir(path)
  1989. X    char           *path;
  1990. X{
  1991. X    if (path[0] == NUL)         /* just checking... */
  1992. X        return FAIL;
  1993. X    if (path[1] == ':') {       /* has a drive name */
  1994. X        if (_chdrive(toupper(path[0]) - 'A' + 1))
  1995. X            return -1;          /* invalid drive name */
  1996. X        path += 2;
  1997. X    }
  1998. X    if (*path == NUL)           /* drive name only */
  1999. X        return OK;
  2000. X    return _chdir(path);        /* let the normal chdir() do the rest */
  2001. X}
  2002. X
  2003. Xclrscr()
  2004. X{
  2005. X    int             count;
  2006. X
  2007. X    ntcoord.X = 0;
  2008. X    ntcoord.Y = 0;
  2009. X    FillConsoleOutputCharacter(hConOut, ' ', Columns * Rows,
  2010. X                               ntcoord, &count);
  2011. X    FillConsoleOutputAttribute(hConOut, DefaultAttribute, Rows * Columns,
  2012. X                               ntcoord, &count);
  2013. X}
  2014. X
  2015. Xclreol()
  2016. X{
  2017. X    int             count;
  2018. X    FillConsoleOutputCharacter(hConOut, ' ',
  2019. X                               Columns - ntcoord.X,
  2020. X                               ntcoord, &count);
  2021. X    FillConsoleOutputAttribute(hConOut, DefaultAttribute,
  2022. X                               Columns - ntcoord.X,
  2023. X                               ntcoord, &count);
  2024. X}
  2025. X
  2026. Xinsline(int count)
  2027. X{
  2028. X    SMALL_RECT      source,
  2029. X                    clip;
  2030. X    COORD           dest;
  2031. X    CHAR_INFO       fill;
  2032. X
  2033. X    dest.X = 0;
  2034. X    dest.Y = ntcoord.Y + count;
  2035. X
  2036. X    source.Left = 0;
  2037. X    source.Top = ntcoord.Y;
  2038. X    source.Right = Columns;
  2039. X    source.Bottom = Rows - 1;
  2040. X
  2041. X    fill.Char.AsciiChar = ' ';
  2042. X    fill.Attributes = DefaultAttribute;
  2043. X
  2044. X    ScrollConsoleScreenBuffer(hConOut, &source, (PSMALL_RECT) 0, dest,
  2045. X                              &fill);
  2046. X}
  2047. X
  2048. Xdelline(int count)
  2049. X{
  2050. X    SMALL_RECT      source,
  2051. X                    clip;
  2052. X    COORD           dest;
  2053. X    CHAR_INFO       fill;
  2054. X
  2055. X    dest.X = 0;
  2056. X    dest.Y = ntcoord.Y;
  2057. X
  2058. X    source.Left = 0;
  2059. X    source.Top = ntcoord.Y + count;
  2060. X    source.Right = Columns;
  2061. X    source.Bottom = Rows - 1;
  2062. X
  2063. X    /* get current attributes and fill out CHAR_INFO structure for fill char */
  2064. X    fill.Char.AsciiChar = ' ';
  2065. X    fill.Attributes = DefaultAttribute;
  2066. X
  2067. X    ScrollConsoleScreenBuffer(hConOut, &source, (PSMALL_RECT) 0, dest,
  2068. X                              &fill);
  2069. X}
  2070. X
  2071. X
  2072. Xscroll()
  2073. X{
  2074. X    SMALL_RECT      source,
  2075. X                    clip;
  2076. X    COORD           dest;
  2077. X    CHAR_INFO       fill;
  2078. X
  2079. X    dest.X = 0;
  2080. X    dest.Y = 0;
  2081. X
  2082. X    source.Left = 0;
  2083. X    source.Top = 1;
  2084. X    source.Right = Columns;
  2085. X    source.Bottom = Rows - 1;
  2086. X
  2087. X    /* get current attributes and fill out CHAR_INFO structure for fill char */
  2088. X    fill.Char.AsciiChar = ' ';
  2089. X    fill.Attributes = DefaultAttribute;
  2090. X
  2091. X    ScrollConsoleScreenBuffer(hConOut, &source, (PSMALL_RECT) 0, dest,
  2092. X                              &fill);
  2093. X}
  2094. X
  2095. Xgotoxy(x, y)
  2096. X    register int    x,
  2097. X                    y;
  2098. X{
  2099. X    ntcoord.X = x - 1;
  2100. X    ntcoord.Y = y - 1;
  2101. X    SetConsoleCursorPosition(hConOut, ntcoord);
  2102. X}
  2103. X
  2104. Xnormvideo()
  2105. X{
  2106. X    int             count;
  2107. X    WORD            attr = DefaultAttribute;
  2108. X
  2109. X    SetConsoleTextAttribute(hConOut, attr);
  2110. X}
  2111. X
  2112. Xtextattr(int attr)
  2113. X{
  2114. X    int             count;
  2115. X    WORD            attrw = attr;
  2116. X
  2117. X    SetConsoleTextAttribute(hConOut, attr);
  2118. X}
  2119. X
  2120. Xputch(char c)
  2121. X{
  2122. X    int             count;
  2123. X
  2124. X    WriteConsole(hConOut, &c, 1, &count, 0);
  2125. X    ntcoord.X += count;
  2126. X}
  2127. X
  2128. Xdelay(x)
  2129. X{
  2130. X    Sleep(x);
  2131. X}
  2132. X
  2133. Xsleep(x)
  2134. X{
  2135. X    Sleep(x * 1000);
  2136. X}
  2137. X
  2138. Xvbell()
  2139. X{
  2140. X    COORD           origin = {0, 0};
  2141. X    WORD            flash = ~DefaultAttribute & 0xff;
  2142. X    WORD            off = DefaultAttribute;
  2143. X
  2144. X    int             count;
  2145. X    LPWORD          oldattrs = alloc(Rows * Columns * sizeof(WORD));
  2146. X
  2147. X    ReadConsoleOutputAttribute(hConOut, oldattrs, Rows * Columns, origin,
  2148. X                                &count);
  2149. X    FillConsoleOutputAttribute(hConOut, flash, Rows * Columns, origin,
  2150. X                               &count);
  2151. X    WriteConsoleOutputAttribute(hConOut, oldattrs, Rows * Columns, origin,
  2152. X                                &count);
  2153. X    free(oldattrs);
  2154. X}
  2155. X
  2156. Xcursor_visible(int visible)
  2157. X{
  2158. X    CONSOLE_CURSOR_INFO cci;
  2159. X
  2160. X    cci.bVisible = visible ? TRUE : FALSE;
  2161. X    cci.dwSize = 100;           /* 100 percent cursor */
  2162. X    SetConsoleCursorInfo(hConOut, &cci);
  2163. X}
  2164. X
  2165. Xvoid            set_window(void)
  2166. X{
  2167. X}
  2168. X
  2169. X/*
  2170. X * check for an "interrupt signal": CTRL-break or CTRL-C
  2171. X */
  2172. Xvoid            breakcheck()
  2173. X{
  2174. X    if (ctrlc_pressed) {
  2175. X        ctrlc_pressed = FALSE;
  2176. X        got_int = TRUE;
  2177. X    }
  2178. X}
  2179. X
  2180. X    long
  2181. Xmch_avail_mem(special)
  2182. X    int special;
  2183. X{
  2184. X    return 0x7fffffff;        /* virual memory eh */
  2185. X}
  2186. X
  2187. X/*
  2188. X * return non-zero if a character is available
  2189. X */
  2190. X    int
  2191. Xmch_char_avail()
  2192. X{
  2193. X    return WaitForChar(0);
  2194. X}
  2195. X
  2196. X/*
  2197. X * set screen mode, always fails.
  2198. X */
  2199. X    int
  2200. Xmch_screenmode(arg)
  2201. X    char_u     *arg;
  2202. X{
  2203. X    EMSG("Screen mode setting not supported");
  2204. X    return FAIL;
  2205. X}
  2206. END_OF_FILE
  2207.   if test 31469 -ne `wc -c <'vim/src/winnt.c'`; then
  2208.     echo shar: \"'vim/src/winnt.c'\" unpacked with wrong size!
  2209.   fi
  2210.   # end of 'vim/src/winnt.c'
  2211. fi
  2212. echo shar: End of archive 16 \(of 26\).
  2213. cp /dev/null ark16isdone
  2214. MISSING=""
  2215. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ; do
  2216.     if test ! -f ark${I}isdone ; then
  2217.     MISSING="${MISSING} ${I}"
  2218.     fi
  2219. done
  2220. if test "${MISSING}" = "" ; then
  2221.     echo You have unpacked all 26 archives.
  2222.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2223. else
  2224.     echo You still must unpack the following archives:
  2225.     echo "        " ${MISSING}
  2226. fi
  2227. exit 0
  2228. exit 0 # Just in case...
  2229.