Mercurial > vim
annotate src/vimrun.c @ 17129:4fb68abc770f v8.1.1564
patch 8.1.1564: sign column takes up space
commit https://github.com/vim/vim/commit/394c5d8870b15150fc91a4c058dc571fd5eaa97e
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 17 21:48:05 2019 +0200
patch 8.1.1564: sign column takes up space
Problem: Sign column takes up space. (Adam Stankiewicz)
Solution: Optionally put signs in the number column. (Yegappan Lakshmanan,
closes #4555, closes #4515)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 17 Jun 2019 22:00:09 +0200 |
parents | 7e733046db1d |
children | 85160a3649b9 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9840
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * this file by Vince Negri | |
5 * | |
6 * Do ":help uganda" in Vim to read copying and usage conditions. | |
7 * Do ":help credits" in Vim to see a list of people who contributed. | |
8 * See README.txt for an overview of the Vim source code. | |
9 */ | |
10 | |
11 /* | |
12 * vimrun.c - Tiny Win32 program to safely run an external command in a | |
13 * DOS console. | |
14 * This program is required to avoid that typing CTRL-C in the DOS | |
15 * console kills Vim. Now it only kills vimrun. | |
16 */ | |
17 | |
18 #include <stdio.h> | |
19 #include <stdlib.h> | |
9840
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
20 #include <conio.h> |
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
21 #ifndef WIN32_LEAN_AND_MEAN |
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
22 # define WIN32_LEAN_AND_MEAN |
7 | 23 #endif |
9840
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
24 #include <windows.h> |
7 | 25 |
26 int | |
27 main(void) | |
28 { | |
9840
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
29 const wchar_t *p; |
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
30 int retval; |
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
31 int inquote = 0; |
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
32 int silent = 0; |
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
33 HANDLE hstdout; |
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
34 DWORD written; |
7 | 35 |
9840
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
36 p = (const wchar_t *)GetCommandLineW(); |
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
37 |
7 | 38 /* |
39 * Skip the executable name, which might be in "". | |
40 */ | |
41 while (*p) | |
42 { | |
9840
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
43 if (*p == L'"') |
7 | 44 inquote = !inquote; |
9840
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
45 else if (!inquote && *p == L' ') |
7 | 46 { |
47 ++p; | |
48 break; | |
49 } | |
50 ++p; | |
51 } | |
9840
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
52 while (*p == L' ') |
13353
8412df1479a3
patch 8.0.1550: various small problems in source files
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
53 ++p; |
7 | 54 |
55 /* | |
56 * "-s" argument: don't wait for a key hit. | |
57 */ | |
9840
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
58 if (p[0] == L'-' && p[1] == L's' && p[2] == L' ') |
7 | 59 { |
60 silent = 1; | |
61 p += 3; | |
9840
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
62 while (*p == L' ') |
7 | 63 ++p; |
64 } | |
65 | |
66 /* Print the command, including quotes and redirection. */ | |
9840
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
67 hstdout = GetStdHandle(STD_OUTPUT_HANDLE); |
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
68 WriteConsoleW(hstdout, p, wcslen(p), &written, NULL); |
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
69 WriteConsoleW(hstdout, L"\r\n", 2, &written, NULL); |
7 | 70 |
71 /* | |
72 * Do it! | |
73 */ | |
9840
da7307987ed1
commit https://github.com/vim/vim/commit/bcc1dcc981dfc092587d4fbd1327d82a03426c57
Christian Brabandt <cb@256bit.org>
parents:
7166
diff
changeset
|
74 retval = _wsystem(p); |
7 | 75 |
1121 | 76 if (retval == -1) |
77 perror("vimrun system(): "); | |
78 else if (retval != 0) | |
7 | 79 printf("shell returned %d\n", retval); |
80 | |
81 if (!silent) | |
82 { | |
83 puts("Hit any key to close this window..."); | |
84 | |
85 while (_kbhit()) | |
86 (void)_getch(); | |
87 (void)_getch(); | |
88 } | |
89 | |
90 return retval; | |
91 } |