annotate src/gui_w32.c @ 11745:5a5709918a98 v8.0.0755

patch 8.0.0755: terminal window does not have colors in the GUI commit https://github.com/vim/vim/commit/26af85d97ba1ed0ade6cdd41890ca04ed879b9c7 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 23 16:45:10 2017 +0200 patch 8.0.0755: terminal window does not have colors in the GUI Problem: Terminal window does not have colors in the GUI. Solution: Lookup the GUI color.
author Christian Brabandt <cb@256bit.org>
date Sun, 23 Jul 2017 17:00:04 +0200
parents db21cc7b40f0
children 8ad282dee649
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10042
4aead6a9b7a9 commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents: 9959
diff changeset
1 /* vi:set ts=8 sts=4 sw=4 noet:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 * GUI support by Robert Webb
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * Windows GUI.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 *
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
13 * GUI support for Microsoft Windows, aka Win32. Also for Win64.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 * George V. Reilly <george@reilly.org> wrote the original Win32 GUI.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 * Robert Webb reworked it to use the existing GUI stuff and added menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 * scrollbars, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 * Note: Clipboard stuff, for cutting and pasting text to other windows, is in
7009
286fd54c7ae3 patch 7.4.822
Bram Moolenaar <bram@vim.org>
parents: 6714
diff changeset
20 * winclip.c. (It can also be done from the terminal version).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 * TODO: Some of the function signatures ought to be updated for Win64;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 * e.g., replace LONG with LONG_PTR, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25
1376
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
26 #include "vim.h"
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
27
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
28 #if defined(FEAT_DIRECTX)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
29 # include "gui_dwrite.h"
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
30 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
31
6359
9f9058aeba0d updated for version 7.4.512
Bram Moolenaar <bram@vim.org>
parents: 6260
diff changeset
32 #if defined(FEAT_DIRECTX)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
33 static DWriteContext *s_dwc = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
34 static int s_directx_enabled = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
35 static int s_directx_load_attempted = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
36 # define IS_ENABLE_DIRECTX() (s_directx_enabled && s_dwc != NULL)
6359
9f9058aeba0d updated for version 7.4.512
Bram Moolenaar <bram@vim.org>
parents: 6260
diff changeset
37 #endif
9f9058aeba0d updated for version 7.4.512
Bram Moolenaar <bram@vim.org>
parents: 6260
diff changeset
38
8138
f52504c10387 commit https://github.com/vim/vim/commit/065bbac8adfe29a09958570237d223457f235c6c
Christian Brabandt <cb@256bit.org>
parents: 8108
diff changeset
39 #ifdef FEAT_MENU
f52504c10387 commit https://github.com/vim/vim/commit/065bbac8adfe29a09958570237d223457f235c6c
Christian Brabandt <cb@256bit.org>
parents: 8108
diff changeset
40 static int gui_mswin_get_menu_height(int fix_window);
f52504c10387 commit https://github.com/vim/vim/commit/065bbac8adfe29a09958570237d223457f235c6c
Christian Brabandt <cb@256bit.org>
parents: 8108
diff changeset
41 #endif
f52504c10387 commit https://github.com/vim/vim/commit/065bbac8adfe29a09958570237d223457f235c6c
Christian Brabandt <cb@256bit.org>
parents: 8108
diff changeset
42
6359
9f9058aeba0d updated for version 7.4.512
Bram Moolenaar <bram@vim.org>
parents: 6260
diff changeset
43 #if defined(FEAT_DIRECTX) || defined(PROTO)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
44 int
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
45 directx_enabled(void)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
46 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
47 if (s_dwc != NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
48 return 1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
49 else if (s_directx_load_attempted)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
50 return 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
51 /* load DirectX */
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
52 DWrite_Init();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
53 s_directx_load_attempted = 1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
54 s_dwc = DWriteContext_Open();
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
55 return s_dwc != NULL ? 1 : 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
56 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
57 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
58
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
59 #if defined(FEAT_RENDER_OPTIONS) || defined(PROTO)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
60 int
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
61 gui_mch_set_rendering_options(char_u *s)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
62 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
63 #ifdef FEAT_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
64 char_u *p, *q;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
65
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
66 int dx_enable = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
67 int dx_flags = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
68 float dx_gamma = 0.0f;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
69 float dx_contrast = 0.0f;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
70 float dx_level = 0.0f;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
71 int dx_geom = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
72 int dx_renmode = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
73 int dx_taamode = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
74
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
75 /* parse string as rendering options. */
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
76 for (p = s; p != NULL && *p != NUL; )
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
77 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
78 char_u item[256];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
79 char_u name[128];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
80 char_u value[128];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
81
7009
286fd54c7ae3 patch 7.4.822
Bram Moolenaar <bram@vim.org>
parents: 6714
diff changeset
82 copy_option_part(&p, item, sizeof(item), ",");
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
83 if (p == NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
84 break;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
85 q = &item[0];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
86 copy_option_part(&q, name, sizeof(name), ":");
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
87 if (q == NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
88 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
89 copy_option_part(&q, value, sizeof(value), ":");
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
90
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
91 if (STRCMP(name, "type") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
92 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
93 if (STRCMP(value, "directx") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
94 dx_enable = 1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
95 else
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
96 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
97 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
98 else if (STRCMP(name, "gamma") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
99 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
100 dx_flags |= 1 << 0;
8108
50515f2e81d1 commit https://github.com/vim/vim/commit/7f0608fb5219645d776fadfe13efb867c2460698
Christian Brabandt <cb@256bit.org>
parents: 8102
diff changeset
101 dx_gamma = (float)atof((char *)value);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
102 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
103 else if (STRCMP(name, "contrast") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
104 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
105 dx_flags |= 1 << 1;
8108
50515f2e81d1 commit https://github.com/vim/vim/commit/7f0608fb5219645d776fadfe13efb867c2460698
Christian Brabandt <cb@256bit.org>
parents: 8102
diff changeset
106 dx_contrast = (float)atof((char *)value);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
107 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
108 else if (STRCMP(name, "level") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
109 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
110 dx_flags |= 1 << 2;
8108
50515f2e81d1 commit https://github.com/vim/vim/commit/7f0608fb5219645d776fadfe13efb867c2460698
Christian Brabandt <cb@256bit.org>
parents: 8102
diff changeset
111 dx_level = (float)atof((char *)value);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
112 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
113 else if (STRCMP(name, "geom") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
114 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
115 dx_flags |= 1 << 3;
8108
50515f2e81d1 commit https://github.com/vim/vim/commit/7f0608fb5219645d776fadfe13efb867c2460698
Christian Brabandt <cb@256bit.org>
parents: 8102
diff changeset
116 dx_geom = atoi((char *)value);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
117 if (dx_geom < 0 || dx_geom > 2)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
118 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
119 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
120 else if (STRCMP(name, "renmode") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
121 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
122 dx_flags |= 1 << 4;
8108
50515f2e81d1 commit https://github.com/vim/vim/commit/7f0608fb5219645d776fadfe13efb867c2460698
Christian Brabandt <cb@256bit.org>
parents: 8102
diff changeset
123 dx_renmode = atoi((char *)value);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
124 if (dx_renmode < 0 || dx_renmode > 6)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
125 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
126 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
127 else if (STRCMP(name, "taamode") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
128 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
129 dx_flags |= 1 << 5;
8108
50515f2e81d1 commit https://github.com/vim/vim/commit/7f0608fb5219645d776fadfe13efb867c2460698
Christian Brabandt <cb@256bit.org>
parents: 8102
diff changeset
130 dx_taamode = atoi((char *)value);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
131 if (dx_taamode < 0 || dx_taamode > 3)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
132 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
133 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
134 else
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
135 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
136 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
137
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
138 /* Enable DirectX/DirectWrite */
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
139 if (dx_enable)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
140 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
141 if (!directx_enabled())
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
142 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
143 DWriteContext_SetRenderingParams(s_dwc, NULL);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
144 if (dx_flags)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
145 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
146 DWriteRenderingParams param;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
147 DWriteContext_GetRenderingParams(s_dwc, &param);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
148 if (dx_flags & (1 << 0))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
149 param.gamma = dx_gamma;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
150 if (dx_flags & (1 << 1))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
151 param.enhancedContrast = dx_contrast;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
152 if (dx_flags & (1 << 2))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
153 param.clearTypeLevel = dx_level;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
154 if (dx_flags & (1 << 3))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
155 param.pixelGeometry = dx_geom;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
156 if (dx_flags & (1 << 4))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
157 param.renderingMode = dx_renmode;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
158 if (dx_flags & (1 << 5))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
159 param.textAntialiasMode = dx_taamode;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
160 DWriteContext_SetRenderingParams(s_dwc, &param);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
161 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
162 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
163 s_directx_enabled = dx_enable;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
164
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
165 return OK;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
166 #else
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
167 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
168 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
169 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
170 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
171
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
172 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 * These are new in Windows ME/XP, only defined in recent compilers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 #ifndef HANDLE_WM_XBUTTONUP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 # define HANDLE_WM_XBUTTONUP(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 #ifndef HANDLE_WM_XBUTTONDOWN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 # define HANDLE_WM_XBUTTONDOWN(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 #ifndef HANDLE_WM_XBUTTONDBLCLK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 # define HANDLE_WM_XBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
188
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
189 #include "version.h" /* used by dialog box routine for default title */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
190 #ifdef DEBUG
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
191 # include <tchar.h>
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
192 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
193
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
194 /* cproto fails on missing include files */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
195 #ifndef PROTO
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
196
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
197 #ifndef __MINGW32__
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
198 # include <shellapi.h>
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
199 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
200 #if defined(FEAT_TOOLBAR) || defined(FEAT_BEVAL) || defined(FEAT_GUI_TABLINE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
201 # include <commctrl.h>
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
202 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
203 #include <windowsx.h>
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
204
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
205 #ifdef GLOBAL_IME
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
206 # include "glbl_ime.h"
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
207 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
208
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
209 #endif /* PROTO */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
210
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
211 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
212 # define MENUHINTS /* show menu hints in command line */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
213 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
214
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
215 /* Some parameters for dialog boxes. All in pixels. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
216 #define DLG_PADDING_X 10
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
217 #define DLG_PADDING_Y 10
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
218 #define DLG_OLD_STYLE_PADDING_X 5
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
219 #define DLG_OLD_STYLE_PADDING_Y 5
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
220 #define DLG_VERT_PADDING_X 4 /* For vertical buttons */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
221 #define DLG_VERT_PADDING_Y 4
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
222 #define DLG_ICON_WIDTH 34
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
223 #define DLG_ICON_HEIGHT 34
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
224 #define DLG_MIN_WIDTH 150
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
225 #define DLG_FONT_NAME "MS Sans Serif"
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
226 #define DLG_FONT_POINT_SIZE 8
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
227 #define DLG_MIN_MAX_WIDTH 400
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
228 #define DLG_MIN_MAX_HEIGHT 400
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
229
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
230 #define DLG_NONBUTTON_CONTROL 5000 /* First ID of non-button controls */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
231
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
232 #ifndef WM_XBUTTONDOWN /* For Win2K / winME ONLY */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
233 # define WM_XBUTTONDOWN 0x020B
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
234 # define WM_XBUTTONUP 0x020C
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
235 # define WM_XBUTTONDBLCLK 0x020D
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
236 # define MK_XBUTTON1 0x0020
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
237 # define MK_XBUTTON2 0x0040
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
238 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
239
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
240 #ifdef PROTO
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
241 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
242 * Define a few things for generating prototypes. This is just to avoid
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
243 * syntax errors, the defines do not need to be correct.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
244 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
245 # define APIENTRY
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
246 # define CALLBACK
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
247 # define CONST
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
248 # define FAR
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
249 # define NEAR
9834
80ace3687eec commit https://github.com/vim/vim/commit/a6b7a08ae04a3cd4d9c45c906bb7a197e2135179
Christian Brabandt <cb@256bit.org>
parents: 9428
diff changeset
250 # undef _cdecl
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
251 # define _cdecl
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
252 typedef int BOOL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
253 typedef int BYTE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
254 typedef int DWORD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
255 typedef int WCHAR;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
256 typedef int ENUMLOGFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
257 typedef int FINDREPLACE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
258 typedef int HANDLE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
259 typedef int HBITMAP;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
260 typedef int HBRUSH;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
261 typedef int HDROP;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
262 typedef int INT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
263 typedef int LOGFONT[];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
264 typedef int LPARAM;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
265 typedef int LPCREATESTRUCT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
266 typedef int LPCSTR;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
267 typedef int LPCTSTR;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
268 typedef int LPRECT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
269 typedef int LPSTR;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
270 typedef int LPWINDOWPOS;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
271 typedef int LPWORD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
272 typedef int LRESULT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
273 typedef int HRESULT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
274 # undef MSG
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
275 typedef int MSG;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
276 typedef int NEWTEXTMETRIC;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
277 typedef int OSVERSIONINFO;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
278 typedef int PWORD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
279 typedef int RECT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
280 typedef int UINT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
281 typedef int WORD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
282 typedef int WPARAM;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
283 typedef int POINT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
284 typedef void *HINSTANCE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
285 typedef void *HMENU;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
286 typedef void *HWND;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
287 typedef void *HDC;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
288 typedef void VOID;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
289 typedef int LPNMHDR;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
290 typedef int LONG;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
291 typedef int WNDPROC;
9834
80ace3687eec commit https://github.com/vim/vim/commit/a6b7a08ae04a3cd4d9c45c906bb7a197e2135179
Christian Brabandt <cb@256bit.org>
parents: 9428
diff changeset
292 typedef int UINT_PTR;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
293 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
294
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
295 #ifndef GET_X_LPARAM
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
296 # define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
297 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
298
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
299 static void _OnPaint( HWND hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
300 static void clear_rect(RECT *rcp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
301
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
302 static WORD s_dlgfntheight; /* height of the dialog font */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
303 static WORD s_dlgfntwidth; /* width of the dialog font */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
304
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
305 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
306 static HMENU s_menuBar = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
307 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
308 #ifdef FEAT_TEAROFF
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
309 static void rebuild_tearoff(vimmenu_T *menu);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
310 static HBITMAP s_htearbitmap; /* bitmap used to indicate tearoff */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
311 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
312
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
313 /* Flag that is set while processing a message that must not be interrupted by
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
314 * processing another message. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
315 static int s_busy_processing = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
316
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
317 static int destroying = FALSE; /* call DestroyWindow() ourselves */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
318
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
319 #ifdef MSWIN_FIND_REPLACE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
320 static UINT s_findrep_msg = 0; /* set in gui_w[16/32].c */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
321 static FINDREPLACE s_findrep_struct;
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
322 # ifdef FEAT_MBYTE
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
323 static FINDREPLACEW s_findrep_struct_w;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
324 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
325 static HWND s_findrep_hwnd = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
326 static int s_findrep_is_find; /* TRUE for find dialog, FALSE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
327 for find/replace dialog */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
328 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
329
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
330 static HINSTANCE s_hinst = NULL;
8281
74b15ed0a259 commit https://github.com/vim/vim/commit/85b11769ab507c7df93f319fd964fa579701b76b
Christian Brabandt <cb@256bit.org>
parents: 8273
diff changeset
331 #if !defined(FEAT_GUI)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
332 static
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
333 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
334 HWND s_hwnd = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
335 static HDC s_hdc = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
336 static HBRUSH s_brush = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
337
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
338 #ifdef FEAT_TOOLBAR
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
339 static HWND s_toolbarhwnd = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
340 static WNDPROC s_toolbar_wndproc = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
341 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
342
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
343 #ifdef FEAT_GUI_TABLINE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
344 static HWND s_tabhwnd = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
345 static WNDPROC s_tabline_wndproc = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
346 static int showing_tabline = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
347 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
348
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
349 static WPARAM s_wParam = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
350 static LPARAM s_lParam = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
351
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
352 static HWND s_textArea = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
353 static UINT s_uMsg = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
354
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
355 static char_u *s_textfield; /* Used by dialogs to pass back strings */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
356
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
357 static int s_need_activate = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
358
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
359 /* This variable is set when waiting for an event, which is the only moment
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
360 * scrollbar dragging can be done directly. It's not allowed while commands
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
361 * are executed, because it may move the cursor and that may cause unexpected
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
362 * problems (e.g., while ":s" is working).
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
363 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
364 static int allow_scrollbar = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
365
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
366 #ifdef GLOBAL_IME
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
367 # define MyTranslateMessage(x) global_ime_TranslateMessage(x)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
368 #else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
369 # define MyTranslateMessage(x) TranslateMessage(x)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
370 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
371
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
372 #if defined(FEAT_MBYTE) || defined(GLOBAL_IME)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
373 /* use of WindowProc depends on wide_WindowProc */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
374 # define MyWindowProc vim_WindowProc
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
375 #else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
376 /* use ordinary WindowProc */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
377 # define MyWindowProc DefWindowProc
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
378 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
379
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
380 extern int current_font_height; /* this is in os_mswin.c */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
381
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
382 static struct
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
383 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
384 UINT key_sym;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
385 char_u vim_code0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
386 char_u vim_code1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
387 } special_keys[] =
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
388 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
389 {VK_UP, 'k', 'u'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
390 {VK_DOWN, 'k', 'd'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
391 {VK_LEFT, 'k', 'l'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
392 {VK_RIGHT, 'k', 'r'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
393
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
394 {VK_F1, 'k', '1'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
395 {VK_F2, 'k', '2'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
396 {VK_F3, 'k', '3'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
397 {VK_F4, 'k', '4'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
398 {VK_F5, 'k', '5'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
399 {VK_F6, 'k', '6'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
400 {VK_F7, 'k', '7'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
401 {VK_F8, 'k', '8'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
402 {VK_F9, 'k', '9'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
403 {VK_F10, 'k', ';'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
404
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
405 {VK_F11, 'F', '1'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
406 {VK_F12, 'F', '2'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
407 {VK_F13, 'F', '3'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
408 {VK_F14, 'F', '4'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
409 {VK_F15, 'F', '5'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
410 {VK_F16, 'F', '6'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
411 {VK_F17, 'F', '7'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
412 {VK_F18, 'F', '8'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
413 {VK_F19, 'F', '9'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
414 {VK_F20, 'F', 'A'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
415
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
416 {VK_F21, 'F', 'B'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
417 #ifdef FEAT_NETBEANS_INTG
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
418 {VK_PAUSE, 'F', 'B'}, /* Pause == F21 (see gui_gtk_x11.c) */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
419 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
420 {VK_F22, 'F', 'C'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
421 {VK_F23, 'F', 'D'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
422 {VK_F24, 'F', 'E'}, /* winuser.h defines up to F24 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
423
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
424 {VK_HELP, '%', '1'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
425 {VK_BACK, 'k', 'b'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
426 {VK_INSERT, 'k', 'I'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
427 {VK_DELETE, 'k', 'D'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
428 {VK_HOME, 'k', 'h'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
429 {VK_END, '@', '7'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
430 {VK_PRIOR, 'k', 'P'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
431 {VK_NEXT, 'k', 'N'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
432 {VK_PRINT, '%', '9'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
433 {VK_ADD, 'K', '6'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
434 {VK_SUBTRACT, 'K', '7'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
435 {VK_DIVIDE, 'K', '8'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
436 {VK_MULTIPLY, 'K', '9'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
437 {VK_SEPARATOR, 'K', 'A'}, /* Keypad Enter */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
438 {VK_DECIMAL, 'K', 'B'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
439
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
440 {VK_NUMPAD0, 'K', 'C'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
441 {VK_NUMPAD1, 'K', 'D'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
442 {VK_NUMPAD2, 'K', 'E'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
443 {VK_NUMPAD3, 'K', 'F'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
444 {VK_NUMPAD4, 'K', 'G'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
445 {VK_NUMPAD5, 'K', 'H'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
446 {VK_NUMPAD6, 'K', 'I'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
447 {VK_NUMPAD7, 'K', 'J'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
448 {VK_NUMPAD8, 'K', 'K'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
449 {VK_NUMPAD9, 'K', 'L'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
450
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
451 /* Keys that we want to be able to use any modifier with: */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
452 {VK_SPACE, ' ', NUL},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
453 {VK_TAB, TAB, NUL},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
454 {VK_ESCAPE, ESC, NUL},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
455 {NL, NL, NUL},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
456 {CAR, CAR, NUL},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
457
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
458 /* End of list marker: */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
459 {0, 0, 0}
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
460 };
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
461
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
462 /* Local variables */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
463 static int s_button_pending = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
464
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
465 /* s_getting_focus is set when we got focus but didn't see mouse-up event yet,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
466 * so don't reset s_button_pending. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
467 static int s_getting_focus = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
468
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
469 static int s_x_pending;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
470 static int s_y_pending;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
471 static UINT s_kFlags_pending;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
472 static UINT s_wait_timer = 0; /* Timer for get char from user */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
473 static int s_timed_out = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
474 static int dead_key = 0; /* 0: no dead key, 1: dead key pressed */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
475
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
476 #ifdef FEAT_BEVAL
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
477 /* balloon-eval WM_NOTIFY_HANDLER */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
478 static void Handle_WM_Notify(HWND hwnd, LPNMHDR pnmh);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
479 static void TrackUserActivity(UINT uMsg);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
480 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
481
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
482 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
483 * For control IME.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
484 *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
485 * These LOGFONT used for IME.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
486 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
487 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
488 # ifdef USE_IM_CONTROL
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
489 /* holds LOGFONT for 'guifontwide' if available, otherwise 'guifont' */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
490 static LOGFONT norm_logfont;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
491 /* holds LOGFONT for 'guifont' always. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
492 static LOGFONT sub_logfont;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
493 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
494 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
495
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
496 #ifdef FEAT_MBYTE_IME
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
497 static LRESULT _OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
498 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
499
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
500 #if defined(FEAT_BROWSE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
501 static char_u *convert_filter(char_u *s);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
502 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
503
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
504 #ifdef DEBUG_PRINT_ERROR
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
505 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
506 * Print out the last Windows error message
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
507 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
508 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
509 print_windows_error(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
510 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
511 LPVOID lpMsgBuf;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
512
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
513 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
514 NULL, GetLastError(),
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
515 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
516 (LPTSTR) &lpMsgBuf, 0, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
517 TRACE1("Error: %s\n", lpMsgBuf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
518 LocalFree(lpMsgBuf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
519 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
520 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
521
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
522 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
523 * Cursor blink functions.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
524 *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
525 * This is a simple state machine:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
526 * BLINK_NONE not blinking at all
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
527 * BLINK_OFF blinking, cursor is not shown
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
528 * BLINK_ON blinking, cursor is shown
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
529 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
530
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
531 #define BLINK_NONE 0
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
532 #define BLINK_OFF 1
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
533 #define BLINK_ON 2
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
534
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
535 static int blink_state = BLINK_NONE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
536 static long_u blink_waittime = 700;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
537 static long_u blink_ontime = 400;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
538 static long_u blink_offtime = 250;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
539 static UINT blink_timer = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
540
9213
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9181
diff changeset
541 int
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9181
diff changeset
542 gui_mch_is_blinking(void)
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9181
diff changeset
543 {
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9181
diff changeset
544 return blink_state != BLINK_NONE;
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9181
diff changeset
545 }
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9181
diff changeset
546
9428
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9252
diff changeset
547 int
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9252
diff changeset
548 gui_mch_is_blink_off(void)
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9252
diff changeset
549 {
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9252
diff changeset
550 return blink_state == BLINK_OFF;
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9252
diff changeset
551 }
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9252
diff changeset
552
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
553 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
554 gui_mch_set_blinking(long wait, long on, long off)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
555 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
556 blink_waittime = wait;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
557 blink_ontime = on;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
558 blink_offtime = off;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
559 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
560
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
561 static VOID CALLBACK
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
562 _OnBlinkTimer(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
563 HWND hwnd,
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
564 UINT uMsg UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
565 UINT idEvent,
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
566 DWORD dwTime UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
567 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
568 MSG msg;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
569
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
570 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
571 TRACE2("Got timer event, id %d, blink_timer %d\n", idEvent, blink_timer);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
572 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
573
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
574 KillTimer(NULL, idEvent);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
575
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
576 /* Eat spurious WM_TIMER messages */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
577 while (pPeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
578 ;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
579
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
580 if (blink_state == BLINK_ON)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
581 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
582 gui_undraw_cursor();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
583 blink_state = BLINK_OFF;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
584 blink_timer = (UINT) SetTimer(NULL, 0, (UINT)blink_offtime,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
585 (TIMERPROC)_OnBlinkTimer);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
586 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
587 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
588 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
589 gui_update_cursor(TRUE, FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
590 blink_state = BLINK_ON;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
591 blink_timer = (UINT) SetTimer(NULL, 0, (UINT)blink_ontime,
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
592 (TIMERPROC)_OnBlinkTimer);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
593 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
594 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
595
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
596 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
597 gui_mswin_rm_blink_timer(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
598 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
599 MSG msg;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
600
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
601 if (blink_timer != 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
602 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
603 KillTimer(NULL, blink_timer);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
604 /* Eat spurious WM_TIMER messages */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
605 while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
606 ;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
607 blink_timer = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
608 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
609 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
610
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
611 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
612 * Stop the cursor blinking. Show the cursor if it wasn't shown.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
613 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
614 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
615 gui_mch_stop_blink(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
616 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
617 gui_mswin_rm_blink_timer();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
618 if (blink_state == BLINK_OFF)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
619 gui_update_cursor(TRUE, FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
620 blink_state = BLINK_NONE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
621 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
622
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
623 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
624 * Start the cursor blinking. If it was already blinking, this restarts the
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
625 * waiting time and shows the cursor.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
626 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
627 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
628 gui_mch_start_blink(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
629 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
630 gui_mswin_rm_blink_timer();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
631
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
632 /* Only switch blinking on if none of the times is zero */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
633 if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
634 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
635 blink_timer = (UINT)SetTimer(NULL, 0, (UINT)blink_waittime,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
636 (TIMERPROC)_OnBlinkTimer);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
637 blink_state = BLINK_ON;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
638 gui_update_cursor(TRUE, FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
639 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
640 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
641
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
642 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
643 * Call-back routines.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
644 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
645
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
646 static VOID CALLBACK
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
647 _OnTimer(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
648 HWND hwnd,
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
649 UINT uMsg UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
650 UINT idEvent,
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
651 DWORD dwTime UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
652 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
653 MSG msg;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
654
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
655 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
656 TRACE2("Got timer event, id %d, s_wait_timer %d\n", idEvent, s_wait_timer);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
657 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
658 KillTimer(NULL, idEvent);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
659 s_timed_out = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
660
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
661 /* Eat spurious WM_TIMER messages */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
662 while (pPeekMessage(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
663 ;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
664 if (idEvent == s_wait_timer)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
665 s_wait_timer = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
666 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
667
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
668 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
669 _OnDeadChar(
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
670 HWND hwnd UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
671 UINT ch UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
672 int cRepeat UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
673 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
674 dead_key = 1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
675 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
676
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
677 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
678 * Convert Unicode character "ch" to bytes in "string[slen]".
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
679 * When "had_alt" is TRUE the ALT key was included in "ch".
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
680 * Return the length.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
681 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
682 static int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
683 char_to_string(int ch, char_u *string, int slen, int had_alt)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
684 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
685 int len;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
686 int i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
687 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
688 WCHAR wstring[2];
9252
c25898cc99c1 commit https://github.com/vim/vim/commit/945ec093cd4ddefab930239990564b12eb232153
Christian Brabandt <cb@256bit.org>
parents: 9236
diff changeset
689 char_u *ws = NULL;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
690
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
691 wstring[0] = ch;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
692 len = 1;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
693
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
694 /* "ch" is a UTF-16 character. Convert it to a string of bytes. When
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
695 * "enc_codepage" is non-zero use the standard Win32 function,
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
696 * otherwise use our own conversion function (e.g., for UTF-8). */
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
697 if (enc_codepage > 0)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
698 {
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
699 len = WideCharToMultiByte(enc_codepage, 0, wstring, len,
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
700 (LPSTR)string, slen, 0, NULL);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
701 /* If we had included the ALT key into the character but now the
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
702 * upper bit is no longer set, that probably means the conversion
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
703 * failed. Convert the original character and set the upper bit
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
704 * afterwards. */
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
705 if (had_alt && len == 1 && ch >= 0x80 && string[0] < 0x80)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
706 {
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
707 wstring[0] = ch & 0x7f;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
708 len = WideCharToMultiByte(enc_codepage, 0, wstring, len,
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
709 (LPSTR)string, slen, 0, NULL);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
710 if (len == 1) /* safety check */
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
711 string[0] |= 0x80;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
712 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
713 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
714 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
715 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
716 len = 1;
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
717 ws = utf16_to_enc(wstring, &len);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
718 if (ws == NULL)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
719 len = 0;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
720 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
721 {
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
722 if (len > slen) /* just in case */
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
723 len = slen;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
724 mch_memmove(string, ws, len);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
725 vim_free(ws);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
726 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
727 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
728
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
729 if (len == 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
730 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
731 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
732 string[0] = ch;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
733 len = 1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
734 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
735
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
736 for (i = 0; i < len; ++i)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
737 if (string[i] == CSI && len <= slen - 2)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
738 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
739 /* Insert CSI as K_CSI. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
740 mch_memmove(string + i + 3, string + i + 1, len - i - 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
741 string[++i] = KS_EXTRA;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
742 string[++i] = (int)KE_CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
743 len += 2;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
744 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
745
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
746 return len;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
747 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
748
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
749 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
750 * Key hit, add it to the input buffer.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
751 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
752 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
753 _OnChar(
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
754 HWND hwnd UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
755 UINT ch,
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
756 int cRepeat UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
757 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
758 char_u string[40];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
759 int len = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
760
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
761 dead_key = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
762
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
763 len = char_to_string(ch, string, 40, FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
764 if (len == 1 && string[0] == Ctrl_C && ctrl_c_interrupts)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
765 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
766 trash_input_buf();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
767 got_int = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
768 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
769
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
770 add_to_input_buf(string, len);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
771 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
772
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
773 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
774 * Alt-Key hit, add it to the input buffer.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
775 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
776 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
777 _OnSysChar(
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
778 HWND hwnd UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
779 UINT cch,
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
780 int cRepeat UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
781 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
782 char_u string[40]; /* Enough for multibyte character */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
783 int len;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
784 int modifiers;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
785 int ch = cch; /* special keys are negative */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
786
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
787 dead_key = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
788
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
789 /* TRACE("OnSysChar(%d, %c)\n", ch, ch); */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
790
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
791 /* OK, we have a character key (given by ch) which was entered with the
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
792 * ALT key pressed. Eg, if the user presses Alt-A, then ch == 'A'. Note
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
793 * that the system distinguishes Alt-a and Alt-A (Alt-Shift-a unless
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
794 * CAPSLOCK is pressed) at this point.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
795 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
796 modifiers = MOD_MASK_ALT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
797 if (GetKeyState(VK_SHIFT) & 0x8000)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
798 modifiers |= MOD_MASK_SHIFT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
799 if (GetKeyState(VK_CONTROL) & 0x8000)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
800 modifiers |= MOD_MASK_CTRL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
801
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
802 ch = simplify_key(ch, &modifiers);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
803 /* remove the SHIFT modifier for keys where it's already included, e.g.,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
804 * '(' and '*' */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
805 if (ch < 0x100 && !isalpha(ch) && isprint(ch))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
806 modifiers &= ~MOD_MASK_SHIFT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
807
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
808 /* Interpret the ALT key as making the key META, include SHIFT, etc. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
809 ch = extract_modifiers(ch, &modifiers);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
810 if (ch == CSI)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
811 ch = K_CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
812
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
813 len = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
814 if (modifiers)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
815 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
816 string[len++] = CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
817 string[len++] = KS_MODIFIER;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
818 string[len++] = modifiers;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
819 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
820
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
821 if (IS_SPECIAL((int)ch))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
822 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
823 string[len++] = CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
824 string[len++] = K_SECOND((int)ch);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
825 string[len++] = K_THIRD((int)ch);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
826 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
827 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
828 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
829 /* Although the documentation isn't clear about it, we assume "ch" is
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
830 * a Unicode character. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
831 len += char_to_string(ch, string + len, 40 - len, TRUE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
832 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
833
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
834 add_to_input_buf(string, len);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
835 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
836
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
837 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
838 _OnMouseEvent(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
839 int button,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
840 int x,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
841 int y,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
842 int repeated_click,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
843 UINT keyFlags)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
844 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
845 int vim_modifiers = 0x0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
846
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
847 s_getting_focus = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
848
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
849 if (keyFlags & MK_SHIFT)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
850 vim_modifiers |= MOUSE_SHIFT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
851 if (keyFlags & MK_CONTROL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
852 vim_modifiers |= MOUSE_CTRL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
853 if (GetKeyState(VK_MENU) & 0x8000)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
854 vim_modifiers |= MOUSE_ALT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
855
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
856 gui_send_mouse_event(button, x, y, repeated_click, vim_modifiers);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
857 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
858
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
859 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
860 _OnMouseButtonDown(
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
861 HWND hwnd UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
862 BOOL fDoubleClick UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
863 int x,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
864 int y,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
865 UINT keyFlags)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
866 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
867 static LONG s_prevTime = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
868
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
869 LONG currentTime = GetMessageTime();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
870 int button = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
871 int repeated_click;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
872
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
873 /* Give main window the focus: this is so the cursor isn't hollow. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
874 (void)SetFocus(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
875
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
876 if (s_uMsg == WM_LBUTTONDOWN || s_uMsg == WM_LBUTTONDBLCLK)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
877 button = MOUSE_LEFT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
878 else if (s_uMsg == WM_MBUTTONDOWN || s_uMsg == WM_MBUTTONDBLCLK)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
879 button = MOUSE_MIDDLE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
880 else if (s_uMsg == WM_RBUTTONDOWN || s_uMsg == WM_RBUTTONDBLCLK)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
881 button = MOUSE_RIGHT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
882 else if (s_uMsg == WM_XBUTTONDOWN || s_uMsg == WM_XBUTTONDBLCLK)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
883 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
884 #ifndef GET_XBUTTON_WPARAM
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
885 # define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
886 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
887 button = ((GET_XBUTTON_WPARAM(s_wParam) == 1) ? MOUSE_X1 : MOUSE_X2);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
888 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
889 else if (s_uMsg == WM_CAPTURECHANGED)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
890 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
891 /* on W95/NT4, somehow you get in here with an odd Msg
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
892 * if you press one button while holding down the other..*/
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
893 if (s_button_pending == MOUSE_LEFT)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
894 button = MOUSE_RIGHT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
895 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
896 button = MOUSE_LEFT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
897 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
898 if (button >= 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
899 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
900 repeated_click = ((int)(currentTime - s_prevTime) < p_mouset);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
901
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
902 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
903 * Holding down the left and right buttons simulates pushing the middle
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
904 * button.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
905 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
906 if (repeated_click
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
907 && ((button == MOUSE_LEFT && s_button_pending == MOUSE_RIGHT)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
908 || (button == MOUSE_RIGHT
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
909 && s_button_pending == MOUSE_LEFT)))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
910 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
911 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
912 * Hmm, gui.c will ignore more than one button down at a time, so
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
913 * pretend we let go of it first.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
914 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
915 gui_send_mouse_event(MOUSE_RELEASE, x, y, FALSE, 0x0);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
916 button = MOUSE_MIDDLE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
917 repeated_click = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
918 s_button_pending = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
919 _OnMouseEvent(button, x, y, repeated_click, keyFlags);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
920 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
921 else if ((repeated_click)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
922 || (mouse_model_popup() && (button == MOUSE_RIGHT)))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
923 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
924 if (s_button_pending > -1)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
925 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
926 _OnMouseEvent(s_button_pending, x, y, FALSE, keyFlags);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
927 s_button_pending = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
928 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
929 /* TRACE("Button down at x %d, y %d\n", x, y); */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
930 _OnMouseEvent(button, x, y, repeated_click, keyFlags);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
931 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
932 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
933 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
934 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
935 * If this is the first press (i.e. not a multiple click) don't
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
936 * action immediately, but store and wait for:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
937 * i) button-up
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
938 * ii) mouse move
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
939 * iii) another button press
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
940 * before using it.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
941 * This enables us to make left+right simulate middle button,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
942 * without left or right being actioned first. The side-effect is
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
943 * that if you click and hold the mouse without dragging, the
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
944 * cursor doesn't move until you release the button. In practice
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
945 * this is hardly a problem.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
946 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
947 s_button_pending = button;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
948 s_x_pending = x;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
949 s_y_pending = y;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
950 s_kFlags_pending = keyFlags;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
951 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
952
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
953 s_prevTime = currentTime;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
954 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
955 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
956
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
957 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
958 _OnMouseMoveOrRelease(
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
959 HWND hwnd UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
960 int x,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
961 int y,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
962 UINT keyFlags)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
963 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
964 int button;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
965
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
966 s_getting_focus = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
967 if (s_button_pending > -1)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
968 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
969 /* Delayed action for mouse down event */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
970 _OnMouseEvent(s_button_pending, s_x_pending,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
971 s_y_pending, FALSE, s_kFlags_pending);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
972 s_button_pending = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
973 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
974 if (s_uMsg == WM_MOUSEMOVE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
975 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
976 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
977 * It's only a MOUSE_DRAG if one or more mouse buttons are being held
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
978 * down.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
979 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
980 if (!(keyFlags & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
981 | MK_XBUTTON1 | MK_XBUTTON2)))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
982 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
983 gui_mouse_moved(x, y);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
984 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
985 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
986
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
987 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
988 * While button is down, keep grabbing mouse move events when
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
989 * the mouse goes outside the window
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
990 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
991 SetCapture(s_textArea);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
992 button = MOUSE_DRAG;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
993 /* TRACE(" move at x %d, y %d\n", x, y); */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
994 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
995 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
996 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
997 ReleaseCapture();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
998 button = MOUSE_RELEASE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
999 /* TRACE(" up at x %d, y %d\n", x, y); */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1000 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1001
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1002 _OnMouseEvent(button, x, y, FALSE, keyFlags);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1003 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1004
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1005 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1006 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1007 * Find the vimmenu_T with the given id
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1008 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1009 static vimmenu_T *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1010 gui_mswin_find_menu(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1011 vimmenu_T *pMenu,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1012 int id)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1013 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1014 vimmenu_T *pChildMenu;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1015
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1016 while (pMenu)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1017 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1018 if (pMenu->id == (UINT)id)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1019 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1020 if (pMenu->children != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1021 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1022 pChildMenu = gui_mswin_find_menu(pMenu->children, id);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1023 if (pChildMenu)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1024 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1025 pMenu = pChildMenu;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1026 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1027 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1028 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1029 pMenu = pMenu->next;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1030 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1031 return pMenu;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1032 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1033
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1034 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1035 _OnMenu(
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
1036 HWND hwnd UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1037 int id,
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
1038 HWND hwndCtl UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
1039 UINT codeNotify UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1040 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1041 vimmenu_T *pMenu;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1042
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1043 pMenu = gui_mswin_find_menu(root_menu, id);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1044 if (pMenu)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1045 gui_menu_cb(pMenu);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1046 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1047 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1048
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1049 #ifdef MSWIN_FIND_REPLACE
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1050 # ifdef FEAT_MBYTE
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1051 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1052 * copy useful data from structure LPFINDREPLACE to structure LPFINDREPLACEW
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1053 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1054 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1055 findrep_atow(LPFINDREPLACEW lpfrw, LPFINDREPLACE lpfr)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1056 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1057 WCHAR *wp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1058
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1059 lpfrw->hwndOwner = lpfr->hwndOwner;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1060 lpfrw->Flags = lpfr->Flags;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1061
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1062 wp = enc_to_utf16((char_u *)lpfr->lpstrFindWhat, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1063 wcsncpy(lpfrw->lpstrFindWhat, wp, lpfrw->wFindWhatLen - 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1064 vim_free(wp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1065
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1066 /* the field "lpstrReplaceWith" doesn't need to be copied */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1067 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1068
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1069 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1070 * copy useful data from structure LPFINDREPLACEW to structure LPFINDREPLACE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1071 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1072 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1073 findrep_wtoa(LPFINDREPLACE lpfr, LPFINDREPLACEW lpfrw)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1074 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1075 char_u *p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1076
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1077 lpfr->Flags = lpfrw->Flags;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1078
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1079 p = utf16_to_enc((short_u*)lpfrw->lpstrFindWhat, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1080 vim_strncpy((char_u *)lpfr->lpstrFindWhat, p, lpfr->wFindWhatLen - 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1081 vim_free(p);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1082
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1083 p = utf16_to_enc((short_u*)lpfrw->lpstrReplaceWith, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1084 vim_strncpy((char_u *)lpfr->lpstrReplaceWith, p, lpfr->wReplaceWithLen - 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1085 vim_free(p);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1086 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1087 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1088
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1089 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1090 * Handle a Find/Replace window message.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1091 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1092 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1093 _OnFindRepl(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1094 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1095 int flags = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1096 int down;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1097
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1098 # ifdef FEAT_MBYTE
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1099 /* If the OS is Windows NT, and 'encoding' differs from active codepage:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1100 * convert text from wide string. */
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1101 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1102 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1103 findrep_wtoa(&s_findrep_struct, &s_findrep_struct_w);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1104 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1105 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1106
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1107 if (s_findrep_struct.Flags & FR_DIALOGTERM)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1108 /* Give main window the focus back. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1109 (void)SetFocus(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1110
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1111 if (s_findrep_struct.Flags & FR_FINDNEXT)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1112 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1113 flags = FRD_FINDNEXT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1114
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1115 /* Give main window the focus back: this is so the cursor isn't
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1116 * hollow. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1117 (void)SetFocus(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1118 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1119 else if (s_findrep_struct.Flags & FR_REPLACE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1120 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1121 flags = FRD_REPLACE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1122
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1123 /* Give main window the focus back: this is so the cursor isn't
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1124 * hollow. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1125 (void)SetFocus(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1126 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1127 else if (s_findrep_struct.Flags & FR_REPLACEALL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1128 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1129 flags = FRD_REPLACEALL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1130 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1131
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1132 if (flags != 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1133 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1134 /* Call the generic GUI function to do the actual work. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1135 if (s_findrep_struct.Flags & FR_WHOLEWORD)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1136 flags |= FRD_WHOLE_WORD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1137 if (s_findrep_struct.Flags & FR_MATCHCASE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1138 flags |= FRD_MATCH_CASE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1139 down = (s_findrep_struct.Flags & FR_DOWN) != 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1140 gui_do_findrepl(flags, (char_u *)s_findrep_struct.lpstrFindWhat,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1141 (char_u *)s_findrep_struct.lpstrReplaceWith, down);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1142 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1143 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1144 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1145
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1146 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1147 HandleMouseHide(UINT uMsg, LPARAM lParam)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1148 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1149 static LPARAM last_lParam = 0L;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1150
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1151 /* We sometimes get a mousemove when the mouse didn't move... */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1152 if (uMsg == WM_MOUSEMOVE || uMsg == WM_NCMOUSEMOVE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1153 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1154 if (lParam == last_lParam)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1155 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1156 last_lParam = lParam;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1157 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1158
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1159 /* Handle specially, to centralise coding. We need to be sure we catch all
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1160 * possible events which should cause us to restore the cursor (as it is a
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1161 * shared resource, we take full responsibility for it).
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1162 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1163 switch (uMsg)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1164 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1165 case WM_KEYUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1166 case WM_CHAR:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1167 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1168 * blank out the pointer if necessary
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1169 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1170 if (p_mh)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1171 gui_mch_mousehide(TRUE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1172 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1173
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1174 case WM_SYSKEYUP: /* show the pointer when a system-key is pressed */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1175 case WM_SYSCHAR:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1176 case WM_MOUSEMOVE: /* show the pointer on any mouse action */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1177 case WM_LBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1178 case WM_LBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1179 case WM_MBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1180 case WM_MBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1181 case WM_RBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1182 case WM_RBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1183 case WM_XBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1184 case WM_XBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1185 case WM_NCMOUSEMOVE:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1186 case WM_NCLBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1187 case WM_NCLBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1188 case WM_NCMBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1189 case WM_NCMBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1190 case WM_NCRBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1191 case WM_NCRBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1192 case WM_KILLFOCUS:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1193 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1194 * if the pointer is currently hidden, then we should show it.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1195 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1196 gui_mch_mousehide(FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1197 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1198 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1199 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1200
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1201 static LRESULT CALLBACK
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1202 _TextAreaWndProc(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1203 HWND hwnd,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1204 UINT uMsg,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1205 WPARAM wParam,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1206 LPARAM lParam)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1207 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1208 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1209 TRACE("TextAreaWndProc: hwnd = %08x, msg = %x, wParam = %x, lParam = %x\n",
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1210 hwnd, uMsg, wParam, lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1211 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1212
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1213 HandleMouseHide(uMsg, lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1214
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1215 s_uMsg = uMsg;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1216 s_wParam = wParam;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1217 s_lParam = lParam;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1218
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1219 #ifdef FEAT_BEVAL
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1220 TrackUserActivity(uMsg);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1221 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1222
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1223 switch (uMsg)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1224 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1225 HANDLE_MSG(hwnd, WM_LBUTTONDBLCLK,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1226 HANDLE_MSG(hwnd, WM_LBUTTONDOWN,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1227 HANDLE_MSG(hwnd, WM_LBUTTONUP, _OnMouseMoveOrRelease);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1228 HANDLE_MSG(hwnd, WM_MBUTTONDBLCLK,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1229 HANDLE_MSG(hwnd, WM_MBUTTONDOWN,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1230 HANDLE_MSG(hwnd, WM_MBUTTONUP, _OnMouseMoveOrRelease);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1231 HANDLE_MSG(hwnd, WM_MOUSEMOVE, _OnMouseMoveOrRelease);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1232 HANDLE_MSG(hwnd, WM_PAINT, _OnPaint);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1233 HANDLE_MSG(hwnd, WM_RBUTTONDBLCLK,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1234 HANDLE_MSG(hwnd, WM_RBUTTONDOWN,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1235 HANDLE_MSG(hwnd, WM_RBUTTONUP, _OnMouseMoveOrRelease);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1236 HANDLE_MSG(hwnd, WM_XBUTTONDBLCLK,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1237 HANDLE_MSG(hwnd, WM_XBUTTONDOWN,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1238 HANDLE_MSG(hwnd, WM_XBUTTONUP, _OnMouseMoveOrRelease);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1239
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1240 #ifdef FEAT_BEVAL
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1241 case WM_NOTIFY: Handle_WM_Notify(hwnd, (LPNMHDR)lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1242 return TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1243 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1244 default:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1245 return MyWindowProc(hwnd, uMsg, wParam, lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1246 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1247 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1248
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1249 #if defined(FEAT_MBYTE) \
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1250 || defined(GLOBAL_IME) \
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1251 || defined(PROTO)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1252 # ifdef PROTO
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1253 typedef int WINAPI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1254 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1255
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1256 LRESULT WINAPI
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1257 vim_WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1258 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1259 # ifdef GLOBAL_IME
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1260 return global_ime_DefWindowProc(hwnd, message, wParam, lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1261 # else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1262 if (wide_WindowProc)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1263 return DefWindowProcW(hwnd, message, wParam, lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1264 return DefWindowProc(hwnd, message, wParam, lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1265 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1266 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1267 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1268
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1269 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1270 * Called when the foreground or background color has been changed.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1271 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1272 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1273 gui_mch_new_colors(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1274 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1275 /* nothing to do? */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1276 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1277
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1278 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1279 * Set the colors to their default values.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1280 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1281 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1282 gui_mch_def_colors(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1283 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1284 gui.norm_pixel = GetSysColor(COLOR_WINDOWTEXT);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1285 gui.back_pixel = GetSysColor(COLOR_WINDOW);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1286 gui.def_norm_pixel = gui.norm_pixel;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1287 gui.def_back_pixel = gui.back_pixel;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1288 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1289
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1290 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1291 * Open the GUI window which was created by a call to gui_mch_init().
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1292 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1293 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1294 gui_mch_open(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1295 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1296 #ifndef SW_SHOWDEFAULT
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1297 # define SW_SHOWDEFAULT 10 /* Borland 5.0 doesn't have it */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1298 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1299 /* Actually open the window, if not already visible
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1300 * (may be done already in gui_mch_set_shellsize) */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1301 if (!IsWindowVisible(s_hwnd))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1302 ShowWindow(s_hwnd, SW_SHOWDEFAULT);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1303
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1304 #ifdef MSWIN_FIND_REPLACE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1305 /* Init replace string here, so that we keep it when re-opening the
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1306 * dialog. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1307 s_findrep_struct.lpstrReplaceWith[0] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1308 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1309
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1310 return OK;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1311 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1312
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1313 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1314 * Get the position of the top left corner of the window.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1315 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1316 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1317 gui_mch_get_winpos(int *x, int *y)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1318 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1319 RECT rect;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1320
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1321 GetWindowRect(s_hwnd, &rect);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1322 *x = rect.left;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1323 *y = rect.top;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1324 return OK;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1325 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1326
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1327 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1328 * Set the position of the top left corner of the window to the given
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1329 * coordinates.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1330 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1331 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1332 gui_mch_set_winpos(int x, int y)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1333 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1334 SetWindowPos(s_hwnd, NULL, x, y, 0, 0,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1335 SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1336 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1337 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1338 gui_mch_set_text_area_pos(int x, int y, int w, int h)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1339 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1340 static int oldx = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1341 static int oldy = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1342
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1343 SetWindowPos(s_textArea, NULL, x, y, w, h, SWP_NOZORDER | SWP_NOACTIVATE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1344
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1345 #ifdef FEAT_TOOLBAR
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1346 if (vim_strchr(p_go, GO_TOOLBAR) != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1347 SendMessage(s_toolbarhwnd, WM_SIZE,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1348 (WPARAM)0, (LPARAM)(w + ((long)(TOOLBAR_BUTTON_HEIGHT+8)<<16)));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1349 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1350 #if defined(FEAT_GUI_TABLINE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1351 if (showing_tabline)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1352 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1353 int top = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1354 RECT rect;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1355
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1356 # ifdef FEAT_TOOLBAR
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1357 if (vim_strchr(p_go, GO_TOOLBAR) != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1358 top = TOOLBAR_BUTTON_HEIGHT + TOOLBAR_BORDER_HEIGHT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1359 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1360 GetClientRect(s_hwnd, &rect);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1361 MoveWindow(s_tabhwnd, 0, top, rect.right, gui.tabline_height, TRUE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1362 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1363 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1364
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1365 /* When side scroll bar is unshown, the size of window will change.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1366 * then, the text area move left or right. thus client rect should be
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1367 * forcedly redrawn. (Yasuhiro Matsumoto) */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1368 if (oldx != x || oldy != y)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1369 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1370 InvalidateRect(s_hwnd, NULL, FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1371 oldx = x;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1372 oldy = y;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1373 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1374 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1375
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1376
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1377 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1378 * Scrollbar stuff:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1379 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1380
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1381 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1382 gui_mch_enable_scrollbar(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1383 scrollbar_T *sb,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1384 int flag)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1385 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1386 ShowScrollBar(sb->id, SB_CTL, flag);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1387
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1388 /* TODO: When the window is maximized, the size of the window stays the
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1389 * same, thus the size of the text area changes. On Win98 it's OK, on Win
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1390 * NT 4.0 it's not... */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1391 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1392
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1393 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1394 gui_mch_set_scrollbar_pos(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1395 scrollbar_T *sb,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1396 int x,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1397 int y,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1398 int w,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1399 int h)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1400 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1401 SetWindowPos(sb->id, NULL, x, y, w, h,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1402 SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1403 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1404
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1405 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1406 gui_mch_create_scrollbar(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1407 scrollbar_T *sb,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1408 int orient) /* SBAR_VERT or SBAR_HORIZ */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1409 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1410 sb->id = CreateWindow(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1411 "SCROLLBAR", "Scrollbar",
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1412 WS_CHILD | ((orient == SBAR_VERT) ? SBS_VERT : SBS_HORZ), 0, 0,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1413 10, /* Any value will do for now */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1414 10, /* Any value will do for now */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1415 s_hwnd, NULL,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1416 s_hinst, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1417 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1418
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1419 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1420 * Find the scrollbar with the given hwnd.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1421 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1422 static scrollbar_T *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1423 gui_mswin_find_scrollbar(HWND hwnd)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1424 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1425 win_T *wp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1426
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1427 if (gui.bottom_sbar.id == hwnd)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1428 return &gui.bottom_sbar;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1429 FOR_ALL_WINDOWS(wp)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1430 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1431 if (wp->w_scrollbars[SBAR_LEFT].id == hwnd)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1432 return &wp->w_scrollbars[SBAR_LEFT];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1433 if (wp->w_scrollbars[SBAR_RIGHT].id == hwnd)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1434 return &wp->w_scrollbars[SBAR_RIGHT];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1435 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1436 return NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1437 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1438
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1439 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1440 * Get the character size of a font.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1441 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1442 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1443 GetFontSize(GuiFont font)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1444 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1445 HWND hwnd = GetDesktopWindow();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1446 HDC hdc = GetWindowDC(hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1447 HFONT hfntOld = SelectFont(hdc, (HFONT)font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1448 TEXTMETRIC tm;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1449
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1450 GetTextMetrics(hdc, &tm);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1451 gui.char_width = tm.tmAveCharWidth + tm.tmOverhang;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1452
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1453 gui.char_height = tm.tmHeight + p_linespace;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1454
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1455 SelectFont(hdc, hfntOld);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1456
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1457 ReleaseDC(hwnd, hdc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1458 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1459
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1460 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1461 * Adjust gui.char_height (after 'linespace' was changed).
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1462 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1463 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1464 gui_mch_adjust_charheight(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1465 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1466 GetFontSize(gui.norm_font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1467 return OK;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1468 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1469
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1470 static GuiFont
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1471 get_font_handle(LOGFONT *lf)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1472 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1473 HFONT font = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1474
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1475 /* Load the font */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1476 font = CreateFontIndirect(lf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1477
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1478 if (font == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1479 return NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1480
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1481 return (GuiFont)font;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1482 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1483
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1484 static int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1485 pixels_to_points(int pixels, int vertical)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1486 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1487 int points;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1488 HWND hwnd;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1489 HDC hdc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1490
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1491 hwnd = GetDesktopWindow();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1492 hdc = GetWindowDC(hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1493
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1494 points = MulDiv(pixels, 72,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1495 GetDeviceCaps(hdc, vertical ? LOGPIXELSY : LOGPIXELSX));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1496
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1497 ReleaseDC(hwnd, hdc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1498
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1499 return points;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1500 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1501
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1502 GuiFont
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1503 gui_mch_get_font(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1504 char_u *name,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1505 int giveErrorIfMissing)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1506 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1507 LOGFONT lf;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1508 GuiFont font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1509
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1510 if (get_logfont(&lf, name, NULL, giveErrorIfMissing) == OK)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1511 font = get_font_handle(&lf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1512 if (font == NOFONT && giveErrorIfMissing)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1513 EMSG2(_(e_font), name);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1514 return font;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1515 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1516
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1517 #if defined(FEAT_EVAL) || defined(PROTO)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1518 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1519 * Return the name of font "font" in allocated memory.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1520 * Don't know how to get the actual name, thus use the provided name.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1521 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1522 char_u *
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
1523 gui_mch_get_fontname(GuiFont font UNUSED, char_u *name)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1524 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1525 if (name == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1526 return NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1527 return vim_strsave(name);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1528 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1529 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1530
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1531 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1532 gui_mch_free_font(GuiFont font)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1533 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1534 if (font)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1535 DeleteObject((HFONT)font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1536 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1537
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1538 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1539 * Return the Pixel value (color) for the given color name.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1540 * Return INVALCOLOR for error.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1541 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1542 guicolor_T
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1543 gui_mch_get_color(char_u *name)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1544 {
9017
7b1200ea03a1 commit https://github.com/vim/vim/commit/c285fe7c3ffdb3ec4eff20a1d1d5accfc80f1a86
Christian Brabandt <cb@256bit.org>
parents: 9013
diff changeset
1545 int i;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1546
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1547 typedef struct SysColorTable
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1548 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1549 char *name;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1550 int color;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1551 } SysColorTable;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1552
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1553 static SysColorTable sys_table[] =
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1554 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1555 {"SYS_3DDKSHADOW", COLOR_3DDKSHADOW},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1556 {"SYS_3DHILIGHT", COLOR_3DHILIGHT},
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1557 #ifdef COLOR_3DHIGHLIGHT
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1558 {"SYS_3DHIGHLIGHT", COLOR_3DHIGHLIGHT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1559 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1560 {"SYS_BTNHILIGHT", COLOR_BTNHILIGHT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1561 {"SYS_BTNHIGHLIGHT", COLOR_BTNHIGHLIGHT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1562 {"SYS_3DLIGHT", COLOR_3DLIGHT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1563 {"SYS_3DSHADOW", COLOR_3DSHADOW},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1564 {"SYS_DESKTOP", COLOR_DESKTOP},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1565 {"SYS_INFOBK", COLOR_INFOBK},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1566 {"SYS_INFOTEXT", COLOR_INFOTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1567 {"SYS_3DFACE", COLOR_3DFACE},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1568 {"SYS_BTNFACE", COLOR_BTNFACE},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1569 {"SYS_BTNSHADOW", COLOR_BTNSHADOW},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1570 {"SYS_ACTIVEBORDER", COLOR_ACTIVEBORDER},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1571 {"SYS_ACTIVECAPTION", COLOR_ACTIVECAPTION},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1572 {"SYS_APPWORKSPACE", COLOR_APPWORKSPACE},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1573 {"SYS_BACKGROUND", COLOR_BACKGROUND},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1574 {"SYS_BTNTEXT", COLOR_BTNTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1575 {"SYS_CAPTIONTEXT", COLOR_CAPTIONTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1576 {"SYS_GRAYTEXT", COLOR_GRAYTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1577 {"SYS_HIGHLIGHT", COLOR_HIGHLIGHT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1578 {"SYS_HIGHLIGHTTEXT", COLOR_HIGHLIGHTTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1579 {"SYS_INACTIVEBORDER", COLOR_INACTIVEBORDER},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1580 {"SYS_INACTIVECAPTION", COLOR_INACTIVECAPTION},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1581 {"SYS_INACTIVECAPTIONTEXT", COLOR_INACTIVECAPTIONTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1582 {"SYS_MENU", COLOR_MENU},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1583 {"SYS_MENUTEXT", COLOR_MENUTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1584 {"SYS_SCROLLBAR", COLOR_SCROLLBAR},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1585 {"SYS_WINDOW", COLOR_WINDOW},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1586 {"SYS_WINDOWFRAME", COLOR_WINDOWFRAME},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1587 {"SYS_WINDOWTEXT", COLOR_WINDOWTEXT}
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1588 };
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1589
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1590 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1591 * Try to look up a system colour.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1592 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1593 for (i = 0; i < sizeof(sys_table) / sizeof(sys_table[0]); i++)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1594 if (STRICMP(name, sys_table[i].name) == 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1595 return GetSysColor(sys_table[i].color);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1596
9013
22c29a515b53 commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents: 8835
diff changeset
1597 return gui_get_color_cmn(name);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1598 }
9017
7b1200ea03a1 commit https://github.com/vim/vim/commit/c285fe7c3ffdb3ec4eff20a1d1d5accfc80f1a86
Christian Brabandt <cb@256bit.org>
parents: 9013
diff changeset
1599
11745
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11410
diff changeset
1600 guicolor_T
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11410
diff changeset
1601 gui_mch_get_rgb_color(int r, int g, int b)
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11410
diff changeset
1602 {
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11410
diff changeset
1603 return gui_get_rgb_color_cmn(r, g, b);
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11410
diff changeset
1604 }
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11410
diff changeset
1605
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1606 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1607 * Return OK if the key with the termcap name "name" is supported.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1608 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1609 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1610 gui_mch_haskey(char_u *name)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1611 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1612 int i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1613
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1614 for (i = 0; special_keys[i].vim_code1 != NUL; i++)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1615 if (name[0] == special_keys[i].vim_code0 &&
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1616 name[1] == special_keys[i].vim_code1)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1617 return OK;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1618 return FAIL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1619 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1620
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1621 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1622 gui_mch_beep(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1623 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1624 MessageBeep(MB_OK);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1625 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1626 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1627 * Invert a rectangle from row r, column c, for nr rows and nc columns.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1628 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1629 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1630 gui_mch_invert_rectangle(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1631 int r,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1632 int c,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1633 int nr,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1634 int nc)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1635 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1636 RECT rc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1637
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1638 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1639 * Note: InvertRect() excludes right and bottom of rectangle.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1640 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1641 rc.left = FILL_X(c);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1642 rc.top = FILL_Y(r);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1643 rc.right = rc.left + nc * gui.char_width;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1644 rc.bottom = rc.top + nr * gui.char_height;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1645 InvertRect(s_hdc, &rc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1646 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1647
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1648 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1649 * Iconify the GUI window.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1650 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1651 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1652 gui_mch_iconify(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1653 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1654 ShowWindow(s_hwnd, SW_MINIMIZE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1655 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1656
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1657 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1658 * Draw a cursor without focus.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1659 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1660 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1661 gui_mch_draw_hollow_cursor(guicolor_T color)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1662 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1663 HBRUSH hbr;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1664 RECT rc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1665
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1666 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1667 * Note: FrameRect() excludes right and bottom of rectangle.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1668 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1669 rc.left = FILL_X(gui.col);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1670 rc.top = FILL_Y(gui.row);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1671 rc.right = rc.left + gui.char_width;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1672 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1673 if (mb_lefthalve(gui.row, gui.col))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1674 rc.right += gui.char_width;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1675 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1676 rc.bottom = rc.top + gui.char_height;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1677 hbr = CreateSolidBrush(color);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1678 FrameRect(s_hdc, &rc, hbr);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1679 DeleteBrush(hbr);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1680 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1681 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1682 * Draw part of a cursor, "w" pixels wide, and "h" pixels high, using
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1683 * color "color".
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1684 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1685 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1686 gui_mch_draw_part_cursor(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1687 int w,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1688 int h,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1689 guicolor_T color)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1690 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1691 HBRUSH hbr;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1692 RECT rc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1693
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1694 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1695 * Note: FillRect() excludes right and bottom of rectangle.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1696 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1697 rc.left =
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1698 #ifdef FEAT_RIGHTLEFT
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1699 /* vertical line should be on the right of current point */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1700 CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w :
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1701 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1702 FILL_X(gui.col);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1703 rc.top = FILL_Y(gui.row) + gui.char_height - h;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1704 rc.right = rc.left + w;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1705 rc.bottom = rc.top + h;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1706 hbr = CreateSolidBrush(color);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1707 FillRect(s_hdc, &rc, hbr);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1708 DeleteBrush(hbr);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1709 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1710
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1711
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1712 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1713 * Generates a VK_SPACE when the internal dead_key flag is set to output the
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1714 * dead key's nominal character and re-post the original message.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1715 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1716 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1717 outputDeadKey_rePost(MSG originalMsg)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1718 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1719 static MSG deadCharExpel;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1720
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1721 if (!dead_key)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1722 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1723
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1724 dead_key = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1725
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1726 /* Make Windows generate the dead key's character */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1727 deadCharExpel.message = originalMsg.message;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1728 deadCharExpel.hwnd = originalMsg.hwnd;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1729 deadCharExpel.wParam = VK_SPACE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1730
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1731 MyTranslateMessage(&deadCharExpel);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1732
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1733 /* re-generate the current character free of the dead char influence */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1734 PostMessage(originalMsg.hwnd, originalMsg.message, originalMsg.wParam,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1735 originalMsg.lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1736 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1737
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1738
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1739 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1740 * Process a single Windows message.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1741 * If one is not available we hang until one is.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1742 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1743 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1744 process_message(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1745 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1746 MSG msg;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1747 UINT vk = 0; /* Virtual key */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1748 char_u string[40];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1749 int i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1750 int modifiers = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1751 int key;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1752 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1753 static char_u k10[] = {K_SPECIAL, 'k', ';', 0};
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1754 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1755
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1756 pGetMessage(&msg, NULL, 0, 0);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1757
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1758 #ifdef FEAT_OLE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1759 /* Look after OLE Automation commands */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1760 if (msg.message == WM_OLE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1761 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1762 char_u *str = (char_u *)msg.lParam;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1763 if (str == NULL || *str == NUL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1764 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1765 /* Message can't be ours, forward it. Fixes problem with Ultramon
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1766 * 3.0.4 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1767 pDispatchMessage(&msg);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1768 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1769 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1770 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1771 add_to_input_buf(str, (int)STRLEN(str));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1772 vim_free(str); /* was allocated in CVim::SendKeys() */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1773 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1774 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1775 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1776 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1777
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1778 #ifdef MSWIN_FIND_REPLACE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1779 /* Don't process messages used by the dialog */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1780 if (s_findrep_hwnd != NULL && pIsDialogMessage(s_findrep_hwnd, &msg))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1781 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1782 HandleMouseHide(msg.message, msg.lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1783 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1784 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1785 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1786
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1787 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1788 * Check if it's a special key that we recognise. If not, call
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1789 * TranslateMessage().
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1790 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1791 if (msg.message == WM_KEYDOWN || msg.message == WM_SYSKEYDOWN)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1792 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1793 vk = (int) msg.wParam;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1794
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1795 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1796 * Handle dead keys in special conditions in other cases we let Windows
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1797 * handle them and do not interfere.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1798 *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1799 * The dead_key flag must be reset on several occasions:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1800 * - in _OnChar() (or _OnSysChar()) as any dead key was necessarily
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1801 * consumed at that point (This is when we let Windows combine the
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1802 * dead character on its own)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1803 *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1804 * - Before doing something special such as regenerating keypresses to
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1805 * expel the dead character as this could trigger an infinite loop if
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1806 * for some reason MyTranslateMessage() do not trigger a call
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1807 * immediately to _OnChar() (or _OnSysChar()).
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1808 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1809 if (dead_key)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1810 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1811 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1812 * If a dead key was pressed and the user presses VK_SPACE,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1813 * VK_BACK, or VK_ESCAPE it means that he actually wants to deal
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1814 * with the dead char now, so do nothing special and let Windows
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1815 * handle it.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1816 *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1817 * Note that VK_SPACE combines with the dead_key's character and
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1818 * only one WM_CHAR will be generated by TranslateMessage(), in
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1819 * the two other cases two WM_CHAR will be generated: the dead
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1820 * char and VK_BACK or VK_ESCAPE. That is most likely what the
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1821 * user expects.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1822 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1823 if ((vk == VK_SPACE || vk == VK_BACK || vk == VK_ESCAPE))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1824 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1825 dead_key = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1826 MyTranslateMessage(&msg);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1827 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1828 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1829 /* In modes where we are not typing, dead keys should behave
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1830 * normally */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1831 else if (!(get_real_state() & (INSERT | CMDLINE | SELECTMODE)))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1832 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1833 outputDeadKey_rePost(msg);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1834 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1835 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1836 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1837
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1838 /* Check for CTRL-BREAK */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1839 if (vk == VK_CANCEL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1840 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1841 trash_input_buf();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1842 got_int = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1843 string[0] = Ctrl_C;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1844 add_to_input_buf(string, 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1845 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1846
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1847 for (i = 0; special_keys[i].key_sym != 0; i++)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1848 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1849 /* ignore VK_SPACE when ALT key pressed: system menu */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1850 if (special_keys[i].key_sym == vk
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1851 && (vk != VK_SPACE || !(GetKeyState(VK_MENU) & 0x8000)))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1852 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1853 /*
9252
c25898cc99c1 commit https://github.com/vim/vim/commit/945ec093cd4ddefab930239990564b12eb232153
Christian Brabandt <cb@256bit.org>
parents: 9236
diff changeset
1854 * Behave as expected if we have a dead key and the special key
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1855 * is a key that would normally trigger the dead key nominal
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1856 * character output (such as a NUMPAD printable character or
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1857 * the TAB key, etc...).
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1858 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1859 if (dead_key && (special_keys[i].vim_code0 == 'K'
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1860 || vk == VK_TAB || vk == CAR))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1861 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1862 outputDeadKey_rePost(msg);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1863 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1864 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1865
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1866 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1867 /* Check for <F10>: Windows selects the menu. When <F10> is
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1868 * mapped we want to use the mapping instead. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1869 if (vk == VK_F10
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1870 && gui.menu_is_active
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1871 && check_map(k10, State, FALSE, TRUE, FALSE,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1872 NULL, NULL) == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1873 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1874 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1875 if (GetKeyState(VK_SHIFT) & 0x8000)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1876 modifiers |= MOD_MASK_SHIFT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1877 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1878 * Don't use caps-lock as shift, because these are special keys
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1879 * being considered here, and we only want letters to get
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1880 * shifted -- webb
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1881 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1882 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1883 if (GetKeyState(VK_CAPITAL) & 0x0001)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1884 modifiers ^= MOD_MASK_SHIFT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1885 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1886 if (GetKeyState(VK_CONTROL) & 0x8000)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1887 modifiers |= MOD_MASK_CTRL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1888 if (GetKeyState(VK_MENU) & 0x8000)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1889 modifiers |= MOD_MASK_ALT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1890
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1891 if (special_keys[i].vim_code1 == NUL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1892 key = special_keys[i].vim_code0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1893 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1894 key = TO_SPECIAL(special_keys[i].vim_code0,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1895 special_keys[i].vim_code1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1896 key = simplify_key(key, &modifiers);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1897 if (key == CSI)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1898 key = K_CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1899
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1900 if (modifiers)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1901 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1902 string[0] = CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1903 string[1] = KS_MODIFIER;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1904 string[2] = modifiers;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1905 add_to_input_buf(string, 3);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1906 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1907
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1908 if (IS_SPECIAL(key))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1909 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1910 string[0] = CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1911 string[1] = K_SECOND(key);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1912 string[2] = K_THIRD(key);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1913 add_to_input_buf(string, 3);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1914 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1915 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1916 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1917 int len;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1918
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1919 /* Handle "key" as a Unicode character. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1920 len = char_to_string(key, string, 40, FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1921 add_to_input_buf(string, len);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1922 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1923 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1924 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1925 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1926 if (special_keys[i].key_sym == 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1927 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1928 /* Some keys need C-S- where they should only need C-.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1929 * Ignore 0xff, Windows XP sends it when NUMLOCK has changed since
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1930 * system startup (Helmut Stiegler, 2003 Oct 3). */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1931 if (vk != 0xff
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1932 && (GetKeyState(VK_CONTROL) & 0x8000)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1933 && !(GetKeyState(VK_SHIFT) & 0x8000)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1934 && !(GetKeyState(VK_MENU) & 0x8000))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1935 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1936 /* CTRL-6 is '^'; Japanese keyboard maps '^' to vk == 0xDE */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1937 if (vk == '6' || MapVirtualKey(vk, 2) == (UINT)'^')
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1938 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1939 string[0] = Ctrl_HAT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1940 add_to_input_buf(string, 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1941 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1942 /* vk == 0xBD AZERTY for CTRL-'-', but CTRL-[ for * QWERTY! */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1943 else if (vk == 0xBD) /* QWERTY for CTRL-'-' */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1944 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1945 string[0] = Ctrl__;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1946 add_to_input_buf(string, 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1947 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1948 /* CTRL-2 is '@'; Japanese keyboard maps '@' to vk == 0xC0 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1949 else if (vk == '2' || MapVirtualKey(vk, 2) == (UINT)'@')
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1950 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1951 string[0] = Ctrl_AT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1952 add_to_input_buf(string, 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1953 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1954 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1955 MyTranslateMessage(&msg);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1956 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1957 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1958 MyTranslateMessage(&msg);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1959 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1960 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1961 #ifdef FEAT_MBYTE_IME
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1962 else if (msg.message == WM_IME_NOTIFY)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1963 _OnImeNotify(msg.hwnd, (DWORD)msg.wParam, (DWORD)msg.lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1964 else if (msg.message == WM_KEYUP && im_get_status())
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1965 /* added for non-MS IME (Yasuhiro Matsumoto) */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1966 MyTranslateMessage(&msg);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1967 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1968 #if !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1969 /* GIME_TEST */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1970 else if (msg.message == WM_IME_STARTCOMPOSITION)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1971 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1972 POINT point;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1973
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1974 global_ime_set_font(&norm_logfont);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1975 point.x = FILL_X(gui.col);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1976 point.y = FILL_Y(gui.row);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1977 MapWindowPoints(s_textArea, s_hwnd, &point, 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1978 global_ime_set_position(&point);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1979 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1980 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1981
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1982 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1983 /* Check for <F10>: Default effect is to select the menu. When <F10> is
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1984 * mapped we need to stop it here to avoid strange effects (e.g., for the
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1985 * key-up event) */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1986 if (vk != VK_F10 || check_map(k10, State, FALSE, TRUE, FALSE,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1987 NULL, NULL) == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1988 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1989 pDispatchMessage(&msg);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1990 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1991
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1992 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1993 * Catch up with any queued events. This may put keyboard input into the
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1994 * input buffer, call resize call-backs, trigger timers etc. If there is
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1995 * nothing in the event queue (& no timers pending), then we return
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1996 * immediately.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1997 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1998 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1999 gui_mch_update(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2000 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2001 MSG msg;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2002
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2003 if (!s_busy_processing)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2004 while (pPeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2005 && !vim_is_input_buf_full())
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2006 process_message();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2007 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2008
9179
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2009 static void
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2010 remove_any_timer(void)
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2011 {
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2012 MSG msg;
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2013
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2014 if (s_wait_timer != 0 && !s_timed_out)
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2015 {
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2016 KillTimer(NULL, s_wait_timer);
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2017
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2018 /* Eat spurious WM_TIMER messages */
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2019 while (pPeekMessage(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2020 ;
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2021 s_wait_timer = 0;
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2022 }
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2023 }
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2024
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2025 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2026 * GUI input routine called by gui_wait_for_chars(). Waits for a character
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2027 * from the keyboard.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2028 * wtime == -1 Wait forever.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2029 * wtime == 0 This should never happen.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2030 * wtime > 0 Wait wtime milliseconds for a character.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2031 * Returns OK if a character was found to be available within the given time,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2032 * or FAIL otherwise.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2033 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2034 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2035 gui_mch_wait_for_chars(int wtime)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2036 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2037 int focus;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2038
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2039 s_timed_out = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2040
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2041 if (wtime > 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2042 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2043 /* Don't do anything while processing a (scroll) message. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2044 if (s_busy_processing)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2045 return FAIL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2046 s_wait_timer = (UINT)SetTimer(NULL, 0, (UINT)wtime,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2047 (TIMERPROC)_OnTimer);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2048 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2049
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2050 allow_scrollbar = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2051
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2052 focus = gui.in_focus;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2053 while (!s_timed_out)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2054 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2055 /* Stop or start blinking when focus changes */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2056 if (gui.in_focus != focus)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2057 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2058 if (gui.in_focus)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2059 gui_mch_start_blink();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2060 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2061 gui_mch_stop_blink();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2062 focus = gui.in_focus;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2063 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2064
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2065 if (s_need_activate)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2066 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2067 (void)SetForegroundWindow(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2068 s_need_activate = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2069 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2070
9179
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2071 #ifdef FEAT_TIMERS
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2072 did_add_timer = FALSE;
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2073 #endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2074 #ifdef MESSAGE_QUEUE
8222
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2075 /* Check channel while waiting message. */
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2076 for (;;)
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2077 {
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2078 MSG msg;
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2079
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2080 parse_queued_messages();
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2081
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2082 if (pPeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)
8813
b92938076e40 commit https://github.com/vim/vim/commit/f28d87146544e3b5d70aaa6a2513019f6de043ad
Christian Brabandt <cb@256bit.org>
parents: 8571
diff changeset
2083 || MsgWaitForMultipleObjects(0, NULL, FALSE, 100, QS_ALLINPUT)
8222
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2084 != WAIT_TIMEOUT)
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2085 break;
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2086 }
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2087 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2088
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2089 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2090 * Don't use gui_mch_update() because then we will spin-lock until a
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2091 * char arrives, instead we use GetMessage() to hang until an
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2092 * event arrives. No need to check for input_buf_full because we are
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2093 * returning as soon as it contains a single char -- webb
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2094 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2095 process_message();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2096
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2097 if (input_available())
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2098 {
9179
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2099 remove_any_timer();
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2100 allow_scrollbar = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2101
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2102 /* Clear pending mouse button, the release event may have been
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2103 * taken by the dialog window. But don't do this when getting
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2104 * focus, we need the mouse-up event then. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2105 if (!s_getting_focus)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2106 s_button_pending = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2107
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2108 return OK;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2109 }
9179
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2110
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2111 #ifdef FEAT_TIMERS
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2112 if (did_add_timer)
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2113 {
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2114 /* Need to recompute the waiting time. */
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2115 remove_any_timer();
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2116 break;
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2117 }
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2118 #endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2119 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2120 allow_scrollbar = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2121 return FAIL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2122 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2123
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2124 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2125 * Clear a rectangular region of the screen from text pos (row1, col1) to
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2126 * (row2, col2) inclusive.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2127 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2128 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2129 gui_mch_clear_block(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2130 int row1,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2131 int col1,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2132 int row2,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2133 int col2)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2134 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2135 RECT rc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2136
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2137 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2138 * Clear one extra pixel at the far right, for when bold characters have
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2139 * spilled over to the window border.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2140 * Note: FillRect() excludes right and bottom of rectangle.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2141 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2142 rc.left = FILL_X(col1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2143 rc.top = FILL_Y(row1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2144 rc.right = FILL_X(col2 + 1) + (col2 == Columns - 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2145 rc.bottom = FILL_Y(row2 + 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2146 clear_rect(&rc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2147 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2148
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2149 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2150 * Clear the whole text window.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2151 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2152 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2153 gui_mch_clear_all(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2154 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2155 RECT rc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2156
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2157 rc.left = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2158 rc.top = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2159 rc.right = Columns * gui.char_width + 2 * gui.border_width;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2160 rc.bottom = Rows * gui.char_height + 2 * gui.border_width;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2161 clear_rect(&rc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2162 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2163 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2164 * Menu stuff.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2165 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2166
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2167 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2168 gui_mch_enable_menu(int flag)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2169 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2170 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2171 SetMenu(s_hwnd, flag ? s_menuBar : NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2172 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2173 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2174
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2175 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2176 gui_mch_set_menu_pos(
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
2177 int x UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
2178 int y UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
2179 int w UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
2180 int h UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2181 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2182 /* It will be in the right place anyway */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2183 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2184
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2185 #if defined(FEAT_MENU) || defined(PROTO)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2186 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2187 * Make menu item hidden or not hidden
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2188 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2189 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2190 gui_mch_menu_hidden(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2191 vimmenu_T *menu,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2192 int hidden)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2193 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2194 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2195 * This doesn't do what we want. Hmm, just grey the menu items for now.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2196 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2197 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2198 if (hidden)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2199 EnableMenuItem(s_menuBar, menu->id, MF_BYCOMMAND | MF_DISABLED);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2200 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2201 EnableMenuItem(s_menuBar, menu->id, MF_BYCOMMAND | MF_ENABLED);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2202 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2203 gui_mch_menu_grey(menu, hidden);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2204 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2205
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2206 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2207 * This is called after setting all the menus to grey/hidden or not.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2208 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2209 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2210 gui_mch_draw_menubar(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2211 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2212 DrawMenuBar(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2213 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2214 #endif /*FEAT_MENU*/
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2215
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2216 #ifndef PROTO
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2217 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2218 #ifdef VIMDLL
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2219 _export
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2220 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2221 _cdecl
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2222 SaveInst(HINSTANCE hInst)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2223 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2224 s_hinst = hInst;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2225 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2226 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2227
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2228 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2229 * Return the RGB value of a pixel as a long.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2230 */
9939
ccb6461b82df commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents: 9834
diff changeset
2231 guicolor_T
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2232 gui_mch_get_rgb(guicolor_T pixel)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2233 {
9939
ccb6461b82df commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents: 9834
diff changeset
2234 return (guicolor_T)((GetRValue(pixel) << 16) + (GetGValue(pixel) << 8)
ccb6461b82df commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents: 9834
diff changeset
2235 + GetBValue(pixel));
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2236 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2237
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2238 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2239 /* Convert pixels in X to dialog units */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2240 static WORD
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2241 PixelToDialogX(int numPixels)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2242 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2243 return (WORD)((numPixels * 4) / s_dlgfntwidth);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2244 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2245
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2246 /* Convert pixels in Y to dialog units */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2247 static WORD
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2248 PixelToDialogY(int numPixels)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2249 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2250 return (WORD)((numPixels * 8) / s_dlgfntheight);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2251 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2252
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2253 /* Return the width in pixels of the given text in the given DC. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2254 static int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2255 GetTextWidth(HDC hdc, char_u *str, int len)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2256 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2257 SIZE size;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2258
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2259 GetTextExtentPoint(hdc, (LPCSTR)str, len, &size);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2260 return size.cx;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2261 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2262
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2263 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2264 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2265 * Return the width in pixels of the given text in the given DC, taking care
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2266 * of 'encoding' to active codepage conversion.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2267 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2268 static int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2269 GetTextWidthEnc(HDC hdc, char_u *str, int len)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2270 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2271 SIZE size;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2272 WCHAR *wstr;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2273 int n;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2274 int wlen = len;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2275
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2276 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2277 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2278 /* 'encoding' differs from active codepage: convert text and use wide
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2279 * function */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2280 wstr = enc_to_utf16(str, &wlen);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2281 if (wstr != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2282 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2283 n = GetTextExtentPointW(hdc, wstr, wlen, &size);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2284 vim_free(wstr);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2285 if (n)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2286 return size.cx;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2287 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2288 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2289
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2290 return GetTextWidth(hdc, str, len);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2291 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2292 #else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2293 # define GetTextWidthEnc(h, s, l) GetTextWidth((h), (s), (l))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2294 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2295
10438
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2296 static void get_work_area(RECT *spi_rect);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2297
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2298 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2299 * A quick little routine that will center one window over another, handy for
10438
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2300 * dialog boxes. Taken from the Win32SDK samples and modified for multiple
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2301 * monitors.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2302 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2303 static BOOL
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2304 CenterWindow(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2305 HWND hwndChild,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2306 HWND hwndParent)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2307 {
10438
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2308 HMONITOR mon;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2309 MONITORINFO moninfo;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2310 RECT rChild, rParent, rScreen;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2311 int wChild, hChild, wParent, hParent;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2312 int xNew, yNew;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2313 HDC hdc;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2314
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2315 GetWindowRect(hwndChild, &rChild);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2316 wChild = rChild.right - rChild.left;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2317 hChild = rChild.bottom - rChild.top;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2318
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2319 /* If Vim is minimized put the window in the middle of the screen. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2320 if (hwndParent == NULL || IsMinimized(hwndParent))
10438
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2321 get_work_area(&rParent);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2322 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2323 GetWindowRect(hwndParent, &rParent);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2324 wParent = rParent.right - rParent.left;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2325 hParent = rParent.bottom - rParent.top;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2326
10438
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2327 moninfo.cbSize = sizeof(MONITORINFO);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2328 mon = MonitorFromWindow(hwndChild, MONITOR_DEFAULTTOPRIMARY);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2329 if (mon != NULL && GetMonitorInfo(mon, &moninfo))
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2330 {
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2331 rScreen = moninfo.rcWork;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2332 }
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2333 else
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2334 {
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2335 hdc = GetDC(hwndChild);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2336 rScreen.left = 0;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2337 rScreen.top = 0;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2338 rScreen.right = GetDeviceCaps(hdc, HORZRES);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2339 rScreen.bottom = GetDeviceCaps(hdc, VERTRES);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2340 ReleaseDC(hwndChild, hdc);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2341 }
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2342
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2343 xNew = rParent.left + ((wParent - wChild) / 2);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2344 if (xNew < rScreen.left)
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2345 xNew = rScreen.left;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2346 else if ((xNew + wChild) > rScreen.right)
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2347 xNew = rScreen.right - wChild;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2348
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2349 yNew = rParent.top + ((hParent - hChild) / 2);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2350 if (yNew < rScreen.top)
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2351 yNew = rScreen.top;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2352 else if ((yNew + hChild) > rScreen.bottom)
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2353 yNew = rScreen.bottom - hChild;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2354
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2355 return SetWindowPos(hwndChild, NULL, xNew, yNew, 0, 0,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2356 SWP_NOSIZE | SWP_NOZORDER);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2357 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2358 #endif /* FEAT_GUI_DIALOG */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2359
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2360 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2361 gui_mch_activate_window(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2362 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2363 (void)SetActiveWindow(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2364 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2365
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2366 #if defined(FEAT_TOOLBAR) || defined(PROTO)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2367 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2368 gui_mch_show_toolbar(int showit)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2369 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2370 if (s_toolbarhwnd == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2371 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2372
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2373 if (showit)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2374 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2375 # ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2376 # ifndef TB_SETUNICODEFORMAT
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2377 /* For older compilers. We assume this never changes. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2378 # define TB_SETUNICODEFORMAT 0x2005
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2379 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2380 /* Enable/disable unicode support */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2381 int uu = (enc_codepage >= 0 && (int)GetACP() != enc_codepage);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2382 SendMessage(s_toolbarhwnd, TB_SETUNICODEFORMAT, (WPARAM)uu, (LPARAM)0);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2383 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2384 ShowWindow(s_toolbarhwnd, SW_SHOW);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2385 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2386 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2387 ShowWindow(s_toolbarhwnd, SW_HIDE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2388 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2389
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2390 /* Then number of bitmaps is fixed. Exit is missing! */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2391 #define TOOLBAR_BITMAP_COUNT 31
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2392
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2393 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2394
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2395 #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2396 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2397 add_tabline_popup_menu_entry(HMENU pmenu, UINT item_id, char_u *item_text)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2398 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2399 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2400 WCHAR *wn = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2401
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2402 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2403 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2404 /* 'encoding' differs from active codepage: convert menu name
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2405 * and use wide function */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2406 wn = enc_to_utf16(item_text, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2407 if (wn != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2408 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2409 MENUITEMINFOW infow;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2410
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2411 infow.cbSize = sizeof(infow);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2412 infow.fMask = MIIM_TYPE | MIIM_ID;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2413 infow.wID = item_id;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2414 infow.fType = MFT_STRING;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2415 infow.dwTypeData = wn;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2416 infow.cch = (UINT)wcslen(wn);
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
2417 InsertMenuItemW(pmenu, item_id, FALSE, &infow);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2418 vim_free(wn);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2419 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2420 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2421
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2422 if (wn == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2423 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2424 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2425 MENUITEMINFO info;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2426
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2427 info.cbSize = sizeof(info);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2428 info.fMask = MIIM_TYPE | MIIM_ID;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2429 info.wID = item_id;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2430 info.fType = MFT_STRING;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2431 info.dwTypeData = (LPTSTR)item_text;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2432 info.cch = (UINT)STRLEN(item_text);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2433 InsertMenuItem(pmenu, item_id, FALSE, &info);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2434 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2435 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2436
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2437 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2438 show_tabline_popup_menu(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2439 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2440 HMENU tab_pmenu;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2441 long rval;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2442 POINT pt;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2443
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2444 /* When ignoring events don't show the menu. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2445 if (hold_gui_events
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2446 # ifdef FEAT_CMDWIN
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2447 || cmdwin_type != 0
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2448 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2449 )
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2450 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2451
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2452 tab_pmenu = CreatePopupMenu();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2453 if (tab_pmenu == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2454 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2455
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2456 if (first_tabpage->tp_next != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2457 add_tabline_popup_menu_entry(tab_pmenu,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2458 TABLINE_MENU_CLOSE, (char_u *)_("Close tab"));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2459 add_tabline_popup_menu_entry(tab_pmenu,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2460 TABLINE_MENU_NEW, (char_u *)_("New tab"));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2461 add_tabline_popup_menu_entry(tab_pmenu,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2462 TABLINE_MENU_OPEN, (char_u *)_("Open tab..."));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2463
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2464 GetCursorPos(&pt);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2465 rval = TrackPopupMenuEx(tab_pmenu, TPM_RETURNCMD, pt.x, pt.y, s_tabhwnd,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2466 NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2467
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2468 DestroyMenu(tab_pmenu);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2469
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2470 /* Add the string cmd into input buffer */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2471 if (rval > 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2472 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2473 TCHITTESTINFO htinfo;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2474 int idx;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2475
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2476 if (ScreenToClient(s_tabhwnd, &pt) == 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2477 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2478
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2479 htinfo.pt.x = pt.x;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2480 htinfo.pt.y = pt.y;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2481 idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2482 if (idx == -1)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2483 idx = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2484 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2485 idx += 1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2486
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2487 send_tabline_menu_event(idx, (int)rval);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2488 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2489 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2490
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2491 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2492 * Show or hide the tabline.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2493 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2494 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2495 gui_mch_show_tabline(int showit)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2496 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2497 if (s_tabhwnd == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2498 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2499
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2500 if (!showit != !showing_tabline)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2501 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2502 if (showit)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2503 ShowWindow(s_tabhwnd, SW_SHOW);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2504 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2505 ShowWindow(s_tabhwnd, SW_HIDE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2506 showing_tabline = showit;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2507 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2508 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2509
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2510 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2511 * Return TRUE when tabline is displayed.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2512 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2513 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2514 gui_mch_showing_tabline(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2515 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2516 return s_tabhwnd != NULL && showing_tabline;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2517 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2518
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2519 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2520 * Update the labels of the tabline.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2521 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2522 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2523 gui_mch_update_tabline(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2524 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2525 tabpage_T *tp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2526 TCITEM tie;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2527 int nr = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2528 int curtabidx = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2529 int tabadded = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2530 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2531 static int use_unicode = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2532 int uu;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2533 WCHAR *wstr = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2534 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2535
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2536 if (s_tabhwnd == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2537 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2538
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
2539 #ifdef FEAT_MBYTE
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2540 # ifndef CCM_SETUNICODEFORMAT
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2541 /* For older compilers. We assume this never changes. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2542 # define CCM_SETUNICODEFORMAT 0x2005
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2543 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2544 uu = (enc_codepage >= 0 && (int)GetACP() != enc_codepage);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2545 if (uu != use_unicode)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2546 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2547 /* Enable/disable unicode support */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2548 SendMessage(s_tabhwnd, CCM_SETUNICODEFORMAT, (WPARAM)uu, (LPARAM)0);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2549 use_unicode = uu;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2550 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2551 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2552
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2553 tie.mask = TCIF_TEXT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2554 tie.iImage = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2555
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2556 /* Disable redraw for tab updates to eliminate O(N^2) draws. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2557 SendMessage(s_tabhwnd, WM_SETREDRAW, (WPARAM)FALSE, 0);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2558
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2559 /* Add a label for each tab page. They all contain the same text area. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2560 for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2561 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2562 if (tp == curtab)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2563 curtabidx = nr;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2564
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2565 if (nr >= TabCtrl_GetItemCount(s_tabhwnd))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2566 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2567 /* Add the tab */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2568 tie.pszText = "-Empty-";
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2569 TabCtrl_InsertItem(s_tabhwnd, nr, &tie);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2570 tabadded = 1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2571 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2572
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2573 get_tabline_label(tp, FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2574 tie.pszText = (LPSTR)NameBuff;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2575 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2576 wstr = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2577 if (use_unicode)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2578 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2579 /* Need to go through Unicode. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2580 wstr = enc_to_utf16(NameBuff, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2581 if (wstr != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2582 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2583 TCITEMW tiw;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2584
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2585 tiw.mask = TCIF_TEXT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2586 tiw.iImage = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2587 tiw.pszText = wstr;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2588 SendMessage(s_tabhwnd, TCM_SETITEMW, (WPARAM)nr, (LPARAM)&tiw);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2589 vim_free(wstr);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2590 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2591 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2592 if (wstr == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2593 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2594 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2595 TabCtrl_SetItem(s_tabhwnd, nr, &tie);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2596 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2597 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2598
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2599 /* Remove any old labels. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2600 while (nr < TabCtrl_GetItemCount(s_tabhwnd))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2601 TabCtrl_DeleteItem(s_tabhwnd, nr);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2602
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2603 if (!tabadded && TabCtrl_GetCurSel(s_tabhwnd) != curtabidx)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2604 TabCtrl_SetCurSel(s_tabhwnd, curtabidx);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2605
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2606 /* Re-enable redraw and redraw. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2607 SendMessage(s_tabhwnd, WM_SETREDRAW, (WPARAM)TRUE, 0);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2608 RedrawWindow(s_tabhwnd, NULL, NULL,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2609 RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2610
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2611 if (tabadded && TabCtrl_GetCurSel(s_tabhwnd) != curtabidx)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2612 TabCtrl_SetCurSel(s_tabhwnd, curtabidx);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2613 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2614
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2615 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2616 * Set the current tab to "nr". First tab is 1.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2617 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2618 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2619 gui_mch_set_curtab(int nr)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2620 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2621 if (s_tabhwnd == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2622 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2623
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2624 if (TabCtrl_GetCurSel(s_tabhwnd) != nr - 1)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2625 TabCtrl_SetCurSel(s_tabhwnd, nr - 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2626 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2627
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2628 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2629
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2630 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2631 * ":simalt" command.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2632 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2633 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2634 ex_simalt(exarg_T *eap)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2635 {
11386
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2636 char_u *keys = eap->arg;
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2637 int fill_typebuf = FALSE;
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2638 char_u key_name[4];
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2639
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2640 PostMessage(s_hwnd, WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)0);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2641 while (*keys)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2642 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2643 if (*keys == '~')
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2644 *keys = ' '; /* for showing system menu */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2645 PostMessage(s_hwnd, WM_CHAR, (WPARAM)*keys, (LPARAM)0);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2646 keys++;
11386
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2647 fill_typebuf = TRUE;
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2648 }
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2649 if (fill_typebuf)
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2650 {
11410
db21cc7b40f0 patch 8.0.0589: :simalt still does not work
Christian Brabandt <cb@256bit.org>
parents: 11386
diff changeset
2651 /* Put a NOP in the typeahead buffer so that the message will get
11386
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2652 * processed. */
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2653 key_name[0] = K_SPECIAL;
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2654 key_name[1] = KS_EXTRA;
11410
db21cc7b40f0 patch 8.0.0589: :simalt still does not work
Christian Brabandt <cb@256bit.org>
parents: 11386
diff changeset
2655 key_name[2] = KE_NOP;
11386
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2656 key_name[3] = NUL;
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2657 typebuf_was_filled = TRUE;
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2658 (void)ins_typebuf(key_name, REMAP_NONE, 0, TRUE, FALSE);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2659 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2660 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2661
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2662 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2663 * Create the find & replace dialogs.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2664 * You can't have both at once: ":find" when replace is showing, destroys
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2665 * the replace dialog first, and the other way around.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2666 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2667 #ifdef MSWIN_FIND_REPLACE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2668 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2669 initialise_findrep(char_u *initial_string)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2670 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2671 int wword = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2672 int mcase = !p_ic;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2673 char_u *entry_text;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2674
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2675 /* Get the search string to use. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2676 entry_text = get_find_dialog_text(initial_string, &wword, &mcase);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2677
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2678 s_findrep_struct.hwndOwner = s_hwnd;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2679 s_findrep_struct.Flags = FR_DOWN;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2680 if (mcase)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2681 s_findrep_struct.Flags |= FR_MATCHCASE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2682 if (wword)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2683 s_findrep_struct.Flags |= FR_WHOLEWORD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2684 if (entry_text != NULL && *entry_text != NUL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2685 vim_strncpy((char_u *)s_findrep_struct.lpstrFindWhat, entry_text,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2686 s_findrep_struct.wFindWhatLen - 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2687 vim_free(entry_text);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2688 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2689 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2690
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2691 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2692 set_window_title(HWND hwnd, char *title)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2693 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2694 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2695 if (title != NULL && enc_codepage >= 0 && enc_codepage != (int)GetACP())
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2696 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2697 WCHAR *wbuf;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2698
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2699 /* Convert the title from 'encoding' to UTF-16. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2700 wbuf = (WCHAR *)enc_to_utf16((char_u *)title, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2701 if (wbuf != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2702 {
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
2703 SetWindowTextW(hwnd, wbuf);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2704 vim_free(wbuf);
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
2705 }
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
2706 return;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2707 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2708 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2709 (void)SetWindowText(hwnd, (LPCSTR)title);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2710 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2711
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2712 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2713 gui_mch_find_dialog(exarg_T *eap)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2714 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2715 #ifdef MSWIN_FIND_REPLACE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2716 if (s_findrep_msg != 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2717 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2718 if (IsWindow(s_findrep_hwnd) && !s_findrep_is_find)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2719 DestroyWindow(s_findrep_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2720
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2721 if (!IsWindow(s_findrep_hwnd))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2722 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2723 initialise_findrep(eap->arg);
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
2724 # ifdef FEAT_MBYTE
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2725 /* If the OS is Windows NT, and 'encoding' differs from active
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2726 * codepage: convert text and use wide function. */
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
2727 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2728 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2729 findrep_atow(&s_findrep_struct_w, &s_findrep_struct);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2730 s_findrep_hwnd = FindTextW(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2731 (LPFINDREPLACEW) &s_findrep_struct_w);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2732 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2733 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2734 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2735 s_findrep_hwnd = FindText((LPFINDREPLACE) &s_findrep_struct);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2736 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2737
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2738 set_window_title(s_findrep_hwnd,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2739 _("Find string (use '\\\\' to find a '\\')"));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2740 (void)SetFocus(s_findrep_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2741
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2742 s_findrep_is_find = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2743 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2744 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2745 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2746
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2747
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2748 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2749 gui_mch_replace_dialog(exarg_T *eap)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2750 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2751 #ifdef MSWIN_FIND_REPLACE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2752 if (s_findrep_msg != 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2753 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2754 if (IsWindow(s_findrep_hwnd) && s_findrep_is_find)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2755 DestroyWindow(s_findrep_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2756
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2757 if (!IsWindow(s_findrep_hwnd))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2758 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2759 initialise_findrep(eap->arg);
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
2760 # ifdef FEAT_MBYTE
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
2761 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2762 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2763 findrep_atow(&s_findrep_struct_w, &s_findrep_struct);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2764 s_findrep_hwnd = ReplaceTextW(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2765 (LPFINDREPLACEW) &s_findrep_struct_w);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2766 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2767 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2768 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2769 s_findrep_hwnd = ReplaceText(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2770 (LPFINDREPLACE) &s_findrep_struct);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2771 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2772
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2773 set_window_title(s_findrep_hwnd,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2774 _("Find & Replace (use '\\\\' to find a '\\')"));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2775 (void)SetFocus(s_findrep_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2776
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2777 s_findrep_is_find = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2778 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2779 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2780 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2781
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2782
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2783 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2784 * Set visibility of the pointer.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2785 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2786 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2787 gui_mch_mousehide(int hide)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2788 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2789 if (hide != gui.pointer_hidden)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2790 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2791 ShowCursor(!hide);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2792 gui.pointer_hidden = hide;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2793 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2794 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2795
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2796 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2797 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2798 gui_mch_show_popupmenu_at(vimmenu_T *menu, int x, int y)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2799 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2800 /* Unhide the mouse, we don't get move events here. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2801 gui_mch_mousehide(FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2802
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2803 (void)TrackPopupMenu(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2804 (HMENU)menu->submenu_id,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2805 TPM_LEFTALIGN | TPM_LEFTBUTTON,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2806 x, y,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2807 (int)0, /*reserved param*/
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2808 s_hwnd,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2809 NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2810 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2811 * NOTE: The pop-up menu can eat the mouse up event.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2812 * We deal with this in normal.c.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2813 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2814 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2815 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2816
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2817 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2818 * Got a message when the system will go down.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2819 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2820 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2821 _OnEndSession(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2822 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2823 getout_preserve_modified(1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2824 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2825
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2826 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2827 * Get this message when the user clicks on the cross in the top right corner
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2828 * of a Windows95 window.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2829 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2830 static void
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
2831 _OnClose(HWND hwnd UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2832 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2833 gui_shell_closed();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2834 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2835
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2836 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2837 * Get a message when the window is being destroyed.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2838 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2839 static void
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
2840 _OnDestroy(HWND hwnd)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2841 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2842 if (!destroying)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2843 _OnClose(hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2844 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2845
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2846 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2847 _OnPaint(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2848 HWND hwnd)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2849 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2850 if (!IsMinimized(hwnd))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2851 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2852 PAINTSTRUCT ps;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2853
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2854 out_flush(); /* make sure all output has been processed */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2855 (void)BeginPaint(hwnd, &ps);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2856 #if defined(FEAT_DIRECTX)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2857 if (IS_ENABLE_DIRECTX())
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2858 DWriteContext_BeginDraw(s_dwc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2859 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2860
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2861 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2862 /* prevent multi-byte characters from misprinting on an invalid
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2863 * rectangle */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2864 if (has_mbyte)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2865 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2866 RECT rect;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2867
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2868 GetClientRect(hwnd, &rect);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2869 ps.rcPaint.left = rect.left;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2870 ps.rcPaint.right = rect.right;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2871 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2872 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2873
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2874 if (!IsRectEmpty(&ps.rcPaint))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2875 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2876 #if defined(FEAT_DIRECTX)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2877 if (IS_ENABLE_DIRECTX())
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2878 DWriteContext_BindDC(s_dwc, s_hdc, &ps.rcPaint);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2879 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2880 gui_redraw(ps.rcPaint.left, ps.rcPaint.top,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2881 ps.rcPaint.right - ps.rcPaint.left + 1,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2882 ps.rcPaint.bottom - ps.rcPaint.top + 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2883 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2884
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2885 #if defined(FEAT_DIRECTX)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2886 if (IS_ENABLE_DIRECTX())
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2887 DWriteContext_EndDraw(s_dwc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2888 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2889 EndPaint(hwnd, &ps);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2890 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2891 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2892
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2893 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2894 _OnSize(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2895 HWND hwnd,
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
2896 UINT state UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2897 int cx,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2898 int cy)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2899 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2900 if (!IsMinimized(hwnd))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2901 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2902 gui_resize_shell(cx, cy);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2903
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2904 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2905 /* Menu bar may wrap differently now */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2906 gui_mswin_get_menu_height(TRUE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2907 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2908 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2909 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2910
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2911 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2912 _OnSetFocus(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2913 HWND hwnd,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2914 HWND hwndOldFocus)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2915 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2916 gui_focus_change(TRUE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2917 s_getting_focus = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2918 (void)MyWindowProc(hwnd, WM_SETFOCUS, (WPARAM)hwndOldFocus, 0);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2919 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2920
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2921 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2922 _OnKillFocus(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2923 HWND hwnd,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2924 HWND hwndNewFocus)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2925 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2926 gui_focus_change(FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2927 s_getting_focus = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2928 (void)MyWindowProc(hwnd, WM_KILLFOCUS, (WPARAM)hwndNewFocus, 0);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2929 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2930
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2931 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2932 * Get a message when the user switches back to vim
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2933 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2934 static LRESULT
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2935 _OnActivateApp(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2936 HWND hwnd,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2937 BOOL fActivate,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2938 DWORD dwThreadId)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2939 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2940 /* we call gui_focus_change() in _OnSetFocus() */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2941 /* gui_focus_change((int)fActivate); */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2942 return MyWindowProc(hwnd, WM_ACTIVATEAPP, fActivate, (DWORD)dwThreadId);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2943 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2944
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2945 #if defined(FEAT_WINDOWS) || defined(PROTO)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2946 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2947 gui_mch_destroy_scrollbar(scrollbar_T *sb)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2948 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2949 DestroyWindow(sb->id);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2950 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2951 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2952
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2953 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2954 * Get current mouse coordinates in text window.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2955 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2956 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2957 gui_mch_getmouse(int *x, int *y)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2958 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2959 RECT rct;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2960 POINT mp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2961
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2962 (void)GetWindowRect(s_textArea, &rct);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2963 (void)GetCursorPos((LPPOINT)&mp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2964 *x = (int)(mp.x - rct.left);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2965 *y = (int)(mp.y - rct.top);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2966 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2967
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2968 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2969 * Move mouse pointer to character at (x, y).
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2970 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2971 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2972 gui_mch_setmouse(int x, int y)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2973 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2974 RECT rct;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2975
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2976 (void)GetWindowRect(s_textArea, &rct);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2977 (void)SetCursorPos(x + gui.border_offset + rct.left,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2978 y + gui.border_offset + rct.top);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2979 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2980
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2981 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2982 gui_mswin_get_valid_dimensions(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2983 int w,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2984 int h,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2985 int *valid_w,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2986 int *valid_h)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2987 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2988 int base_width, base_height;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2989
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2990 base_width = gui_get_base_width()
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2991 + (GetSystemMetrics(SM_CXFRAME) +
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2992 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2993 base_height = gui_get_base_height()
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2994 + (GetSystemMetrics(SM_CYFRAME) +
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2995 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2996 + GetSystemMetrics(SM_CYCAPTION)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2997 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2998 + gui_mswin_get_menu_height(FALSE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2999 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3000 ;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3001 *valid_w = base_width +
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3002 ((w - base_width) / gui.char_width) * gui.char_width;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3003 *valid_h = base_height +
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3004 ((h - base_height) / gui.char_height) * gui.char_height;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3005 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3006
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3007 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3008 gui_mch_flash(int msec)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3009 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3010 RECT rc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3011
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3012 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3013 * Note: InvertRect() excludes right and bottom of rectangle.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3014 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3015 rc.left = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3016 rc.top = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3017 rc.right = gui.num_cols * gui.char_width;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3018 rc.bottom = gui.num_rows * gui.char_height;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3019 InvertRect(s_hdc, &rc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3020 gui_mch_flush(); /* make sure it's displayed */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3021
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3022 ui_delay((long)msec, TRUE); /* wait for a few msec */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3023
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3024 InvertRect(s_hdc, &rc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3025 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3026
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3027 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3028 * Return flags used for scrolling.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3029 * The SW_INVALIDATE is required when part of the window is covered or
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3030 * off-screen. Refer to MS KB Q75236.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3031 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3032 static int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3033 get_scroll_flags(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3034 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3035 HWND hwnd;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3036 RECT rcVim, rcOther, rcDest;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3037
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3038 GetWindowRect(s_hwnd, &rcVim);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3039
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3040 /* Check if the window is partly above or below the screen. We don't care
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3041 * about partly left or right of the screen, it is not relevant when
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3042 * scrolling up or down. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3043 if (rcVim.top < 0 || rcVim.bottom > GetSystemMetrics(SM_CYFULLSCREEN))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3044 return SW_INVALIDATE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3045
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3046 /* Check if there is an window (partly) on top of us. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3047 for (hwnd = s_hwnd; (hwnd = GetWindow(hwnd, GW_HWNDPREV)) != (HWND)0; )
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3048 if (IsWindowVisible(hwnd))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3049 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3050 GetWindowRect(hwnd, &rcOther);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3051 if (IntersectRect(&rcDest, &rcVim, &rcOther))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3052 return SW_INVALIDATE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3053 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3054 return 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3055 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3056
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3057 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3058 * On some Intel GPUs, the regions drawn just prior to ScrollWindowEx()
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3059 * may not be scrolled out properly.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3060 * For gVim, when _OnScroll() is repeated, the character at the
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3061 * previous cursor position may be left drawn after scroll.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3062 * The problem can be avoided by calling GetPixel() to get a pixel in
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3063 * the region before ScrollWindowEx().
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3064 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3065 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3066 intel_gpu_workaround(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3067 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3068 GetPixel(s_hdc, FILL_X(gui.col), FILL_Y(gui.row));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3069 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3070
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3071 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3072 * Delete the given number of lines from the given row, scrolling up any
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3073 * text further down within the scroll region.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3074 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3075 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3076 gui_mch_delete_lines(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3077 int row,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3078 int num_lines)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3079 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3080 RECT rc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3081
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3082 intel_gpu_workaround();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3083
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3084 rc.left = FILL_X(gui.scroll_region_left);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3085 rc.right = FILL_X(gui.scroll_region_right + 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3086 rc.top = FILL_Y(row);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3087 rc.bottom = FILL_Y(gui.scroll_region_bot + 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3088
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3089 ScrollWindowEx(s_textArea, 0, -num_lines * gui.char_height,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3090 &rc, &rc, NULL, NULL, get_scroll_flags());
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3091
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3092 UpdateWindow(s_textArea);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3093 /* This seems to be required to avoid the cursor disappearing when
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3094 * scrolling such that the cursor ends up in the top-left character on
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3095 * the screen... But why? (Webb) */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3096 /* It's probably fixed by disabling drawing the cursor while scrolling. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3097 /* gui.cursor_is_valid = FALSE; */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3098
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3099 gui_clear_block(gui.scroll_region_bot - num_lines + 1,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3100 gui.scroll_region_left,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3101 gui.scroll_region_bot, gui.scroll_region_right);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3102 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3103
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3104 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3105 * Insert the given number of lines before the given row, scrolling down any
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3106 * following text within the scroll region.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3107 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3108 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3109 gui_mch_insert_lines(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3110 int row,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3111 int num_lines)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3112 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3113 RECT rc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3114
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3115 intel_gpu_workaround();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3116
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3117 rc.left = FILL_X(gui.scroll_region_left);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3118 rc.right = FILL_X(gui.scroll_region_right + 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3119 rc.top = FILL_Y(row);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3120 rc.bottom = FILL_Y(gui.scroll_region_bot + 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3121 /* The SW_INVALIDATE is required when part of the window is covered or
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3122 * off-screen. How do we avoid it when it's not needed? */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3123 ScrollWindowEx(s_textArea, 0, num_lines * gui.char_height,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3124 &rc, &rc, NULL, NULL, get_scroll_flags());
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3125
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3126 UpdateWindow(s_textArea);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3127
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3128 gui_clear_block(row, gui.scroll_region_left,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3129 row + num_lines - 1, gui.scroll_region_right);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3130 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3131
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3132
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3133 void
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
3134 gui_mch_exit(int rc UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3135 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3136 #if defined(FEAT_DIRECTX)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3137 DWriteContext_Close(s_dwc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3138 DWrite_Final();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3139 s_dwc = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3140 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3141
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3142 ReleaseDC(s_textArea, s_hdc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3143 DeleteObject(s_brush);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3144
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3145 #ifdef FEAT_TEAROFF
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3146 /* Unload the tearoff bitmap */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3147 (void)DeleteObject((HGDIOBJ)s_htearbitmap);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3148 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3149
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3150 /* Destroy our window (if we have one). */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3151 if (s_hwnd != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3152 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3153 destroying = TRUE; /* ignore WM_DESTROY message now */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3154 DestroyWindow(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3155 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3156
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3157 #ifdef GLOBAL_IME
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3158 global_ime_end();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3159 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3160 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3161
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3162 static char_u *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3163 logfont2name(LOGFONT lf)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3164 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3165 char *p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3166 char *res;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3167 char *charset_name;
8835
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3168 char *quality_name;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3169 char *font_name = lf.lfFaceName;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3170
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3171 charset_name = charset_id2name((int)lf.lfCharSet);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3172 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3173 /* Convert a font name from the current codepage to 'encoding'.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3174 * TODO: Use Wide APIs (including LOGFONTW) instead of ANSI APIs. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3175 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3176 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3177 int len;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3178 acp_to_enc((char_u *)lf.lfFaceName, (int)strlen(lf.lfFaceName),
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3179 (char_u **)&font_name, &len);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3180 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3181 #endif
8835
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3182 quality_name = quality_id2name((int)lf.lfQuality);
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3183
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3184 res = (char *)alloc((unsigned)(strlen(font_name) + 20
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3185 + (charset_name == NULL ? 0 : strlen(charset_name) + 2)));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3186 if (res != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3187 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3188 p = res;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3189 /* make a normal font string out of the lf thing:*/
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3190 sprintf((char *)p, "%s:h%d", font_name, pixels_to_points(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3191 lf.lfHeight < 0 ? -lf.lfHeight : lf.lfHeight, TRUE));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3192 while (*p)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3193 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3194 if (*p == ' ')
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3195 *p = '_';
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3196 ++p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3197 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3198 if (lf.lfItalic)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3199 STRCAT(p, ":i");
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3200 if (lf.lfWeight >= FW_BOLD)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3201 STRCAT(p, ":b");
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3202 if (lf.lfUnderline)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3203 STRCAT(p, ":u");
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3204 if (lf.lfStrikeOut)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3205 STRCAT(p, ":s");
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3206 if (charset_name != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3207 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3208 STRCAT(p, ":c");
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3209 STRCAT(p, charset_name);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3210 }
8835
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3211 if (quality_name != NULL)
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3212 {
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3213 STRCAT(p, ":q");
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3214 STRCAT(p, quality_name);
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3215 }
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3216 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3217
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3218 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3219 if (font_name != lf.lfFaceName)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3220 vim_free(font_name);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3221 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3222 return (char_u *)res;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3223 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3224
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3225
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3226 #ifdef FEAT_MBYTE_IME
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3227 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3228 * Set correct LOGFONT to IME. Use 'guifontwide' if available, otherwise use
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3229 * 'guifont'
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3230 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3231 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3232 update_im_font(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3233 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3234 LOGFONT lf_wide;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3235
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3236 if (p_guifontwide != NULL && *p_guifontwide != NUL
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3237 && gui.wide_font != NOFONT
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3238 && GetObject((HFONT)gui.wide_font, sizeof(lf_wide), &lf_wide))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3239 norm_logfont = lf_wide;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3240 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3241 norm_logfont = sub_logfont;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3242 im_set_font(&norm_logfont);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3243 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3244 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3245
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3246 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3247 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3248 * Handler of gui.wide_font (p_guifontwide) changed notification.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3249 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3250 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3251 gui_mch_wide_font_changed(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3252 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3253 LOGFONT lf;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3254
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3255 # ifdef FEAT_MBYTE_IME
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3256 update_im_font();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3257 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3258
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3259 gui_mch_free_font(gui.wide_ital_font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3260 gui.wide_ital_font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3261 gui_mch_free_font(gui.wide_bold_font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3262 gui.wide_bold_font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3263 gui_mch_free_font(gui.wide_boldital_font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3264 gui.wide_boldital_font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3265
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3266 if (gui.wide_font
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3267 && GetObject((HFONT)gui.wide_font, sizeof(lf), &lf))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3268 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3269 if (!lf.lfItalic)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3270 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3271 lf.lfItalic = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3272 gui.wide_ital_font = get_font_handle(&lf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3273 lf.lfItalic = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3274 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3275 if (lf.lfWeight < FW_BOLD)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3276 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3277 lf.lfWeight = FW_BOLD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3278 gui.wide_bold_font = get_font_handle(&lf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3279 if (!lf.lfItalic)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3280 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3281 lf.lfItalic = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3282 gui.wide_boldital_font = get_font_handle(&lf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3283 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3284 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3285 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3286 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3287 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3288
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3289 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3290 * Initialise vim to use the font with the given name.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3291 * Return FAIL if the font could not be loaded, OK otherwise.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3292 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3293 int
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
3294 gui_mch_init_font(char_u *font_name, int fontset UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3295 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3296 LOGFONT lf;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3297 GuiFont font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3298 char_u *p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3299
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3300 /* Load the font */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3301 if (get_logfont(&lf, font_name, NULL, TRUE) == OK)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3302 font = get_font_handle(&lf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3303 if (font == NOFONT)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3304 return FAIL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3305
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3306 if (font_name == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3307 font_name = (char_u *)lf.lfFaceName;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3308 #if defined(FEAT_MBYTE_IME) || defined(GLOBAL_IME)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3309 norm_logfont = lf;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3310 sub_logfont = lf;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3311 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3312 #ifdef FEAT_MBYTE_IME
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3313 update_im_font();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3314 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3315 gui_mch_free_font(gui.norm_font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3316 gui.norm_font = font;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3317 current_font_height = lf.lfHeight;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3318 GetFontSize(font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3319
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3320 p = logfont2name(lf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3321 if (p != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3322 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3323 hl_set_font_name(p);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3324
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3325 /* When setting 'guifont' to "*" replace it with the actual font name.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3326 * */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3327 if (STRCMP(font_name, "*") == 0 && STRCMP(p_guifont, "*") == 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3328 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3329 vim_free(p_guifont);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3330 p_guifont = p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3331 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3332 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3333 vim_free(p);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3334 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3335
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3336 gui_mch_free_font(gui.ital_font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3337 gui.ital_font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3338 gui_mch_free_font(gui.bold_font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3339 gui.bold_font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3340 gui_mch_free_font(gui.boldital_font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3341 gui.boldital_font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3342
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3343 if (!lf.lfItalic)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3344 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3345 lf.lfItalic = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3346 gui.ital_font = get_font_handle(&lf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3347 lf.lfItalic = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3348 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3349 if (lf.lfWeight < FW_BOLD)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3350 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3351 lf.lfWeight = FW_BOLD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3352 gui.bold_font = get_font_handle(&lf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3353 if (!lf.lfItalic)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3354 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3355 lf.lfItalic = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3356 gui.boldital_font = get_font_handle(&lf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3357 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3358 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3359
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3360 return OK;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3361 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3362
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3363 #ifndef WPF_RESTORETOMAXIMIZED
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3364 # define WPF_RESTORETOMAXIMIZED 2 /* just in case someone doesn't have it */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3365 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3366
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3367 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3368 * Return TRUE if the GUI window is maximized, filling the whole screen.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3369 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3370 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3371 gui_mch_maximized(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3372 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3373 WINDOWPLACEMENT wp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3374
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3375 wp.length = sizeof(WINDOWPLACEMENT);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3376 if (GetWindowPlacement(s_hwnd, &wp))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3377 return wp.showCmd == SW_SHOWMAXIMIZED
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3378 || (wp.showCmd == SW_SHOWMINIMIZED
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3379 && wp.flags == WPF_RESTORETOMAXIMIZED);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3380
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3381 return 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3382 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3383
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3384 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3385 * Called when the font changed while the window is maximized. Compute the
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3386 * new Rows and Columns. This is like resizing the window.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3387 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3388 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3389 gui_mch_newfont(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3390 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3391 RECT rect;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3392
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3393 GetWindowRect(s_hwnd, &rect);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3394 if (win_socket_id == 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3395 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3396 gui_resize_shell(rect.right - rect.left
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3397 - (GetSystemMetrics(SM_CXFRAME) +
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3398 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3399 rect.bottom - rect.top
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3400 - (GetSystemMetrics(SM_CYFRAME) +
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3401 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3402 - GetSystemMetrics(SM_CYCAPTION)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3403 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3404 - gui_mswin_get_menu_height(FALSE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3405 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3406 );
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3407 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3408 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3409 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3410 /* Inside another window, don't use the frame and border. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3411 gui_resize_shell(rect.right - rect.left,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3412 rect.bottom - rect.top
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3413 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3414 - gui_mswin_get_menu_height(FALSE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3415 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3416 );
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3417 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3418 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3419
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3420 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3421 * Set the window title
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3422 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3423 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3424 gui_mch_settitle(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3425 char_u *title,
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
3426 char_u *icon UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3427 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3428 set_window_title(s_hwnd, (title == NULL ? "VIM" : (char *)title));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3429 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3430
9834
80ace3687eec commit https://github.com/vim/vim/commit/a6b7a08ae04a3cd4d9c45c906bb7a197e2135179
Christian Brabandt <cb@256bit.org>
parents: 9428
diff changeset
3431 #if defined(FEAT_MOUSESHAPE) || defined(PROTO)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3432 /* Table for shape IDCs. Keep in sync with the mshape_names[] table in
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3433 * misc2.c! */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3434 static LPCSTR mshape_idcs[] =
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3435 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3436 IDC_ARROW, /* arrow */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3437 MAKEINTRESOURCE(0), /* blank */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3438 IDC_IBEAM, /* beam */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3439 IDC_SIZENS, /* updown */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3440 IDC_SIZENS, /* udsizing */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3441 IDC_SIZEWE, /* leftright */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3442 IDC_SIZEWE, /* lrsizing */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3443 IDC_WAIT, /* busy */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3444 IDC_NO, /* no */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3445 IDC_ARROW, /* crosshair */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3446 IDC_ARROW, /* hand1 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3447 IDC_ARROW, /* hand2 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3448 IDC_ARROW, /* pencil */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3449 IDC_ARROW, /* question */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3450 IDC_ARROW, /* right-arrow */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3451 IDC_UPARROW, /* up-arrow */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3452 IDC_ARROW /* last one */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3453 };
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3454
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3455 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3456 mch_set_mouse_shape(int shape)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3457 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3458 LPCSTR idc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3459
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3460 if (shape == MSHAPE_HIDE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3461 ShowCursor(FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3462 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3463 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3464 if (shape >= MSHAPE_NUMBERED)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3465 idc = IDC_ARROW;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3466 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3467 idc = mshape_idcs[shape];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3468 #ifdef SetClassLongPtr
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3469 SetClassLongPtr(s_textArea, GCLP_HCURSOR, (__int3264)(LONG_PTR)LoadCursor(NULL, idc));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3470 #else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3471 SetClassLong(s_textArea, GCL_HCURSOR, (long_u)LoadCursor(NULL, idc));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3472 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3473 if (!p_mh)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3474 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3475 POINT mp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3476
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3477 /* Set the position to make it redrawn with the new shape. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3478 (void)GetCursorPos((LPPOINT)&mp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3479 (void)SetCursorPos(mp.x, mp.y);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3480 ShowCursor(TRUE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3481 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3482 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3483 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3484 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3485
9834
80ace3687eec commit https://github.com/vim/vim/commit/a6b7a08ae04a3cd4d9c45c906bb7a197e2135179
Christian Brabandt <cb@256bit.org>
parents: 9428
diff changeset
3486 #if defined(FEAT_BROWSE) || defined(PROTO)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3487 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3488 * The file browser exists in two versions: with "W" uses wide characters,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3489 * without "W" the current codepage. When FEAT_MBYTE is defined and on
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3490 * Windows NT/2000/XP the "W" functions are used.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3491 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3492
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3493 # ifdef FEAT_MBYTE
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3494 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3495 * Wide version of convert_filter().
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3496 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3497 static WCHAR *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3498 convert_filterW(char_u *s)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3499 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3500 char_u *tmp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3501 int len;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3502 WCHAR *res;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3503
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3504 tmp = convert_filter(s);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3505 if (tmp == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3506 return NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3507 len = (int)STRLEN(s) + 3;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3508 res = enc_to_utf16(tmp, &len);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3509 vim_free(tmp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3510 return res;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3511 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3512
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3513 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3514 * Wide version of gui_mch_browse(). Keep in sync!
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3515 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3516 static char_u *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3517 gui_mch_browseW(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3518 int saving,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3519 char_u *title,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3520 char_u *dflt,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3521 char_u *ext,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3522 char_u *initdir,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3523 char_u *filter)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3524 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3525 /* We always use the wide function. This means enc_to_utf16() must work,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3526 * otherwise it fails miserably! */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3527 OPENFILENAMEW fileStruct;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3528 WCHAR fileBuf[MAXPATHL];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3529 WCHAR *wp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3530 int i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3531 WCHAR *titlep = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3532 WCHAR *extp = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3533 WCHAR *initdirp = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3534 WCHAR *filterp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3535 char_u *p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3536
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3537 if (dflt == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3538 fileBuf[0] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3539 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3540 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3541 wp = enc_to_utf16(dflt, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3542 if (wp == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3543 fileBuf[0] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3544 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3545 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3546 for (i = 0; wp[i] != NUL && i < MAXPATHL - 1; ++i)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3547 fileBuf[i] = wp[i];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3548 fileBuf[i] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3549 vim_free(wp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3550 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3551 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3552
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3553 /* Convert the filter to Windows format. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3554 filterp = convert_filterW(filter);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3555
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3556 vim_memset(&fileStruct, 0, sizeof(OPENFILENAMEW));
10440
f54e4c691de4 commit https://github.com/vim/vim/commit/b04a98f6c3cca14bf055934b0a793f4dc376858b
Christian Brabandt <cb@256bit.org>
parents: 10438
diff changeset
3557 # ifdef OPENFILENAME_SIZE_VERSION_400W
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3558 /* be compatible with Windows NT 4.0 */
8571
debe6347024d commit https://github.com/vim/vim/commit/89e375a88f3eceb73bbd97e78aca1a1c4647c897
Christian Brabandt <cb@256bit.org>
parents: 8281
diff changeset
3559 fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400W;
10440
f54e4c691de4 commit https://github.com/vim/vim/commit/b04a98f6c3cca14bf055934b0a793f4dc376858b
Christian Brabandt <cb@256bit.org>
parents: 10438
diff changeset
3560 # else
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3561 fileStruct.lStructSize = sizeof(fileStruct);
10440
f54e4c691de4 commit https://github.com/vim/vim/commit/b04a98f6c3cca14bf055934b0a793f4dc376858b
Christian Brabandt <cb@256bit.org>
parents: 10438
diff changeset
3562 # endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3563
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3564 if (title != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3565 titlep = enc_to_utf16(title, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3566 fileStruct.lpstrTitle = titlep;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3567
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3568 if (ext != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3569 extp = enc_to_utf16(ext, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3570 fileStruct.lpstrDefExt = extp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3571
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3572 fileStruct.lpstrFile = fileBuf;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3573 fileStruct.nMaxFile = MAXPATHL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3574 fileStruct.lpstrFilter = filterp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3575 fileStruct.hwndOwner = s_hwnd; /* main Vim window is owner*/
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3576 /* has an initial dir been specified? */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3577 if (initdir != NULL && *initdir != NUL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3578 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3579 /* Must have backslashes here, no matter what 'shellslash' says */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3580 initdirp = enc_to_utf16(initdir, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3581 if (initdirp != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3582 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3583 for (wp = initdirp; *wp != NUL; ++wp)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3584 if (*wp == '/')
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3585 *wp = '\\';
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3586 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3587 fileStruct.lpstrInitialDir = initdirp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3588 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3589
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3590 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3591 * TODO: Allow selection of multiple files. Needs another arg to this
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3592 * function to ask for it, and need to use OFN_ALLOWMULTISELECT below.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3593 * Also, should we use OFN_FILEMUSTEXIST when opening? Vim can edit on
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3594 * files that don't exist yet, so I haven't put it in. What about
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3595 * OFN_PATHMUSTEXIST?
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3596 * Don't use OFN_OVERWRITEPROMPT, Vim has its own ":confirm" dialog.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3597 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3598 fileStruct.Flags = (OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY);
10440
f54e4c691de4 commit https://github.com/vim/vim/commit/b04a98f6c3cca14bf055934b0a793f4dc376858b
Christian Brabandt <cb@256bit.org>
parents: 10438
diff changeset
3599 # ifdef FEAT_SHORTCUT
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3600 if (curbuf->b_p_bin)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3601 fileStruct.Flags |= OFN_NODEREFERENCELINKS;
10440
f54e4c691de4 commit https://github.com/vim/vim/commit/b04a98f6c3cca14bf055934b0a793f4dc376858b
Christian Brabandt <cb@256bit.org>
parents: 10438
diff changeset
3602 # endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3603 if (saving)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3604 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3605 if (!GetSaveFileNameW(&fileStruct))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3606 return NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3607 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3608 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3609 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3610 if (!GetOpenFileNameW(&fileStruct))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3611 return NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3612 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3613
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3614 vim_free(filterp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3615 vim_free(initdirp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3616 vim_free(titlep);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3617 vim_free(extp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3618
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3619 /* Convert from UCS2 to 'encoding'. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3620 p = utf16_to_enc(fileBuf, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3621 if (p != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3622 /* when out of memory we get garbage for non-ASCII chars */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3623 STRCPY(fileBuf, p);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3624 vim_free(p);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3625
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3626 /* Give focus back to main window (when using MDI). */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3627 SetFocus(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3628
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3629 /* Shorten the file name if possible */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3630 return vim_strsave(shorten_fname1((char_u *)fileBuf));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3631 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3632 # endif /* FEAT_MBYTE */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3633
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3634
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3635 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3636 * Convert the string s to the proper format for a filter string by replacing
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3637 * the \t and \n delimiters with \0.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3638 * Returns the converted string in allocated memory.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3639 *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3640 * Keep in sync with convert_filterW() above!
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3641 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3642 static char_u *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3643 convert_filter(char_u *s)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3644 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3645 char_u *res;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3646 unsigned s_len = (unsigned)STRLEN(s);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3647 unsigned i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3648
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3649 res = alloc(s_len + 3);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3650 if (res != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3651 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3652 for (i = 0; i < s_len; ++i)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3653 if (s[i] == '\t' || s[i] == '\n')
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3654 res[i] = '\0';
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3655 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3656 res[i] = s[i];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3657 res[s_len] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3658 /* Add two extra NULs to make sure it's properly terminated. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3659 res[s_len + 1] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3660 res[s_len + 2] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3661 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3662 return res;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3663 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3664
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3665 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3666 * Select a directory.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3667 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3668 char_u *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3669 gui_mch_browsedir(char_u *title, char_u *initdir)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3670 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3671 /* We fake this: Use a filter that doesn't select anything and a default
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3672 * file name that won't be used. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3673 return gui_mch_browse(0, title, (char_u *)_("Not Used"), NULL,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3674 initdir, (char_u *)_("Directory\t*.nothing\n"));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3675 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3676
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3677 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3678 * Pop open a file browser and return the file selected, in allocated memory,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3679 * or NULL if Cancel is hit.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3680 * saving - TRUE if the file will be saved to, FALSE if it will be opened.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3681 * title - Title message for the file browser dialog.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3682 * dflt - Default name of file.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3683 * ext - Default extension to be added to files without extensions.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3684 * initdir - directory in which to open the browser (NULL = current dir)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3685 * filter - Filter for matched files to choose from.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3686 *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3687 * Keep in sync with gui_mch_browseW() above!
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3688 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3689 char_u *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3690 gui_mch_browse(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3691 int saving,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3692 char_u *title,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3693 char_u *dflt,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3694 char_u *ext,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3695 char_u *initdir,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3696 char_u *filter)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3697 {
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3698 # ifdef FEAT_MBYTE
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3699 return gui_mch_browseW(saving, title, dflt, ext, initdir, filter);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3700 # else
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3701 OPENFILENAME fileStruct;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3702 char_u fileBuf[MAXPATHL];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3703 char_u *initdirp = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3704 char_u *filterp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3705 char_u *p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3706
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3707 if (dflt == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3708 fileBuf[0] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3709 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3710 vim_strncpy(fileBuf, dflt, MAXPATHL - 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3711
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3712 /* Convert the filter to Windows format. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3713 filterp = convert_filter(filter);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3714
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3715 vim_memset(&fileStruct, 0, sizeof(OPENFILENAME));
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3716 # ifdef OPENFILENAME_SIZE_VERSION_400
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3717 /* be compatible with Windows NT 4.0 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3718 fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400;
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3719 # else
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3720 fileStruct.lStructSize = sizeof(fileStruct);
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3721 # endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3722
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3723 fileStruct.lpstrTitle = (LPSTR)title;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3724 fileStruct.lpstrDefExt = (LPSTR)ext;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3725
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3726 fileStruct.lpstrFile = (LPSTR)fileBuf;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3727 fileStruct.nMaxFile = MAXPATHL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3728 fileStruct.lpstrFilter = (LPSTR)filterp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3729 fileStruct.hwndOwner = s_hwnd; /* main Vim window is owner*/
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3730 /* has an initial dir been specified? */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3731 if (initdir != NULL && *initdir != NUL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3732 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3733 /* Must have backslashes here, no matter what 'shellslash' says */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3734 initdirp = vim_strsave(initdir);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3735 if (initdirp != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3736 for (p = initdirp; *p != NUL; ++p)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3737 if (*p == '/')
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3738 *p = '\\';
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3739 fileStruct.lpstrInitialDir = (LPSTR)initdirp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3740 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3741
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3742 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3743 * TODO: Allow selection of multiple files. Needs another arg to this
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3744 * function to ask for it, and need to use OFN_ALLOWMULTISELECT below.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3745 * Also, should we use OFN_FILEMUSTEXIST when opening? Vim can edit on
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3746 * files that don't exist yet, so I haven't put it in. What about
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3747 * OFN_PATHMUSTEXIST?
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3748 * Don't use OFN_OVERWRITEPROMPT, Vim has its own ":confirm" dialog.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3749 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3750 fileStruct.Flags = (OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY);
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3751 # ifdef FEAT_SHORTCUT
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3752 if (curbuf->b_p_bin)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3753 fileStruct.Flags |= OFN_NODEREFERENCELINKS;
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3754 # endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3755 if (saving)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3756 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3757 if (!GetSaveFileName(&fileStruct))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3758 return NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3759 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3760 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3761 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3762 if (!GetOpenFileName(&fileStruct))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3763 return NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3764 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3765
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3766 vim_free(filterp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3767 vim_free(initdirp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3768
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3769 /* Give focus back to main window (when using MDI). */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3770 SetFocus(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3771
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3772 /* Shorten the file name if possible */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3773 return vim_strsave(shorten_fname1((char_u *)fileBuf));
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3774 # endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3775 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3776 #endif /* FEAT_BROWSE */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3777
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3778 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3779 _OnDropFiles(
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
3780 HWND hwnd UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3781 HDROP hDrop)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3782 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3783 #ifdef FEAT_WINDOWS
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3784 # define BUFPATHLEN _MAX_PATH
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3785 # define DRAGQVAL 0xFFFFFFFF
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3786 # ifdef FEAT_MBYTE
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3787 WCHAR wszFile[BUFPATHLEN];
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3788 # endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3789 char szFile[BUFPATHLEN];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3790 UINT cFiles = DragQueryFile(hDrop, DRAGQVAL, NULL, 0);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3791 UINT i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3792 char_u **fnames;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3793 POINT pt;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3794 int_u modifiers = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3795
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3796 /* TRACE("_OnDropFiles: %d files dropped\n", cFiles); */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3797
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3798 /* Obtain dropped position */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3799 DragQueryPoint(hDrop, &pt);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3800 MapWindowPoints(s_hwnd, s_textArea, &pt, 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3801
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3802 reset_VIsual();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3803
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3804 fnames = (char_u **)alloc(cFiles * sizeof(char_u *));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3805
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3806 if (fnames != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3807 for (i = 0; i < cFiles; ++i)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3808 {
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3809 # ifdef FEAT_MBYTE
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3810 if (DragQueryFileW(hDrop, i, wszFile, BUFPATHLEN) > 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3811 fnames[i] = utf16_to_enc(wszFile, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3812 else
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
3813 # endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3814 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3815 DragQueryFile(hDrop, i, szFile, BUFPATHLEN);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3816 fnames[i] = vim_strsave((char_u *)szFile);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3817 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3818 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3819
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3820 DragFinish(hDrop);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3821
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3822 if (fnames != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3823 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3824 if ((GetKeyState(VK_SHIFT) & 0x8000) != 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3825 modifiers |= MOUSE_SHIFT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3826 if ((GetKeyState(VK_CONTROL) & 0x8000) != 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3827 modifiers |= MOUSE_CTRL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3828 if ((GetKeyState(VK_MENU) & 0x8000) != 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3829 modifiers |= MOUSE_ALT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3830
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3831 gui_handle_drop(pt.x, pt.y, modifiers, fnames, cFiles);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3832
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3833 s_need_activate = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3834 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3835 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3836 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3837
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3838 static int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3839 _OnScroll(
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
3840 HWND hwnd UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3841 HWND hwndCtl,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3842 UINT code,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3843 int pos)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3844 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3845 static UINT prev_code = 0; /* code of previous call */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3846 scrollbar_T *sb, *sb_info;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3847 long val;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3848 int dragging = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3849 int dont_scroll_save = dont_scroll;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3850 SCROLLINFO si;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3851
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3852 si.cbSize = sizeof(si);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3853 si.fMask = SIF_POS;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3854
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3855 sb = gui_mswin_find_scrollbar(hwndCtl);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3856 if (sb == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3857 return 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3858
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3859 if (sb->wp != NULL) /* Left or right scrollbar */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3860 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3861 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3862 * Careful: need to get scrollbar info out of first (left) scrollbar
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3863 * for window, but keep real scrollbar too because we must pass it to
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3864 * gui_drag_scrollbar().
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3865 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3866 sb_info = &sb->wp->w_scrollbars[0];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3867 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3868 else /* Bottom scrollbar */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3869 sb_info = sb;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3870 val = sb_info->value;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3871
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3872 switch (code)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3873 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3874 case SB_THUMBTRACK:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3875 val = pos;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3876 dragging = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3877 if (sb->scroll_shift > 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3878 val <<= sb->scroll_shift;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3879 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3880 case SB_LINEDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3881 val++;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3882 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3883 case SB_LINEUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3884 val--;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3885 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3886 case SB_PAGEDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3887 val += (sb_info->size > 2 ? sb_info->size - 2 : 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3888 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3889 case SB_PAGEUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3890 val -= (sb_info->size > 2 ? sb_info->size - 2 : 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3891 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3892 case SB_TOP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3893 val = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3894 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3895 case SB_BOTTOM:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3896 val = sb_info->max;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3897 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3898 case SB_ENDSCROLL:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3899 if (prev_code == SB_THUMBTRACK)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3900 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3901 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3902 * "pos" only gives us 16-bit data. In case of large file,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3903 * use GetScrollPos() which returns 32-bit. Unfortunately it
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3904 * is not valid while the scrollbar is being dragged.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3905 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3906 val = GetScrollPos(hwndCtl, SB_CTL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3907 if (sb->scroll_shift > 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3908 val <<= sb->scroll_shift;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3909 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3910 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3911
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3912 default:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3913 /* TRACE("Unknown scrollbar event %d\n", code); */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3914 return 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3915 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3916 prev_code = code;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3917
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3918 si.nPos = (sb->scroll_shift > 0) ? val >> sb->scroll_shift : val;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3919 SetScrollInfo(hwndCtl, SB_CTL, &si, TRUE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3920
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3921 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3922 * When moving a vertical scrollbar, move the other vertical scrollbar too.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3923 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3924 if (sb->wp != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3925 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3926 scrollbar_T *sba = sb->wp->w_scrollbars;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3927 HWND id = sba[ (sb == sba + SBAR_LEFT) ? SBAR_RIGHT : SBAR_LEFT].id;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3928
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3929 SetScrollInfo(id, SB_CTL, &si, TRUE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3930 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3931
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3932 /* Don't let us be interrupted here by another message. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3933 s_busy_processing = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3934
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3935 /* When "allow_scrollbar" is FALSE still need to remember the new
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3936 * position, but don't actually scroll by setting "dont_scroll". */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3937 dont_scroll = !allow_scrollbar;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3938
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3939 gui_drag_scrollbar(sb, val, dragging);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3940
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3941 s_busy_processing = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3942 dont_scroll = dont_scroll_save;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3943
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3944 return 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3945 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3946
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3947
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3948 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3949 * Get command line arguments.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3950 * Use "prog" as the name of the program and "cmdline" as the arguments.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3951 * Copy the arguments to allocated memory.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3952 * Return the number of arguments (including program name).
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3953 * Return pointers to the arguments in "argvp". Memory is allocated with
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3954 * malloc(), use free() instead of vim_free().
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3955 * Return pointer to buffer in "tofree".
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3956 * Returns zero when out of memory.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3957 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3958 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3959 get_cmd_args(char *prog, char *cmdline, char ***argvp, char **tofree)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3960 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3961 int i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3962 char *p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3963 char *progp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3964 char *pnew = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3965 char *newcmdline;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3966 int inquote;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3967 int argc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3968 char **argv = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3969 int round;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3970
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3971 *tofree = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3972
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3973 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3974 /* Try using the Unicode version first, it takes care of conversion when
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3975 * 'encoding' is changed. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3976 argc = get_cmd_argsW(&argv);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3977 if (argc != 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3978 goto done;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3979 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3980
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3981 /* Handle the program name. Remove the ".exe" extension, and find the 1st
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3982 * non-space. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3983 p = strrchr(prog, '.');
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3984 if (p != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3985 *p = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3986 for (progp = prog; *progp == ' '; ++progp)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3987 ;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3988
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3989 /* The command line is copied to allocated memory, so that we can change
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3990 * it. Add the size of the string, the separating NUL and a terminating
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3991 * NUL. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3992 newcmdline = malloc(STRLEN(cmdline) + STRLEN(progp) + 2);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3993 if (newcmdline == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3994 return 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3995
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3996 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3997 * First round: count the number of arguments ("pnew" == NULL).
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3998 * Second round: produce the arguments.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3999 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4000 for (round = 1; round <= 2; ++round)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4001 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4002 /* First argument is the program name. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4003 if (pnew != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4004 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4005 argv[0] = pnew;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4006 strcpy(pnew, progp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4007 pnew += strlen(pnew);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4008 *pnew++ = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4009 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4010
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4011 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4012 * Isolate each argument and put it in argv[].
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4013 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4014 p = cmdline;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4015 argc = 1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4016 while (*p != NUL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4017 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4018 inquote = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4019 if (pnew != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4020 argv[argc] = pnew;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4021 ++argc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4022 while (*p != NUL && (inquote || (*p != ' ' && *p != '\t')))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4023 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4024 /* Backslashes are only special when followed by a double
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4025 * quote. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4026 i = (int)strspn(p, "\\");
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4027 if (p[i] == '"')
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4028 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4029 /* Halve the number of backslashes. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4030 if (i > 1 && pnew != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4031 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4032 vim_memset(pnew, '\\', i / 2);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4033 pnew += i / 2;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4034 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4035
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4036 /* Even nr of backslashes toggles quoting, uneven copies
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4037 * the double quote. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4038 if ((i & 1) == 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4039 inquote = !inquote;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4040 else if (pnew != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4041 *pnew++ = '"';
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4042 p += i + 1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4043 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4044 else if (i > 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4045 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4046 /* Copy span of backslashes unmodified. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4047 if (pnew != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4048 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4049 vim_memset(pnew, '\\', i);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4050 pnew += i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4051 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4052 p += i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4053 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4054 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4055 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4056 if (pnew != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4057 *pnew++ = *p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4058 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4059 /* Can't use mb_* functions, because 'encoding' is not
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4060 * initialized yet here. */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4061 if (IsDBCSLeadByte(*p))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4062 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4063 ++p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4064 if (pnew != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4065 *pnew++ = *p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4066 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4067 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4068 ++p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4069 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4070 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4071
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4072 if (pnew != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4073 *pnew++ = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4074 while (*p == ' ' || *p == '\t')
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4075 ++p; /* advance until a non-space */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4076 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4077
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4078 if (round == 1)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4079 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4080 argv = (char **)malloc((argc + 1) * sizeof(char *));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4081 if (argv == NULL )
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4082 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4083 free(newcmdline);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4084 return 0; /* malloc error */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4085 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4086 pnew = newcmdline;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4087 *tofree = newcmdline;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4088 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4089 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4090
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4091 #ifdef FEAT_MBYTE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4092 done:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4093 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4094 argv[argc] = NULL; /* NULL-terminated list */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4095 *argvp = argv;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4096 return argc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4097 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4098
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4099 #ifdef FEAT_XPM_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4100 # include "xpm_w32.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4101 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4102
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4103 #ifdef PROTO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4104 # define WINAPI
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4105 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4106
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4107 #ifdef __MINGW32__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4108 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4109 * Add a lot of missing defines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4110 * They are not always missing, we need the #ifndef's.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4111 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4112 # ifndef _cdecl
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4113 # define _cdecl
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4114 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4115 # ifndef IsMinimized
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4116 # define IsMinimized(hwnd) IsIconic(hwnd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4117 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4118 # ifndef IsMaximized
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4119 # define IsMaximized(hwnd) IsZoomed(hwnd)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4120 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4121 # ifndef SelectFont
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4122 # define SelectFont(hdc, hfont) ((HFONT)SelectObject((hdc), (HGDIOBJ)(HFONT)(hfont)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4123 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4124 # ifndef GetStockBrush
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4125 # define GetStockBrush(i) ((HBRUSH)GetStockObject(i))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4126 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4127 # ifndef DeleteBrush
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4128 # define DeleteBrush(hbr) DeleteObject((HGDIOBJ)(HBRUSH)(hbr))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4129 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4130
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4131 # ifndef HANDLE_WM_RBUTTONDBLCLK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4132 # define HANDLE_WM_RBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4133 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4134 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4135 # ifndef HANDLE_WM_MBUTTONUP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4136 # define HANDLE_WM_MBUTTONUP(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4137 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4138 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4139 # ifndef HANDLE_WM_MBUTTONDBLCLK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4140 # define HANDLE_WM_MBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4141 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4142 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4143 # ifndef HANDLE_WM_LBUTTONDBLCLK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4144 # define HANDLE_WM_LBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4145 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4146 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4147 # ifndef HANDLE_WM_RBUTTONDOWN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4148 # define HANDLE_WM_RBUTTONDOWN(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4149 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4150 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4151 # ifndef HANDLE_WM_MOUSEMOVE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4152 # define HANDLE_WM_MOUSEMOVE(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4153 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4154 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4155 # ifndef HANDLE_WM_RBUTTONUP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4156 # define HANDLE_WM_RBUTTONUP(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4157 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4158 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4159 # ifndef HANDLE_WM_MBUTTONDOWN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4160 # define HANDLE_WM_MBUTTONDOWN(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4161 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4162 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4163 # ifndef HANDLE_WM_LBUTTONUP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4164 # define HANDLE_WM_LBUTTONUP(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4165 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4166 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4167 # ifndef HANDLE_WM_LBUTTONDOWN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4168 # define HANDLE_WM_LBUTTONDOWN(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4169 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4170 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4171 # ifndef HANDLE_WM_SYSCHAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4172 # define HANDLE_WM_SYSCHAR(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4173 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4174 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4175 # ifndef HANDLE_WM_ACTIVATEAPP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4176 # define HANDLE_WM_ACTIVATEAPP(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4177 ((fn)((hwnd), (BOOL)(wParam), (DWORD)(lParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4178 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4179 # ifndef HANDLE_WM_WINDOWPOSCHANGING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4180 # define HANDLE_WM_WINDOWPOSCHANGING(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4181 (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (LPWINDOWPOS)(lParam))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4182 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4183 # ifndef HANDLE_WM_VSCROLL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4184 # define HANDLE_WM_VSCROLL(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4185 ((fn)((hwnd), (HWND)(lParam), (UINT)(LOWORD(wParam)), (int)(short)HIWORD(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4186 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4187 # ifndef HANDLE_WM_SETFOCUS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4188 # define HANDLE_WM_SETFOCUS(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4189 ((fn)((hwnd), (HWND)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4190 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4191 # ifndef HANDLE_WM_KILLFOCUS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4192 # define HANDLE_WM_KILLFOCUS(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4193 ((fn)((hwnd), (HWND)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4194 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4195 # ifndef HANDLE_WM_HSCROLL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4196 # define HANDLE_WM_HSCROLL(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4197 ((fn)((hwnd), (HWND)(lParam), (UINT)(LOWORD(wParam)), (int)(short)HIWORD(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4198 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4199 # ifndef HANDLE_WM_DROPFILES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4200 # define HANDLE_WM_DROPFILES(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4201 ((fn)((hwnd), (HDROP)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4202 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4203 # ifndef HANDLE_WM_CHAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4204 # define HANDLE_WM_CHAR(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4205 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4206 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4207 # ifndef HANDLE_WM_SYSDEADCHAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4208 # define HANDLE_WM_SYSDEADCHAR(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4209 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4210 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4211 # ifndef HANDLE_WM_DEADCHAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4212 # define HANDLE_WM_DEADCHAR(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4213 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4214 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4215 #endif /* __MINGW32__ */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4217
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4218 /* Some parameters for tearoff menus. All in pixels. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4219 #define TEAROFF_PADDING_X 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4220 #define TEAROFF_BUTTON_PAD_X 8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4221 #define TEAROFF_MIN_WIDTH 200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4222 #define TEAROFF_SUBMENU_LABEL ">>"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4223 #define TEAROFF_COLUMN_PADDING 3 // # spaces to pad column with.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4224
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4225
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4226 /* For the Intellimouse: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4227 #ifndef WM_MOUSEWHEEL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4228 #define WM_MOUSEWHEEL 0x20a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4229 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4230
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4231
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4232 #ifdef FEAT_BEVAL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4233 # define ID_BEVAL_TOOLTIP 200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4234 # define BEVAL_TEXT_LEN MAXPATHL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4235
2224
a0cce15dd2a9 Fix definition of UINT_PTR for 64 bit systems.
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
4236 #if (defined(_MSC_VER) && _MSC_VER < 1300) || !defined(MAXULONG_PTR)
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1489
diff changeset
4237 /* Work around old versions of basetsd.h which wrongly declares
82b5078be2dd updated for version 7.2a
vimboss
parents: 1489
diff changeset
4238 * UINT_PTR as unsigned long. */
2224
a0cce15dd2a9 Fix definition of UINT_PTR for 64 bit systems.
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
4239 # undef UINT_PTR
837
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 835
diff changeset
4240 # define UINT_PTR UINT
6bb1fa855dc9 updated for version 7.0e03
vimboss
parents: 835
diff changeset
4241 #endif
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4242
7801
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 7797
diff changeset
4243 static void make_tooltip(BalloonEval *beval, char *text, POINT pt);
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 7797
diff changeset
4244 static void delete_tooltip(BalloonEval *beval);
a1e71a01dbd6 commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents: 7797
diff changeset
4245 static VOID CALLBACK BevalTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4246
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4247 static BalloonEval *cur_beval = NULL;
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 824
diff changeset
4248 static UINT_PTR BevalTimerId = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4249 static DWORD LastActivity = 0;
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4250
3927
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3248
diff changeset
4251
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3248
diff changeset
4252 /* cproto fails on missing include files */
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3248
diff changeset
4253 #ifndef PROTO
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3248
diff changeset
4254
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4255 /*
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4256 * excerpts from headers since this may not be presented
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4257 * in the extremely old compilers
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4258 */
3927
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3248
diff changeset
4259 # include <pshpack1.h>
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3248
diff changeset
4260
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3248
diff changeset
4261 #endif
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4262
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4263 typedef struct _DllVersionInfo
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4264 {
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4265 DWORD cbSize;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4266 DWORD dwMajorVersion;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4267 DWORD dwMinorVersion;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4268 DWORD dwBuildNumber;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4269 DWORD dwPlatformID;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4270 } DLLVERSIONINFO;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4271
3927
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3248
diff changeset
4272 #ifndef PROTO
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3248
diff changeset
4273 # include <poppack.h>
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3248
diff changeset
4274 #endif
2026
d3571ca62cd6 updated for version 7.2-323
vimboss
parents: 1795
diff changeset
4275
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4276 typedef struct tagTOOLINFOA_NEW
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4277 {
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4278 UINT cbSize;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4279 UINT uFlags;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4280 HWND hwnd;
2026
d3571ca62cd6 updated for version 7.2-323
vimboss
parents: 1795
diff changeset
4281 UINT_PTR uId;
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4282 RECT rect;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4283 HINSTANCE hinst;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4284 LPSTR lpszText;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4285 LPARAM lParam;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4286 } TOOLINFO_NEW;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4287
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4288 typedef struct tagNMTTDISPINFO_NEW
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4289 {
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4290 NMHDR hdr;
2026
d3571ca62cd6 updated for version 7.2-323
vimboss
parents: 1795
diff changeset
4291 LPSTR lpszText;
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4292 char szText[80];
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4293 HINSTANCE hinst;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4294 UINT uFlags;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4295 LPARAM lParam;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4296 } NMTTDISPINFO_NEW;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4297
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4298 typedef HRESULT (WINAPI* DLLGETVERSIONPROC)(DLLVERSIONINFO *);
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4299 #ifndef TTM_SETMAXTIPWIDTH
842
a209672376fd updated for version 7.0f
vimboss
parents: 840
diff changeset
4300 # define TTM_SETMAXTIPWIDTH (WM_USER+24)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4301 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4302
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4303 #ifndef TTF_DI_SETITEM
842
a209672376fd updated for version 7.0f
vimboss
parents: 840
diff changeset
4304 # define TTF_DI_SETITEM 0x8000
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4305 #endif
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4306
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4307 #ifndef TTN_GETDISPINFO
842
a209672376fd updated for version 7.0f
vimboss
parents: 840
diff changeset
4308 # define TTN_GETDISPINFO (TTN_FIRST - 0)
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4309 #endif
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4310
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4311 #endif /* defined(FEAT_BEVAL) */
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4312
1213
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4313 #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE)
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4314 /* Older MSVC compilers don't have LPNMTTDISPINFO[AW] thus we need to define
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4315 * it here if LPNMTTDISPINFO isn't defined.
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4316 * MingW doesn't define LPNMTTDISPINFO but typedefs it. Thus we need to check
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4317 * _MSC_VER. */
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4318 # if !defined(LPNMTTDISPINFO) && defined(_MSC_VER)
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4319 typedef struct tagNMTTDISPINFOA {
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4320 NMHDR hdr;
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4321 LPSTR lpszText;
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4322 char szText[80];
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4323 HINSTANCE hinst;
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4324 UINT uFlags;
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4325 LPARAM lParam;
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4326 } NMTTDISPINFOA, *LPNMTTDISPINFOA;
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4327 # define LPNMTTDISPINFO LPNMTTDISPINFOA
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4328
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4329 # ifdef FEAT_MBYTE
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4330 typedef struct tagNMTTDISPINFOW {
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4331 NMHDR hdr;
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4332 LPWSTR lpszText;
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4333 WCHAR szText[80];
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4334 HINSTANCE hinst;
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4335 UINT uFlags;
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4336 LPARAM lParam;
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4337 } NMTTDISPINFOW, *LPNMTTDISPINFOW;
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4338 # endif
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4339 # endif
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4340 #endif
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
4341
842
a209672376fd updated for version 7.0f
vimboss
parents: 840
diff changeset
4342 #ifndef TTN_GETDISPINFOW
a209672376fd updated for version 7.0f
vimboss
parents: 840
diff changeset
4343 # define TTN_GETDISPINFOW (TTN_FIRST - 10)
a209672376fd updated for version 7.0f
vimboss
parents: 840
diff changeset
4344 #endif
a209672376fd updated for version 7.0f
vimboss
parents: 840
diff changeset
4345
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4346 /* Local variables: */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4347
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4348 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4349 static UINT s_menu_id = 100;
2614
56ecdb792c33 updated for version 7.3.036
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
4350 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4351
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4352 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4353 * Use the system font for dialogs and tear-off menus. Remove this line to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4354 * use DLG_FONT_NAME.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4355 */
2614
56ecdb792c33 updated for version 7.3.036
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
4356 #define USE_SYSMENU_FONT
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4357
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4358 #define VIM_NAME "vim"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4359 #define VIM_CLASS "Vim"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4360 #define VIM_CLASSW L"Vim"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4361
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4362 /* Initial size for the dialog template. For gui_mch_dialog() it's fixed,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4363 * thus there should be room for every dialog. For tearoffs it's made bigger
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4364 * when needed. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4365 #define DLG_ALLOC_SIZE 16 * 1024
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4366
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4367 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4368 * stuff for dialogs, menus, tearoffs etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4369 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4370 static LRESULT APIENTRY dialog_callback(HWND, UINT, WPARAM, LPARAM);
8138
f52504c10387 commit https://github.com/vim/vim/commit/065bbac8adfe29a09958570237d223457f235c6c
Christian Brabandt <cb@256bit.org>
parents: 8108
diff changeset
4371 #ifdef FEAT_TEAROFF
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4372 static LRESULT APIENTRY tearoff_callback(HWND, UINT, WPARAM, LPARAM);
8138
f52504c10387 commit https://github.com/vim/vim/commit/065bbac8adfe29a09958570237d223457f235c6c
Christian Brabandt <cb@256bit.org>
parents: 8108
diff changeset
4373 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4374 static PWORD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4375 add_dialog_element(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4376 PWORD p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4377 DWORD lStyle,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4378 WORD x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4379 WORD y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4380 WORD w,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4381 WORD h,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4382 WORD Id,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4383 WORD clss,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4384 const char *caption);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4385 static LPWORD lpwAlign(LPWORD);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4386 static int nCopyAnsiToWideChar(LPWORD, LPSTR);
8138
f52504c10387 commit https://github.com/vim/vim/commit/065bbac8adfe29a09958570237d223457f235c6c
Christian Brabandt <cb@256bit.org>
parents: 8108
diff changeset
4387 #if defined(FEAT_MENU) && defined(FEAT_TEAROFF)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4388 static void gui_mch_tearoff(char_u *title, vimmenu_T *menu, int initX, int initY);
8138
f52504c10387 commit https://github.com/vim/vim/commit/065bbac8adfe29a09958570237d223457f235c6c
Christian Brabandt <cb@256bit.org>
parents: 8108
diff changeset
4389 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4390 static void get_dialog_font_metrics(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4391
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4392 static int dialog_default_button = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4393
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4394 /* Intellimouse support */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4395 static int mouse_scroll_lines = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4396
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4397 static int s_usenewlook; /* emulate W95/NT4 non-bold dialogs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4398 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4399 static void initialise_toolbar(void);
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
4400 static LRESULT CALLBACK toolbar_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4401 static int get_toolbar_bitmap(vimmenu_T *menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4402 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4403
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4404 #ifdef FEAT_GUI_TABLINE
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4405 static void initialise_tabline(void);
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
4406 static LRESULT CALLBACK tabline_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4407 #endif
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4408
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4409 #ifdef FEAT_MBYTE_IME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4410 static LRESULT _OnImeComposition(HWND hwnd, WPARAM dbcs, LPARAM param);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4411 static char_u *GetResultStr(HWND hwnd, int GCS, int *lenp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4412 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4413 #if defined(FEAT_MBYTE_IME) && defined(DYNAMIC_IME)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4414 # ifdef NOIME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4415 typedef struct tagCOMPOSITIONFORM {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4416 DWORD dwStyle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4417 POINT ptCurrentPos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4418 RECT rcArea;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4419 } COMPOSITIONFORM, *PCOMPOSITIONFORM, NEAR *NPCOMPOSITIONFORM, FAR *LPCOMPOSITIONFORM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4420 typedef HANDLE HIMC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4421 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4422
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4423 static HINSTANCE hLibImm = NULL;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4424 static LONG (WINAPI *pImmGetCompositionStringA)(HIMC, DWORD, LPVOID, DWORD);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4425 static LONG (WINAPI *pImmGetCompositionStringW)(HIMC, DWORD, LPVOID, DWORD);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4426 static HIMC (WINAPI *pImmGetContext)(HWND);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4427 static HIMC (WINAPI *pImmAssociateContext)(HWND, HIMC);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4428 static BOOL (WINAPI *pImmReleaseContext)(HWND, HIMC);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4429 static BOOL (WINAPI *pImmGetOpenStatus)(HIMC);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4430 static BOOL (WINAPI *pImmSetOpenStatus)(HIMC, BOOL);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4431 static BOOL (WINAPI *pImmGetCompositionFont)(HIMC, LPLOGFONTA);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4432 static BOOL (WINAPI *pImmSetCompositionFont)(HIMC, LPLOGFONTA);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4433 static BOOL (WINAPI *pImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4434 static BOOL (WINAPI *pImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD);
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
4435 static BOOL (WINAPI *pImmSetConversionStatus)(HIMC, DWORD, DWORD);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4436 static void dyn_imm_load(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4437 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4438 # define pImmGetCompositionStringA ImmGetCompositionStringA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4439 # define pImmGetCompositionStringW ImmGetCompositionStringW
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4440 # define pImmGetContext ImmGetContext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4441 # define pImmAssociateContext ImmAssociateContext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4442 # define pImmReleaseContext ImmReleaseContext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4443 # define pImmGetOpenStatus ImmGetOpenStatus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4444 # define pImmSetOpenStatus ImmSetOpenStatus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4445 # define pImmGetCompositionFont ImmGetCompositionFontA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4446 # define pImmSetCompositionFont ImmSetCompositionFontA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4447 # define pImmSetCompositionWindow ImmSetCompositionWindow
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4448 # define pImmGetConversionStatus ImmGetConversionStatus
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
4449 # define pImmSetConversionStatus ImmSetConversionStatus
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4450 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4451
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4452 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4453 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4454 * Figure out how high the menu bar is at the moment.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4455 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4456 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4457 gui_mswin_get_menu_height(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4458 int fix_window) /* If TRUE, resize window if menu height changed */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4459 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4460 static int old_menu_height = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4462 RECT rc1, rc2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4463 int num;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4464 int menu_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4465
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4466 if (gui.menu_is_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4467 num = GetMenuItemCount(s_menuBar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4468 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4469 num = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4470
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4471 if (num == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4472 menu_height = 0;
6714
dc96dd80aef8 updated for version 7.4.681
Bram Moolenaar <bram@vim.org>
parents: 6359
diff changeset
4473 else if (IsMinimized(s_hwnd))
dc96dd80aef8 updated for version 7.4.681
Bram Moolenaar <bram@vim.org>
parents: 6359
diff changeset
4474 {
dc96dd80aef8 updated for version 7.4.681
Bram Moolenaar <bram@vim.org>
parents: 6359
diff changeset
4475 /* The height of the menu cannot be determined while the window is
dc96dd80aef8 updated for version 7.4.681
Bram Moolenaar <bram@vim.org>
parents: 6359
diff changeset
4476 * minimized. Take the previous height if the menu is changed in that
dc96dd80aef8 updated for version 7.4.681
Bram Moolenaar <bram@vim.org>
parents: 6359
diff changeset
4477 * state, to avoid that Vim's vertical window size accidentally
dc96dd80aef8 updated for version 7.4.681
Bram Moolenaar <bram@vim.org>
parents: 6359
diff changeset
4478 * increases due to the unaccounted-for menu height. */
dc96dd80aef8 updated for version 7.4.681
Bram Moolenaar <bram@vim.org>
parents: 6359
diff changeset
4479 menu_height = old_menu_height == -1 ? 0 : old_menu_height;
dc96dd80aef8 updated for version 7.4.681
Bram Moolenaar <bram@vim.org>
parents: 6359
diff changeset
4480 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4481 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4482 {
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4483 /*
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4484 * In case 'lines' is set in _vimrc/_gvimrc window width doesn't
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4485 * seem to have been set yet, so menu wraps in default window
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4486 * width which is very narrow. Instead just return height of a
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4487 * single menu item. Will still be wrong when the menu really
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4488 * should wrap over more than one line.
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4489 */
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4490 GetMenuItemRect(s_hwnd, s_menuBar, 0, &rc1);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4491 if (gui.starting)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4492 menu_height = rc1.bottom - rc1.top + 1;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4493 else
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4494 {
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4495 GetMenuItemRect(s_hwnd, s_menuBar, num - 1, &rc2);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4496 menu_height = rc2.bottom - rc1.top + 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4497 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4498 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4499
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4500 if (fix_window && menu_height != old_menu_height)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4501 {
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4502 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4503 }
6714
dc96dd80aef8 updated for version 7.4.681
Bram Moolenaar <bram@vim.org>
parents: 6359
diff changeset
4504 old_menu_height = menu_height;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4505
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4506 return menu_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4507 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4508 #endif /*FEAT_MENU*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4509
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4510
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4511 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4512 * Setup for the Intellimouse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4513 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4514 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4515 init_mouse_wheel(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4516 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4517
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4518 #ifndef SPI_GETWHEELSCROLLLINES
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4519 # define SPI_GETWHEELSCROLLLINES 104
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4520 #endif
336
2d8c2622e1fa updated for version 7.0087
vimboss
parents: 333
diff changeset
4521 #ifndef SPI_SETWHEELSCROLLLINES
2d8c2622e1fa updated for version 7.0087
vimboss
parents: 333
diff changeset
4522 # define SPI_SETWHEELSCROLLLINES 105
2d8c2622e1fa updated for version 7.0087
vimboss
parents: 333
diff changeset
4523 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4524
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4525 #define VMOUSEZ_CLASSNAME "MouseZ" /* hidden wheel window class */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4526 #define VMOUSEZ_TITLE "Magellan MSWHEEL" /* hidden wheel window title */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4527 #define VMSH_MOUSEWHEEL "MSWHEEL_ROLLMSG"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4528 #define VMSH_SCROLL_LINES "MSH_SCROLL_LINES_MSG"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4529
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4530 mouse_scroll_lines = 3; /* reasonable default */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4531
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4532 /* if NT 4.0+ (or Win98) get scroll lines directly from system */
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4533 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4534 &mouse_scroll_lines, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4535 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4536
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4537
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4538 /* Intellimouse wheel handler */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4539 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4540 _OnMouseWheel(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4541 HWND hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4542 short zDelta)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4543 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4544 /* Treat a mouse wheel event as if it were a scroll request */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4545 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4546 int size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4547 HWND hwndCtl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4549 if (curwin->w_scrollbars[SBAR_RIGHT].id != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4550 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4551 hwndCtl = curwin->w_scrollbars[SBAR_RIGHT].id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4552 size = curwin->w_scrollbars[SBAR_RIGHT].size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4553 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4554 else if (curwin->w_scrollbars[SBAR_LEFT].id != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4555 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4556 hwndCtl = curwin->w_scrollbars[SBAR_LEFT].id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4557 size = curwin->w_scrollbars[SBAR_LEFT].size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4558 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4559 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4560 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4561
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4562 size = curwin->w_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4563 if (mouse_scroll_lines == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4564 init_mouse_wheel();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4565
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4566 if (mouse_scroll_lines > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4567 && mouse_scroll_lines < (size > 2 ? size - 2 : 1))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4568 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4569 for (i = mouse_scroll_lines; i > 0; --i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4570 _OnScroll(hwnd, hwndCtl, zDelta >= 0 ? SB_LINEUP : SB_LINEDOWN, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4571 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4572 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4573 _OnScroll(hwnd, hwndCtl, zDelta >= 0 ? SB_PAGEUP : SB_PAGEDOWN, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4574 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4575
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4576 #ifdef USE_SYSMENU_FONT
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4577 /*
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4578 * Get Menu Font.
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4579 * Return OK or FAIL.
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4580 */
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4581 static int
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4582 gui_w32_get_menu_font(LOGFONT *lf)
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4583 {
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4584 NONCLIENTMETRICS nm;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4585
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4586 nm.cbSize = sizeof(NONCLIENTMETRICS);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4587 if (!SystemParametersInfo(
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4588 SPI_GETNONCLIENTMETRICS,
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4589 sizeof(NONCLIENTMETRICS),
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4590 &nm,
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4591 0))
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4592 return FAIL;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4593 *lf = nm.lfMenuFont;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4594 return OK;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4595 }
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4596 #endif
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4597
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4598
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4599 #if defined(FEAT_GUI_TABLINE) && defined(USE_SYSMENU_FONT)
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4600 /*
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4601 * Set the GUI tabline font to the system menu font
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4602 */
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4603 static void
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4604 set_tabline_font(void)
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4605 {
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4606 LOGFONT lfSysmenu;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4607 HFONT font;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4608 HWND hwnd;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4609 HDC hdc;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4610 HFONT hfntOld;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4611 TEXTMETRIC tm;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4612
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4613 if (gui_w32_get_menu_font(&lfSysmenu) != OK)
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4614 return;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4615
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4616 font = CreateFontIndirect(&lfSysmenu);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4617
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4618 SendMessage(s_tabhwnd, WM_SETFONT, (WPARAM)font, TRUE);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4619
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4620 /*
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4621 * Compute the height of the font used for the tab text
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4622 */
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4623 hwnd = GetDesktopWindow();
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4624 hdc = GetWindowDC(hwnd);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4625 hfntOld = SelectFont(hdc, font);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4626
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4627 GetTextMetrics(hdc, &tm);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4628
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4629 SelectFont(hdc, hfntOld);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4630 ReleaseDC(hwnd, hdc);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4631
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4632 /*
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4633 * The space used by the tab border and the space between the tab label
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4634 * and the tab border is included as 7.
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4635 */
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4636 gui.tabline_height = tm.tmHeight + tm.tmInternalLeading + 7;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4637 }
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4638 #endif
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4639
333
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4640 /*
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4641 * Invoked when a setting was changed.
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4642 */
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4643 static LRESULT CALLBACK
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4644 _OnSettingChange(UINT n)
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4645 {
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4646 if (n == SPI_SETWHEELSCROLLLINES)
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4647 SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4648 &mouse_scroll_lines, 0);
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4649 #if defined(FEAT_GUI_TABLINE) && defined(USE_SYSMENU_FONT)
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4650 if (n == SPI_SETNONCLIENTMETRICS)
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4651 set_tabline_font();
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4652 #endif
333
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4653 return 0;
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4654 }
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4655
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4656 #ifdef FEAT_NETBEANS_INTG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4657 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4658 _OnWindowPosChanged(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4659 HWND hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4660 const LPWINDOWPOS lpwpos)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4661 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4662 static int x = 0, y = 0, cx = 0, cy = 0;
7797
0d46cea25641 commit https://github.com/vim/vim/commit/f12d983deab06b0408781d7a6c2f8970d765b723
Christian Brabandt <cb@256bit.org>
parents: 7743
diff changeset
4663 extern int WSInitialized;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4664
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4665 if (WSInitialized && (lpwpos->x != x || lpwpos->y != y
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4666 || lpwpos->cx != cx || lpwpos->cy != cy))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4667 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4668 x = lpwpos->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4669 y = lpwpos->y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4670 cx = lpwpos->cx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4671 cy = lpwpos->cy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4672 netbeans_frame_moved(x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4673 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4674 /* Allow to send WM_SIZE and WM_MOVE */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4675 FORWARD_WM_WINDOWPOSCHANGED(hwnd, lpwpos, MyWindowProc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4676 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4677 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4678
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4679 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4680 _DuringSizing(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4681 UINT fwSide,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4682 LPRECT lprc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4683 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4684 int w, h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4685 int valid_w, valid_h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4686 int w_offset, h_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4687
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4688 w = lprc->right - lprc->left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4689 h = lprc->bottom - lprc->top;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4690 gui_mswin_get_valid_dimensions(w, h, &valid_w, &valid_h);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4691 w_offset = w - valid_w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4692 h_offset = h - valid_h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4693
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4694 if (fwSide == WMSZ_LEFT || fwSide == WMSZ_TOPLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4695 || fwSide == WMSZ_BOTTOMLEFT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4696 lprc->left += w_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4697 else if (fwSide == WMSZ_RIGHT || fwSide == WMSZ_TOPRIGHT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4698 || fwSide == WMSZ_BOTTOMRIGHT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4699 lprc->right -= w_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4700
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4701 if (fwSide == WMSZ_TOP || fwSide == WMSZ_TOPLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4702 || fwSide == WMSZ_TOPRIGHT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4703 lprc->top += h_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4704 else if (fwSide == WMSZ_BOTTOM || fwSide == WMSZ_BOTTOMLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4705 || fwSide == WMSZ_BOTTOMRIGHT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4706 lprc->bottom -= h_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4707 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4708 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4709
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4710
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4711
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4712 static LRESULT CALLBACK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4713 _WndProc(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4714 HWND hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4715 UINT uMsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4716 WPARAM wParam,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4717 LPARAM lParam)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4718 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4719 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4720 TRACE("WndProc: hwnd = %08x, msg = %x, wParam = %x, lParam = %x\n",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4721 hwnd, uMsg, wParam, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4722 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4723
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4724 HandleMouseHide(uMsg, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4725
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4726 s_uMsg = uMsg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4727 s_wParam = wParam;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4728 s_lParam = lParam;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4729
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4730 switch (uMsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4731 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4732 HANDLE_MSG(hwnd, WM_DEADCHAR, _OnDeadChar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4733 HANDLE_MSG(hwnd, WM_SYSDEADCHAR, _OnDeadChar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4734 /* HANDLE_MSG(hwnd, WM_ACTIVATE, _OnActivate); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4735 HANDLE_MSG(hwnd, WM_CLOSE, _OnClose);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4736 /* HANDLE_MSG(hwnd, WM_COMMAND, _OnCommand); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4737 HANDLE_MSG(hwnd, WM_DESTROY, _OnDestroy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4738 HANDLE_MSG(hwnd, WM_DROPFILES, _OnDropFiles);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4739 HANDLE_MSG(hwnd, WM_HSCROLL, _OnScroll);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4740 HANDLE_MSG(hwnd, WM_KILLFOCUS, _OnKillFocus);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4741 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4742 HANDLE_MSG(hwnd, WM_COMMAND, _OnMenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4743 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4744 /* HANDLE_MSG(hwnd, WM_MOVE, _OnMove); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4745 /* HANDLE_MSG(hwnd, WM_NCACTIVATE, _OnNCActivate); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4746 HANDLE_MSG(hwnd, WM_SETFOCUS, _OnSetFocus);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4747 HANDLE_MSG(hwnd, WM_SIZE, _OnSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4748 /* HANDLE_MSG(hwnd, WM_SYSCOMMAND, _OnSysCommand); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4749 /* HANDLE_MSG(hwnd, WM_SYSKEYDOWN, _OnAltKey); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4750 HANDLE_MSG(hwnd, WM_VSCROLL, _OnScroll);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4751 // HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGING, _OnWindowPosChanging);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4752 HANDLE_MSG(hwnd, WM_ACTIVATEAPP, _OnActivateApp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4753 #ifdef FEAT_NETBEANS_INTG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4754 HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGED, _OnWindowPosChanged);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4755 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4756
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4757 #ifdef FEAT_GUI_TABLINE
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4758 case WM_RBUTTONUP:
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4759 {
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4760 if (gui_mch_showing_tabline())
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4761 {
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4762 POINT pt;
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4763 RECT rect;
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4764
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4765 /*
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4766 * If the cursor is on the tabline, display the tab menu
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4767 */
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4768 GetCursorPos((LPPOINT)&pt);
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4769 GetWindowRect(s_textArea, &rect);
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4770 if (pt.y < rect.top)
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4771 {
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4772 show_tabline_popup_menu();
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4773 return 0L;
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4774 }
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4775 }
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4776 return MyWindowProc(hwnd, uMsg, wParam, lParam);
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4777 }
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4778 case WM_LBUTTONDBLCLK:
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4779 {
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4780 /*
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4781 * If the user double clicked the tabline, create a new tab
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4782 */
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4783 if (gui_mch_showing_tabline())
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4784 {
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4785 POINT pt;
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4786 RECT rect;
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4787
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4788 GetCursorPos((LPPOINT)&pt);
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4789 GetWindowRect(s_textArea, &rect);
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4790 if (pt.y < rect.top)
824
8dd456c1e283 updated for version 7.0c13
vimboss
parents: 819
diff changeset
4791 send_tabline_menu_event(0, TABLINE_MENU_NEW);
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4792 }
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4793 return MyWindowProc(hwnd, uMsg, wParam, lParam);
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
4794 }
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4795 #endif
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4796
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4797 case WM_QUERYENDSESSION: /* System wants to go down. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4798 gui_shell_closed(); /* Will exit when no changed buffers. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4799 return FALSE; /* Do NOT allow system to go down. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4800
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4801 case WM_ENDSESSION:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4802 if (wParam) /* system only really goes down when wParam is TRUE */
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4803 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4804 _OnEndSession();
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4805 return 0L;
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4806 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4807 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4808
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4809 case WM_CHAR:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4810 /* Don't use HANDLE_MSG() for WM_CHAR, it truncates wParam to a single
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4811 * byte while we want the UTF-16 character value. */
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 824
diff changeset
4812 _OnChar(hwnd, (UINT)wParam, (int)(short)LOWORD(lParam));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4813 return 0L;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4814
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4815 case WM_SYSCHAR:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4816 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4817 * if 'winaltkeys' is "no", or it's "menu" and it's not a menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4818 * shortcut key, handle like a typed ALT key, otherwise call Windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4819 * ALT key handling.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4820 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4821 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4822 if ( !gui.menu_is_active
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4823 || p_wak[0] == 'n'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4824 || (p_wak[0] == 'm' && !gui_is_menu_shortcut((int)wParam))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4825 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4826 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4827 {
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 824
diff changeset
4828 _OnSysChar(hwnd, (UINT)wParam, (int)(short)LOWORD(lParam));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4829 return 0L;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4830 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4831 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4832 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4833 return MyWindowProc(hwnd, uMsg, wParam, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4834 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4835
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4836 case WM_SYSKEYUP:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4837 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4838 /* This used to be done only when menu is active: ALT key is used for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4839 * that. But that caused problems when menu is disabled and using
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4840 * Alt-Tab-Esc: get into a strange state where no mouse-moved events
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4841 * are received, mouse pointer remains hidden. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4842 return MyWindowProc(hwnd, uMsg, wParam, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4843 #else
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4844 return 0L;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4845 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4846
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4847 case WM_SIZING: /* HANDLE_MSG doesn't seem to handle this one */
323
03b3684919e3 updated for version 7.0084
vimboss
parents: 293
diff changeset
4848 return _DuringSizing((UINT)wParam, (LPRECT)lParam);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4849
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4850 case WM_MOUSEWHEEL:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4851 _OnMouseWheel(hwnd, HIWORD(wParam));
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4852 return 0L;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4853
333
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4854 /* Notification for change in SystemParametersInfo() */
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4855 case WM_SETTINGCHANGE:
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4856 return _OnSettingChange((UINT)wParam);
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4857
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4858 #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4859 case WM_NOTIFY:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4860 switch (((LPNMHDR) lParam)->code)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4861 {
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4862 # ifdef FEAT_MBYTE
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4863 case TTN_GETDISPINFOW:
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4864 # endif
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4865 case TTN_GETDISPINFO:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4866 {
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4867 LPNMHDR hdr = (LPNMHDR)lParam;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4868 char_u *str = NULL;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4869 static void *tt_text = NULL;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4870
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4871 vim_free(tt_text);
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4872 tt_text = NULL;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4873
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4874 # ifdef FEAT_GUI_TABLINE
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4875 if (gui_mch_showing_tabline()
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4876 && hdr->hwndFrom == TabCtrl_GetToolTips(s_tabhwnd))
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4877 {
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4878 POINT pt;
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4879 /*
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4880 * Mouse is over the GUI tabline. Display the
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4881 * tooltip for the tab under the cursor
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4882 *
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4883 * Get the cursor position within the tab control
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4884 */
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4885 GetCursorPos(&pt);
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4886 if (ScreenToClient(s_tabhwnd, &pt) != 0)
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4887 {
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4888 TCHITTESTINFO htinfo;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4889 int idx;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4890
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4891 /*
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4892 * Get the tab under the cursor
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4893 */
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4894 htinfo.pt.x = pt.x;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4895 htinfo.pt.y = pt.y;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4896 idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4897 if (idx != -1)
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4898 {
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4899 tabpage_T *tp;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4900
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4901 tp = find_tabpage(idx + 1);
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4902 if (tp != NULL)
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4903 {
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4904 get_tabline_label(tp, TRUE);
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4905 str = NameBuff;
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4906 }
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4907 }
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4908 }
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4909 }
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4910 # endif
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
4911 # ifdef FEAT_TOOLBAR
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4912 # ifdef FEAT_GUI_TABLINE
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4913 else
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4914 # endif
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4915 {
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4916 UINT idButton;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4917 vimmenu_T *pMenu;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4918
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4919 idButton = (UINT) hdr->idFrom;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4920 pMenu = gui_mswin_find_menu(root_menu, idButton);
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4921 if (pMenu)
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4922 str = pMenu->strings[MENU_INDEX_TIP];
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4923 }
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4924 # endif
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4925 if (str != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4926 {
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4927 # ifdef FEAT_MBYTE
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4928 if (hdr->code == TTN_GETDISPINFOW)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4929 {
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4930 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)lParam;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4931
1481
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
4932 /* Set the maximum width, this also enables using
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
4933 * \n for line break. */
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
4934 SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
4935 0, 500);
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
4936
1752
a8aae2e1d2ae updated for version 7.2-049
vimboss
parents: 1621
diff changeset
4937 tt_text = enc_to_utf16(str, NULL);
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4938 lpdi->lpszText = tt_text;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4939 /* can't show tooltip if failed */
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4940 }
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4941 else
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4942 # endif
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4943 {
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4944 LPNMTTDISPINFO lpdi = (LPNMTTDISPINFO)lParam;
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4945
1481
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
4946 /* Set the maximum width, this also enables using
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
4947 * \n for line break. */
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
4948 SendMessage(lpdi->hdr.hwndFrom, TTM_SETMAXTIPWIDTH,
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
4949 0, 500);
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
4950
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4951 if (STRLEN(str) < sizeof(lpdi->szText)
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4952 || ((tt_text = vim_strsave(str)) == NULL))
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
4953 vim_strncpy((char_u *)lpdi->szText, str,
948
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4954 sizeof(lpdi->szText) - 1);
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4955 else
c1b61096e3d0 updated for version 7.0-074
vimboss
parents: 872
diff changeset
4956 lpdi->lpszText = tt_text;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4957 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4958 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4959 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4960 break;
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4961 # ifdef FEAT_GUI_TABLINE
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4962 case TCN_SELCHANGE:
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4963 if (gui_mch_showing_tabline()
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4964 && ((LPNMHDR)lParam)->hwndFrom == s_tabhwnd)
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4965 {
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4966 send_tabline_event(TabCtrl_GetCurSel(s_tabhwnd) + 1);
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4967 return 0L;
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4968 }
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4969 break;
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4970
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4971 case NM_RCLICK:
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4972 if (gui_mch_showing_tabline()
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4973 && ((LPNMHDR)lParam)->hwndFrom == s_tabhwnd)
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4974 {
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4975 show_tabline_popup_menu();
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4976 return 0L;
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4977 }
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4978 break;
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4979 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4980 default:
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4981 # ifdef FEAT_GUI_TABLINE
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4982 if (gui_mch_showing_tabline()
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4983 && ((LPNMHDR)lParam)->hwndFrom == s_tabhwnd)
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4984 return MyWindowProc(hwnd, uMsg, wParam, lParam);
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4985 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4986 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4987 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4988 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4989 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4990 #if defined(MENUHINTS) && defined(FEAT_MENU)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4991 case WM_MENUSELECT:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4992 if (((UINT) HIWORD(wParam)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4993 & (0xffff ^ (MF_MOUSESELECT + MF_BITMAP + MF_POPUP)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4994 == MF_HILITE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4995 && (State & CMDLINE) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4996 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4997 UINT idButton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4998 vimmenu_T *pMenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4999 static int did_menu_tip = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5000
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5001 if (did_menu_tip)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5002 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5003 msg_clr_cmdline();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5004 setcursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5005 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5006 did_menu_tip = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5007 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5008
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5009 idButton = (UINT)LOWORD(wParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5010 pMenu = gui_mswin_find_menu(root_menu, idButton);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5011 if (pMenu != NULL && pMenu->strings[MENU_INDEX_TIP] != 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5012 && GetMenuState(s_menuBar, pMenu->id, MF_BYCOMMAND) != -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5013 {
1288
2a256978a646 updated for version 7.1-003
vimboss
parents: 1229
diff changeset
5014 ++msg_hist_off;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5015 msg(pMenu->strings[MENU_INDEX_TIP]);
1288
2a256978a646 updated for version 7.1-003
vimboss
parents: 1229
diff changeset
5016 --msg_hist_off;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5017 setcursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5018 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5019 did_menu_tip = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5020 }
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
5021 return 0L;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5022 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5023 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5024 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5025 case WM_NCHITTEST:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5026 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5027 LRESULT result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5028 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5029 int xPos = GET_X_LPARAM(lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5030
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5031 result = MyWindowProc(hwnd, uMsg, wParam, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5032 if (result == HTCLIENT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5033 {
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5034 #ifdef FEAT_GUI_TABLINE
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5035 if (gui_mch_showing_tabline())
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5036 {
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5037 int yPos = GET_Y_LPARAM(lParam);
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5038 RECT rct;
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5039
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5040 /* If the cursor is on the GUI tabline, don't process this
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5041 * event */
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5042 GetWindowRect(s_textArea, &rct);
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5043 if (yPos < rct.top)
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5044 return result;
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5045 }
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5046 #endif
7009
286fd54c7ae3 patch 7.4.822
Bram Moolenaar <bram@vim.org>
parents: 6714
diff changeset
5047 (void)gui_mch_get_winpos(&x, &y);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5048 xPos -= x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5049
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5050 if (xPos < 48) /* <VN> TODO should use system metric? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5051 return HTBOTTOMLEFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5052 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5053 return HTBOTTOMRIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5054 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5055 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5056 return result;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5057 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5058 /* break; notreached */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5059
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5060 #ifdef FEAT_MBYTE_IME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5061 case WM_IME_NOTIFY:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5062 if (!_OnImeNotify(hwnd, (DWORD)wParam, (DWORD)lParam))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5063 return MyWindowProc(hwnd, uMsg, wParam, lParam);
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
5064 return 1L;
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
5065
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5066 case WM_IME_COMPOSITION:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5067 if (!_OnImeComposition(hwnd, wParam, lParam))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5068 return MyWindowProc(hwnd, uMsg, wParam, lParam);
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
5069 return 1L;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5070 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5071
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5072 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5073 #ifdef MSWIN_FIND_REPLACE
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5074 if (uMsg == s_findrep_msg && s_findrep_msg != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5075 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5076 _OnFindRepl();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5077 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5078 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5079 return MyWindowProc(hwnd, uMsg, wParam, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5080 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5081
3212
1d7434010de1 updated for version 7.3.376
Bram Moolenaar <bram@vim.org>
parents: 3010
diff changeset
5082 return DefWindowProc(hwnd, uMsg, wParam, lParam);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5083 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5084
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5085 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5086 * End of call-back routines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5087 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5088
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5089 /* parent window, if specified with -P */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5090 HWND vim_parent_hwnd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5091
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5092 static BOOL CALLBACK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5093 FindWindowTitle(HWND hwnd, LPARAM lParam)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5094 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5095 char buf[2048];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5096 char *title = (char *)lParam;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5097
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5098 if (GetWindowText(hwnd, buf, sizeof(buf)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5099 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5100 if (strstr(buf, title) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5101 {
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5102 /* Found it. Store the window ref. and quit searching if MDI
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5103 * works. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5104 vim_parent_hwnd = FindWindowEx(hwnd, NULL, "MDIClient", NULL);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5105 if (vim_parent_hwnd != NULL)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
5106 return FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5107 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5108 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5109 return TRUE; /* continue searching */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5110 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5112 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5113 * Invoked for '-P "title"' argument: search for parent application to open
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5114 * our window in.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5115 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5116 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5117 gui_mch_set_parent(char *title)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5118 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5119 EnumWindows(FindWindowTitle, (LPARAM)title);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5120 if (vim_parent_hwnd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5121 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5122 EMSG2(_("E671: Cannot find window title \"%s\""), title);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5123 mch_exit(2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5124 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5125 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5126
323
03b3684919e3 updated for version 7.0084
vimboss
parents: 293
diff changeset
5127 #ifndef FEAT_OLE
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5128 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5129 ole_error(char *arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5130 {
1116
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
5131 char buf[IOSIZE];
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
5132
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
5133 /* Can't use EMSG() here, we have not finished initialisation yet. */
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
5134 vim_snprintf(buf, IOSIZE,
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
5135 _("E243: Argument not supported: \"-%s\"; Use the OLE version."),
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
5136 arg);
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
5137 mch_errmsg(buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5138 }
323
03b3684919e3 updated for version 7.0084
vimboss
parents: 293
diff changeset
5139 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5141 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5142 * Parse the GUI related command-line arguments. Any arguments used are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5143 * deleted from argv, and *argc is decremented accordingly. This is called
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5144 * when vim is started, whether or not the GUI has been started.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5145 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5146 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5147 gui_mch_prepare(int *argc, char **argv)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5148 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5149 int silent = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5150 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5151
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5152 /* Check for special OLE command line parameters */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5153 if ((*argc == 2 || *argc == 3) && (argv[1][0] == '-' || argv[1][0] == '/'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5154 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5155 /* Check for a "-silent" argument first. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5156 if (*argc == 3 && STRICMP(argv[1] + 1, "silent") == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5157 && (argv[2][0] == '-' || argv[2][0] == '/'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5158 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5159 silent = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5160 idx = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5161 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5162 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5163 idx = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5164
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5165 /* Register Vim as an OLE Automation server */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5166 if (STRICMP(argv[idx] + 1, "register") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5167 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5168 #ifdef FEAT_OLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5169 RegisterMe(silent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5170 mch_exit(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5171 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5172 if (!silent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5173 ole_error("register");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5174 mch_exit(2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5175 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5178 /* Unregister Vim as an OLE Automation server */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5179 if (STRICMP(argv[idx] + 1, "unregister") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5180 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5181 #ifdef FEAT_OLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5182 UnregisterMe(!silent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5183 mch_exit(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5184 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5185 if (!silent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5186 ole_error("unregister");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5187 mch_exit(2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5188 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5189 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5190
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5191 /* Ignore an -embedding argument. It is only relevant if the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5192 * application wants to treat the case when it is started manually
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5193 * differently from the case where it is started via automation (and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5194 * we don't).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5195 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5196 if (STRICMP(argv[idx] + 1, "embedding") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5197 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5198 #ifdef FEAT_OLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5199 *argc = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5200 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5201 ole_error("embedding");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5202 mch_exit(2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5203 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5204 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5205 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5207 #ifdef FEAT_OLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5208 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5209 int bDoRestart = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5211 InitOLE(&bDoRestart);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5212 /* automatically exit after registering */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5213 if (bDoRestart)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5214 mch_exit(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5215 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5216 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5217
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5218 #ifdef FEAT_NETBEANS_INTG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5219 {
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 4238
diff changeset
5220 /* stolen from gui_x11.c */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5221 int arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5222
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5223 for (arg = 1; arg < *argc; arg++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5224 if (strncmp("-nb", argv[arg], 3) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5225 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5226 netbeansArg = argv[arg];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5227 mch_memmove(&argv[arg], &argv[arg + 1],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5228 (--*argc - arg) * sizeof(char *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5229 argv[*argc] = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5230 break; /* enough? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5231 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5232 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5233 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5234 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5235
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5236 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5237 * Initialise the GUI. Create all the windows, set up all the call-backs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5238 * etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5239 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5240 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5241 gui_mch_init(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5242 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5243 const char szVimWndClass[] = VIM_CLASS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5244 const char szTextAreaClass[] = "VimTextArea";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5245 WNDCLASS wndclass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5246 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5247 const WCHAR szVimWndClassW[] = VIM_CLASSW;
2078
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5248 const WCHAR szTextAreaClassW[] = L"VimTextArea";
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5249 WNDCLASSW wndclassw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5250 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5251 #ifdef GLOBAL_IME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5252 ATOM atom;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5253 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5255 /* Return here if the window was already opened (happens when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5256 * gui_mch_dialog() is called early). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5257 if (s_hwnd != NULL)
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
5258 goto theend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5259
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5260 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5261 * Load the tearoff bitmap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5262 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5263 #ifdef FEAT_TEAROFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5264 s_htearbitmap = LoadBitmap(s_hinst, "IDB_TEAROFF");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5265 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5266
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5267 gui.scrollbar_width = GetSystemMetrics(SM_CXVSCROLL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5268 gui.scrollbar_height = GetSystemMetrics(SM_CYHSCROLL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5269 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5270 gui.menu_height = 0; /* Windows takes care of this */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5271 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5272 gui.border_width = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5273
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5274 s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5275
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5276 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5277 /* First try using the wide version, so that we can use any title.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5278 * Otherwise only characters in the active codepage will work. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5279 if (GetClassInfoW(s_hinst, szVimWndClassW, &wndclassw) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5280 {
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
5281 wndclassw.style = CS_DBLCLKS;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5282 wndclassw.lpfnWndProc = _WndProc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5283 wndclassw.cbClsExtra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5284 wndclassw.cbWndExtra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5285 wndclassw.hInstance = s_hinst;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5286 wndclassw.hIcon = LoadIcon(wndclassw.hInstance, "IDR_VIM");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5287 wndclassw.hCursor = LoadCursor(NULL, IDC_ARROW);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5288 wndclassw.hbrBackground = s_brush;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5289 wndclassw.lpszMenuName = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5290 wndclassw.lpszClassName = szVimWndClassW;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5291
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5292 if ((
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5293 #ifdef GLOBAL_IME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5294 atom =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5295 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5296 RegisterClassW(&wndclassw)) == 0)
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5297 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5298 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5299 wide_WindowProc = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5300 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5301
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5302 if (!wide_WindowProc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5303 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5304
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5305 if (GetClassInfo(s_hinst, szVimWndClass, &wndclass) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5306 {
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
5307 wndclass.style = CS_DBLCLKS;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5308 wndclass.lpfnWndProc = _WndProc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5309 wndclass.cbClsExtra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5310 wndclass.cbWndExtra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5311 wndclass.hInstance = s_hinst;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5312 wndclass.hIcon = LoadIcon(wndclass.hInstance, "IDR_VIM");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5313 wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5314 wndclass.hbrBackground = s_brush;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5315 wndclass.lpszMenuName = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5316 wndclass.lpszClassName = szVimWndClass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5318 if ((
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5319 #ifdef GLOBAL_IME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5320 atom =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5321 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5322 RegisterClass(&wndclass)) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5323 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5324 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5325
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5326 if (vim_parent_hwnd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5327 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5328 #ifdef HAVE_TRY_EXCEPT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5329 __try
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5330 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5331 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5332 /* Open inside the specified parent window.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5333 * TODO: last argument should point to a CLIENTCREATESTRUCT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5334 * structure. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5335 s_hwnd = CreateWindowEx(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5336 WS_EX_MDICHILD,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5337 szVimWndClass, "Vim MSWindows GUI",
3006
125c7bf52271 updated for version 7.3.275
Bram Moolenaar <bram@vim.org>
parents: 2943
diff changeset
5338 WS_OVERLAPPEDWINDOW | WS_CHILD
125c7bf52271 updated for version 7.3.275
Bram Moolenaar <bram@vim.org>
parents: 2943
diff changeset
5339 | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | 0xC000,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5340 gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5341 gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5342 100, /* Any value will do */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5343 100, /* Any value will do */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5344 vim_parent_hwnd, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5345 s_hinst, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5346 #ifdef HAVE_TRY_EXCEPT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5347 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5348 __except(EXCEPTION_EXECUTE_HANDLER)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5349 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5350 /* NOP */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5351 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5352 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5353 if (s_hwnd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5354 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5355 EMSG(_("E672: Unable to open window inside MDI application"));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5356 mch_exit(2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5357 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5358 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5359 else
1376
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5360 {
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5361 /* If the provided windowid is not valid reset it to zero, so that it
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5362 * is ignored and we open our own window. */
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5363 if (IsWindow((HWND)win_socket_id) <= 0)
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5364 win_socket_id = 0;
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5365
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5366 /* Create a window. If win_socket_id is not zero without border and
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5367 * titlebar, it will be reparented below. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5368 s_hwnd = CreateWindow(
1376
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5369 szVimWndClass, "Vim MSWindows GUI",
3006
125c7bf52271 updated for version 7.3.275
Bram Moolenaar <bram@vim.org>
parents: 2943
diff changeset
5370 (win_socket_id == 0 ? WS_OVERLAPPEDWINDOW : WS_POPUP)
125c7bf52271 updated for version 7.3.275
Bram Moolenaar <bram@vim.org>
parents: 2943
diff changeset
5371 | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
1376
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5372 gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5373 gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5374 100, /* Any value will do */
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5375 100, /* Any value will do */
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5376 NULL, NULL,
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5377 s_hinst, NULL);
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5378 if (s_hwnd != NULL && win_socket_id != 0)
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5379 {
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5380 SetParent(s_hwnd, (HWND)win_socket_id);
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5381 ShowWindow(s_hwnd, SW_SHOWMAXIMIZED);
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5382 }
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5383 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5384
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5385 if (s_hwnd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5386 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5387
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5388 #ifdef GLOBAL_IME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5389 global_ime_init(atom, s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5390 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5391 #if defined(FEAT_MBYTE_IME) && defined(DYNAMIC_IME)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5392 dyn_imm_load();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5393 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5395 /* Create the text area window */
2078
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5396 #ifdef FEAT_MBYTE
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5397 if (wide_WindowProc)
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5398 {
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5399 if (GetClassInfoW(s_hinst, szTextAreaClassW, &wndclassw) == 0)
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5400 {
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5401 wndclassw.style = CS_OWNDC;
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5402 wndclassw.lpfnWndProc = _TextAreaWndProc;
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5403 wndclassw.cbClsExtra = 0;
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5404 wndclassw.cbWndExtra = 0;
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5405 wndclassw.hInstance = s_hinst;
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5406 wndclassw.hIcon = NULL;
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5407 wndclassw.hCursor = LoadCursor(NULL, IDC_ARROW);
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5408 wndclassw.hbrBackground = NULL;
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5409 wndclassw.lpszMenuName = NULL;
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5410 wndclassw.lpszClassName = szTextAreaClassW;
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5411
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5412 if (RegisterClassW(&wndclassw) == 0)
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5413 return FAIL;
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5414 }
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5415 }
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5416 else
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5417 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5418 if (GetClassInfo(s_hinst, szTextAreaClass, &wndclass) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5419 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5420 wndclass.style = CS_OWNDC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5421 wndclass.lpfnWndProc = _TextAreaWndProc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5422 wndclass.cbClsExtra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5423 wndclass.cbWndExtra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5424 wndclass.hInstance = s_hinst;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5425 wndclass.hIcon = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5426 wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5427 wndclass.hbrBackground = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5428 wndclass.lpszMenuName = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5429 wndclass.lpszClassName = szTextAreaClass;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5430
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5431 if (RegisterClass(&wndclass) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5432 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5433 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5434 s_textArea = CreateWindowEx(
7243
861a44fc5183 commit https://github.com/vim/vim/commit/97b0b0ec764d3a247ef600d809b965d5ab37155d
Christian Brabandt <cb@256bit.org>
parents: 7060
diff changeset
5435 0,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5436 szTextAreaClass, "Vim text area",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5437 WS_CHILD | WS_VISIBLE, 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5438 100, /* Any value will do for now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5439 100, /* Any value will do for now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5440 s_hwnd, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5441 s_hinst, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5442
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5443 if (s_textArea == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5444 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5445
8100
ae50910ce279 commit https://github.com/vim/vim/commit/203219048fa007b5042d9b893fd647aef44722a0
Christian Brabandt <cb@256bit.org>
parents: 8090
diff changeset
5446 #ifdef FEAT_LIBCALL
6249
7816c24ff890 updated for version 7.4.459
Bram Moolenaar <bram@vim.org>
parents: 6226
diff changeset
5447 /* Try loading an icon from $RUNTIMEPATH/bitmaps/vim.ico. */
7816c24ff890 updated for version 7.4.459
Bram Moolenaar <bram@vim.org>
parents: 6226
diff changeset
5448 {
7816c24ff890 updated for version 7.4.459
Bram Moolenaar <bram@vim.org>
parents: 6226
diff changeset
5449 HANDLE hIcon = NULL;
7816c24ff890 updated for version 7.4.459
Bram Moolenaar <bram@vim.org>
parents: 6226
diff changeset
5450
7816c24ff890 updated for version 7.4.459
Bram Moolenaar <bram@vim.org>
parents: 6226
diff changeset
5451 if (mch_icon_load(&hIcon) == OK && hIcon != NULL)
6260
74c65620c985 updated for version 7.4.464
Bram Moolenaar <bram@vim.org>
parents: 6249
diff changeset
5452 SendMessage(s_hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
6249
7816c24ff890 updated for version 7.4.459
Bram Moolenaar <bram@vim.org>
parents: 6226
diff changeset
5453 }
8100
ae50910ce279 commit https://github.com/vim/vim/commit/203219048fa007b5042d9b893fd647aef44722a0
Christian Brabandt <cb@256bit.org>
parents: 8090
diff changeset
5454 #endif
6249
7816c24ff890 updated for version 7.4.459
Bram Moolenaar <bram@vim.org>
parents: 6226
diff changeset
5455
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5456 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5457 s_menuBar = CreateMenu();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5458 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5459 s_hdc = GetDC(s_textArea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5460
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5461 #ifdef FEAT_WINDOWS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5462 DragAcceptFiles(s_hwnd, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5463 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5464
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5465 /* Do we need to bother with this? */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5466 /* m_fMouseAvail = GetSystemMetrics(SM_MOUSEPRESENT); */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5467
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5468 /* Get background/foreground colors from the system */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5469 gui_mch_def_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5470
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5471 /* Get the colors from the "Normal" group (set in syntax.c or in a vimrc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5472 * file) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5473 set_normal_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5474
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5475 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5476 * Check that none of the colors are the same as the background color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5477 * Then store the current values as the defaults.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5478 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5479 gui_check_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5480 gui.def_norm_pixel = gui.norm_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5481 gui.def_back_pixel = gui.back_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5482
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5483 /* Get the colors for the highlight groups (gui_check_colors() might have
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5484 * changed them) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5485 highlight_gui_started();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5486
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5487 /*
7243
861a44fc5183 commit https://github.com/vim/vim/commit/97b0b0ec764d3a247ef600d809b965d5ab37155d
Christian Brabandt <cb@256bit.org>
parents: 7060
diff changeset
5488 * Start out by adding the configured border width into the border offset.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5489 */
7243
861a44fc5183 commit https://github.com/vim/vim/commit/97b0b0ec764d3a247ef600d809b965d5ab37155d
Christian Brabandt <cb@256bit.org>
parents: 7060
diff changeset
5490 gui.border_offset = gui.border_width;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5491
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5492 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5493 * Set up for Intellimouse processing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5494 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5495 init_mouse_wheel();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5497 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5498 * compute a couple of metrics used for the dialogs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5499 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5500 get_dialog_font_metrics();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5501 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5502 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5503 * Create the toolbar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5504 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5505 initialise_toolbar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5506 #endif
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5507 #ifdef FEAT_GUI_TABLINE
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5508 /*
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5509 * Create the tabline
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5510 */
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5511 initialise_tabline();
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5512 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5513 #ifdef MSWIN_FIND_REPLACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5514 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5515 * Initialise the dialog box stuff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5516 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5517 s_findrep_msg = RegisterWindowMessage(FINDMSGSTRING);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5518
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5519 /* Initialise the struct */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5520 s_findrep_struct.lStructSize = sizeof(s_findrep_struct);
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
5521 s_findrep_struct.lpstrFindWhat = (LPSTR)alloc(MSWIN_FR_BUFSIZE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5522 s_findrep_struct.lpstrFindWhat[0] = NUL;
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
5523 s_findrep_struct.lpstrReplaceWith = (LPSTR)alloc(MSWIN_FR_BUFSIZE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5524 s_findrep_struct.lpstrReplaceWith[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5525 s_findrep_struct.wFindWhatLen = MSWIN_FR_BUFSIZE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5526 s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE;
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5527 # ifdef FEAT_MBYTE
1795
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
5528 s_findrep_struct_w.lStructSize = sizeof(s_findrep_struct_w);
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
5529 s_findrep_struct_w.lpstrFindWhat =
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
5530 (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR));
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
5531 s_findrep_struct_w.lpstrFindWhat[0] = NUL;
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
5532 s_findrep_struct_w.lpstrReplaceWith =
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
5533 (LPWSTR)alloc(MSWIN_FR_BUFSIZE * sizeof(WCHAR));
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
5534 s_findrep_struct_w.lpstrReplaceWith[0] = NUL;
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
5535 s_findrep_struct_w.wFindWhatLen = MSWIN_FR_BUFSIZE;
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
5536 s_findrep_struct_w.wReplaceWithLen = MSWIN_FR_BUFSIZE;
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
5537 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5538 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5539
2616
73d947c20291 updated for version 7.3.038
Bram Moolenaar <bram@vim.org>
parents: 2614
diff changeset
5540 #ifdef FEAT_EVAL
7560
fb84355cd972 commit https://github.com/vim/vim/commit/f32c5cd6e0e6aa6d4aeacb6bf52e3d3ba21e5201
Christian Brabandt <cb@256bit.org>
parents: 7243
diff changeset
5541 # if !defined(_MSC_VER) || (_MSC_VER < 1400)
fb84355cd972 commit https://github.com/vim/vim/commit/f32c5cd6e0e6aa6d4aeacb6bf52e3d3ba21e5201
Christian Brabandt <cb@256bit.org>
parents: 7243
diff changeset
5542 /* Define HandleToLong for old MS and non-MS compilers if not defined. */
fb84355cd972 commit https://github.com/vim/vim/commit/f32c5cd6e0e6aa6d4aeacb6bf52e3d3ba21e5201
Christian Brabandt <cb@256bit.org>
parents: 7243
diff changeset
5543 # ifndef HandleToLong
8102
441298d72f3c commit https://github.com/vim/vim/commit/a87e2c277eabf0134925c340e9dc4fe9446f3636
Christian Brabandt <cb@256bit.org>
parents: 8100
diff changeset
5544 # define HandleToLong(h) ((long)(intptr_t)(h))
7560
fb84355cd972 commit https://github.com/vim/vim/commit/f32c5cd6e0e6aa6d4aeacb6bf52e3d3ba21e5201
Christian Brabandt <cb@256bit.org>
parents: 7243
diff changeset
5545 # endif
2943
be6b65096362 updated for version 7.3.244
Bram Moolenaar <bram@vim.org>
parents: 2865
diff changeset
5546 # endif
2616
73d947c20291 updated for version 7.3.038
Bram Moolenaar <bram@vim.org>
parents: 2614
diff changeset
5547 /* set the v:windowid variable */
2865
46544d3ae7ec updated for version 7.3.206
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
5548 set_vim_var_nr(VV_WINDOWID, HandleToLong(s_hwnd));
2616
73d947c20291 updated for version 7.3.038
Bram Moolenaar <bram@vim.org>
parents: 2614
diff changeset
5549 #endif
73d947c20291 updated for version 7.3.038
Bram Moolenaar <bram@vim.org>
parents: 2614
diff changeset
5550
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
5551 #ifdef FEAT_RENDER_OPTIONS
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
5552 if (p_rop)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
5553 (void)gui_mch_set_rendering_options(p_rop);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
5554 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
5555
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
5556 theend:
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
5557 /* Display any pending error messages */
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
5558 display_errors();
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
5559
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5560 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5561 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5562
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5563 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5564 * Get the size of the screen, taking position on multiple monitors into
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5565 * account (if supported).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5566 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5567 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5568 get_work_area(RECT *spi_rect)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5569 {
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5570 HMONITOR mon;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5571 MONITORINFO moninfo;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5572
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5573 /* work out which monitor the window is on, and get *it's* work area */
10438
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
5574 mon = MonitorFromWindow(s_hwnd, MONITOR_DEFAULTTOPRIMARY);
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5575 if (mon != NULL)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5576 {
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5577 moninfo.cbSize = sizeof(MONITORINFO);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5578 if (GetMonitorInfo(mon, &moninfo))
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5579 {
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5580 *spi_rect = moninfo.rcWork;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5581 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5582 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5583 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5584 /* this is the old method... */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5585 SystemParametersInfo(SPI_GETWORKAREA, 0, spi_rect, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5586 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5587
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5588 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5589 * Set the size of the window to the given width and height in pixels.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5590 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5591 void
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
5592 gui_mch_set_shellsize(
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
5593 int width,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
5594 int height,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
5595 int min_width UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
5596 int min_height UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
5597 int base_width UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
5598 int base_height UNUSED,
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
5599 int direction)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5600 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5601 RECT workarea_rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5602 int win_width, win_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5603 WINDOWPLACEMENT wndpl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5604
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
5605 /* Try to keep window completely on screen. */
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
5606 /* Get position of the screen work area. This is the part that is not
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
5607 * used by the taskbar or appbars. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5608 get_work_area(&workarea_rect);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5609
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 4238
diff changeset
5610 /* Get current position of our window. Note that the .left and .top are
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
5611 * relative to the work area. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5612 wndpl.length = sizeof(WINDOWPLACEMENT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5613 GetWindowPlacement(s_hwnd, &wndpl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5614
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5615 /* Resizing a maximized window looks very strange, unzoom it first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5616 * But don't do it when still starting up, it may have been requested in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5617 * the shortcut. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5618 if (wndpl.showCmd == SW_SHOWMAXIMIZED && starting == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5619 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5620 ShowWindow(s_hwnd, SW_SHOWNORMAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5621 /* Need to get the settings of the normal window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5622 GetWindowPlacement(s_hwnd, &wndpl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5623 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5624
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5625 /* compute the size of the outside of the window */
5225
8f983df0299f updated for version 7.4a.038
Bram Moolenaar <bram@vim.org>
parents: 5223
diff changeset
5626 win_width = width + (GetSystemMetrics(SM_CXFRAME) +
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
5627 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2;
5225
8f983df0299f updated for version 7.4a.038
Bram Moolenaar <bram@vim.org>
parents: 5223
diff changeset
5628 win_height = height + (GetSystemMetrics(SM_CYFRAME) +
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
5629 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5630 + GetSystemMetrics(SM_CYCAPTION)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5631 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5632 + gui_mswin_get_menu_height(FALSE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5633 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5634 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5635
3248
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5636 /* The following should take care of keeping Vim on the same monitor, no
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5637 * matter if the secondary monitor is left or right of the primary
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5638 * monitor. */
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5639 wndpl.rcNormalPosition.right = wndpl.rcNormalPosition.left + win_width;
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5640 wndpl.rcNormalPosition.bottom = wndpl.rcNormalPosition.top + win_height;
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5641
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5642 /* If the window is going off the screen, move it on to the screen. */
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
5643 if ((direction & RESIZE_HOR)
3248
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5644 && wndpl.rcNormalPosition.right > workarea_rect.right)
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5645 OffsetRect(&wndpl.rcNormalPosition,
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5646 workarea_rect.right - wndpl.rcNormalPosition.right, 0);
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5647
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5648 if ((direction & RESIZE_HOR)
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5649 && wndpl.rcNormalPosition.left < workarea_rect.left)
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5650 OffsetRect(&wndpl.rcNormalPosition,
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5651 workarea_rect.left - wndpl.rcNormalPosition.left, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5652
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
5653 if ((direction & RESIZE_VERT)
3248
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5654 && wndpl.rcNormalPosition.bottom > workarea_rect.bottom)
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5655 OffsetRect(&wndpl.rcNormalPosition,
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5656 0, workarea_rect.bottom - wndpl.rcNormalPosition.bottom);
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5657
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5658 if ((direction & RESIZE_VERT)
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5659 && wndpl.rcNormalPosition.top < workarea_rect.top)
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5660 OffsetRect(&wndpl.rcNormalPosition,
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5661 0, workarea_rect.top - wndpl.rcNormalPosition.top);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5662
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5663 /* set window position - we should use SetWindowPlacement rather than
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5664 * SetWindowPos as the MSDN docs say the coord systems returned by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5665 * these two are not compatible. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5666 SetWindowPlacement(s_hwnd, &wndpl);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5667
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5668 SetActiveWindow(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5669 SetFocus(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5670
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5671 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5672 /* Menu may wrap differently now */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5673 gui_mswin_get_menu_height(!gui.starting);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5674 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5675 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5676
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5677
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5678 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5679 gui_mch_set_scrollbar_thumb(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5680 scrollbar_T *sb,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5681 long val,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5682 long size,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5683 long max)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5684 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5685 SCROLLINFO info;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5686
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5687 sb->scroll_shift = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5688 while (max > 32767)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5689 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5690 max = (max + 1) >> 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5691 val >>= 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5692 size >>= 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5693 ++sb->scroll_shift;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5694 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5695
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5696 if (sb->scroll_shift > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5697 ++size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5698
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5699 info.cbSize = sizeof(info);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5700 info.fMask = SIF_POS | SIF_RANGE | SIF_PAGE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5701 info.nPos = val;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5702 info.nMin = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5703 info.nMax = max;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5704 info.nPage = size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5705 SetScrollInfo(sb->id, SB_CTL, &info, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5706 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5707
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5708
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5709 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5710 * Set the current text font.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5711 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5712 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5713 gui_mch_set_font(GuiFont font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5714 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5715 gui.currFont = font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5716 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5717
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5718
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5719 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5720 * Set the current text foreground color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5721 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5722 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5723 gui_mch_set_fg_color(guicolor_T color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5724 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5725 gui.currFgColor = color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5726 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5727
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5728 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5729 * Set the current text background color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5730 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5731 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5732 gui_mch_set_bg_color(guicolor_T color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5733 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5734 gui.currBgColor = color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5735 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5736
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5737 /*
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5738 * Set the current text special color.
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5739 */
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5740 void
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5741 gui_mch_set_sp_color(guicolor_T color)
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5742 {
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5743 gui.currSpColor = color;
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5744 }
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5745
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5746 #if defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5747 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5748 * Multi-byte handling, originally by Sung-Hoon Baek.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5749 * First static functions (no prototypes generated).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5750 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5751 #ifdef _MSC_VER
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5752 # include <ime.h> /* Apparently not needed for Cygwin, MingW or Borland. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5753 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5754 #include <imm.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5755
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5756 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5757 * handle WM_IME_NOTIFY message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5758 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5759 static LRESULT
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
5760 _OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5761 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5762 LRESULT lResult = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5763 HIMC hImc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5764
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5765 if (!pImmGetContext || (hImc = pImmGetContext(hWnd)) == (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5766 return lResult;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5767 switch (dwCommand)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5768 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5769 case IMN_SETOPENSTATUS:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5770 if (pImmGetOpenStatus(hImc))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5771 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5772 pImmSetCompositionFont(hImc, &norm_logfont);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5773 im_set_position(gui.row, gui.col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5774
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5775 /* Disable langmap */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5776 State &= ~LANGMAP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5777 if (State & INSERT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5778 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5779 #if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5780 /* Unshown 'keymap' in status lines */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5781 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5782 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5783 /* Save cursor position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5784 int old_row = gui.row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5785 int old_col = gui.col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5786
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5787 // This must be called here before
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5788 // status_redraw_curbuf(), otherwise the mode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5789 // message may appear in the wrong position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5790 showmode();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5791 status_redraw_curbuf();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5792 update_screen(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5793 /* Restore cursor position */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5794 gui.row = old_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5795 gui.col = old_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5796 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5797 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5798 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5799 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5800 gui_update_cursor(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5801 lResult = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5802 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5803 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5804 pImmReleaseContext(hWnd, hImc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5805 return lResult;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5806 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5807
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5808 static LRESULT
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
5809 _OnImeComposition(HWND hwnd, WPARAM dbcs UNUSED, LPARAM param)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5810 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5811 char_u *ret;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5812 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5813
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5814 if ((param & GCS_RESULTSTR) == 0) /* Composition unfinished. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5815 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5816
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5817 ret = GetResultStr(hwnd, GCS_RESULTSTR, &len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5818 if (ret != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5819 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5820 add_to_input_buf_csi(ret, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5821 vim_free(ret);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5822 return 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5823 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5824 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5825 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5826
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5827 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5828 * get the current composition string, in UCS-2; *lenp is the number of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5829 * *lenp is the number of Unicode characters.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5830 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5831 static short_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5832 GetCompositionString_inUCS2(HIMC hIMC, DWORD GCS, int *lenp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5833 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5834 LONG ret;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5835 LPWSTR wbuf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5836 char_u *buf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5837
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5838 if (!pImmGetContext)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5839 return NULL; /* no imm32.dll */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5840
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5841 /* Try Unicode; this'll always work on NT regardless of codepage. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5842 ret = pImmGetCompositionStringW(hIMC, GCS, NULL, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5843 if (ret == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5844 return NULL; /* empty */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5845
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5846 if (ret > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5847 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5848 /* Allocate the requested buffer plus space for the NUL character. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5849 wbuf = (LPWSTR)alloc(ret + sizeof(WCHAR));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5850 if (wbuf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5851 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5852 pImmGetCompositionStringW(hIMC, GCS, wbuf, ret);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5853 *lenp = ret / sizeof(WCHAR);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5854 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5855 return (short_u *)wbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5856 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5857
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5858 /* ret < 0; we got an error, so try the ANSI version. This'll work
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5859 * on 9x/ME, but only if the codepage happens to be set to whatever
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5860 * we're inputting. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5861 ret = pImmGetCompositionStringA(hIMC, GCS, NULL, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5862 if (ret <= 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5863 return NULL; /* empty or error */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5864
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5865 buf = alloc(ret);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5866 if (buf == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5867 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5868 pImmGetCompositionStringA(hIMC, GCS, buf, ret);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5869
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5870 /* convert from codepage to UCS-2 */
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
5871 MultiByteToWideChar_alloc(GetACP(), 0, (LPCSTR)buf, ret, &wbuf, lenp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5872 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5873
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5874 return (short_u *)wbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5875 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5876
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5877 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5878 * void GetResultStr()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5879 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5880 * This handles WM_IME_COMPOSITION with GCS_RESULTSTR flag on.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5881 * get complete composition string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5882 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5883 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5884 GetResultStr(HWND hwnd, int GCS, int *lenp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5885 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5886 HIMC hIMC; /* Input context handle. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5887 short_u *buf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5888 char_u *convbuf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5889
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5890 if (!pImmGetContext || (hIMC = pImmGetContext(hwnd)) == (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5891 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5892
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5893 /* Reads in the composition string. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5894 buf = GetCompositionString_inUCS2(hIMC, GCS, lenp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5895 if (buf == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5896 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5897
1752
a8aae2e1d2ae updated for version 7.2-049
vimboss
parents: 1621
diff changeset
5898 convbuf = utf16_to_enc(buf, lenp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5899 pImmReleaseContext(hwnd, hIMC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5900 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5901 return convbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5902 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5903 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5904
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5905 /* For global functions we need prototypes. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5906 #if (defined(FEAT_MBYTE) && defined(FEAT_MBYTE_IME)) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5907
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5908 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5909 * set font to IM.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5910 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5911 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5912 im_set_font(LOGFONT *lf)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5913 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5914 HIMC hImc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5915
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5916 if (pImmGetContext && (hImc = pImmGetContext(s_hwnd)) != (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5917 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5918 pImmSetCompositionFont(hImc, lf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5919 pImmReleaseContext(s_hwnd, hImc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5920 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5921 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5922
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5923 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5924 * Notify cursor position to IM.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5925 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5926 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5927 im_set_position(int row, int col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5928 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5929 HIMC hImc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5930
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5931 if (pImmGetContext && (hImc = pImmGetContext(s_hwnd)) != (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5932 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5933 COMPOSITIONFORM cfs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5934
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5935 cfs.dwStyle = CFS_POINT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5936 cfs.ptCurrentPos.x = FILL_X(col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5937 cfs.ptCurrentPos.y = FILL_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5938 MapWindowPoints(s_textArea, s_hwnd, &cfs.ptCurrentPos, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5939 pImmSetCompositionWindow(hImc, &cfs);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5940
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5941 pImmReleaseContext(s_hwnd, hImc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5942 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5943 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5944
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5945 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5946 * Set IM status on ("active" is TRUE) or off ("active" is FALSE).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5947 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5948 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5949 im_set_active(int active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5950 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5951 HIMC hImc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5952 static HIMC hImcOld = (HIMC)0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5953
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5954 if (pImmGetContext) /* if NULL imm32.dll wasn't loaded (yet) */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5955 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5956 if (p_imdisable)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5957 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5958 if (hImcOld == (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5959 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5960 hImcOld = pImmGetContext(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5961 if (hImcOld)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5962 pImmAssociateContext(s_hwnd, (HIMC)0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5963 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5964 active = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5965 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5966 else if (hImcOld != (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5967 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5968 pImmAssociateContext(s_hwnd, hImcOld);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5969 hImcOld = (HIMC)0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5970 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5971
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5972 hImc = pImmGetContext(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5973 if (hImc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5974 {
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5975 /*
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5976 * for Korean ime
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5977 */
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5978 HKL hKL = GetKeyboardLayout(0);
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5979
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5980 if (LOWORD(hKL) == MAKELANGID(LANG_KOREAN, SUBLANG_KOREAN))
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5981 {
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5982 static DWORD dwConversionSaved = 0, dwSentenceSaved = 0;
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5983 static BOOL bSaved = FALSE;
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5984
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5985 if (active)
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5986 {
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5987 /* if we have a saved conversion status, restore it */
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5988 if (bSaved)
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5989 pImmSetConversionStatus(hImc, dwConversionSaved,
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5990 dwSentenceSaved);
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5991 bSaved = FALSE;
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5992 }
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5993 else
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5994 {
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5995 /* save conversion status and disable korean */
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5996 if (pImmGetConversionStatus(hImc, &dwConversionSaved,
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5997 &dwSentenceSaved))
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5998 {
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5999 bSaved = TRUE;
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6000 pImmSetConversionStatus(hImc,
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6001 dwConversionSaved & ~(IME_CMODE_NATIVE
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6002 | IME_CMODE_FULLSHAPE),
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6003 dwSentenceSaved);
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6004 }
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6005 }
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6006 }
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6007
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6008 pImmSetOpenStatus(hImc, active);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6009 pImmReleaseContext(s_hwnd, hImc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6010 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6011 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6012 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6013
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6014 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6015 * Get IM status. When IM is on, return not 0. Else return 0.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6016 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6017 int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
6018 im_get_status(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6019 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6020 int status = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6021 HIMC hImc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6022
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6023 if (pImmGetContext && (hImc = pImmGetContext(s_hwnd)) != (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6024 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6025 status = pImmGetOpenStatus(hImc) ? 1 : 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6026 pImmReleaseContext(s_hwnd, hImc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6027 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6028 return status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6029 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6030
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6031 #endif /* FEAT_MBYTE && FEAT_MBYTE_IME */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6032
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6033 #if defined(FEAT_MBYTE) && !defined(FEAT_MBYTE_IME) && defined(GLOBAL_IME)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6034 /* Win32 with GLOBAL IME */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6035
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6036 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6037 * Notify cursor position to IM.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6038 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6039 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6040 im_set_position(int row, int col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6041 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6042 /* Win32 with GLOBAL IME */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6043 POINT p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6044
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6045 p.x = FILL_X(col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6046 p.y = FILL_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6047 MapWindowPoints(s_textArea, s_hwnd, &p, 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6048 global_ime_set_position(&p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6049 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6050
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6051 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6052 * Set IM status on ("active" is TRUE) or off ("active" is FALSE).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6053 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6054 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6055 im_set_active(int active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6056 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6057 global_ime_set_status(active);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6058 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6059
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6060 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6061 * Get IM status. When IM is on, return not 0. Else return 0.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6062 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6063 int
7856
226ed297307f commit https://github.com/vim/vim/commit/d14e00ea67afbaa8cb4a7e6b1eb306da6a2d5adb
Christian Brabandt <cb@256bit.org>
parents: 7823
diff changeset
6064 im_get_status(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6065 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6066 return global_ime_get_status();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6067 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6068 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6069
26
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6070 #ifdef FEAT_MBYTE
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6071 /*
786
8f6a426bc1e0 updated for version 7.0229
vimboss
parents: 782
diff changeset
6072 * Convert latin9 text "text[len]" to ucs-2 in "unicodebuf".
26
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6073 */
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6074 static void
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6075 latin9_to_ucs(char_u *text, int len, WCHAR *unicodebuf)
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6076 {
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6077 int c;
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6078
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6079 while (--len >= 0)
26
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6080 {
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6081 c = *text++;
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6082 switch (c)
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6083 {
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6084 case 0xa4: c = 0x20ac; break; /* euro */
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6085 case 0xa6: c = 0x0160; break; /* S hat */
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6086 case 0xa8: c = 0x0161; break; /* S -hat */
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6087 case 0xb4: c = 0x017d; break; /* Z hat */
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6088 case 0xb8: c = 0x017e; break; /* Z -hat */
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6089 case 0xbc: c = 0x0152; break; /* OE */
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6090 case 0xbd: c = 0x0153; break; /* oe */
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6091 case 0xbe: c = 0x0178; break; /* Y */
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6092 }
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6093 *unicodebuf++ = c;
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6094 }
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6095 }
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6096 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6097
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6098 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6099 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6100 * What is this for? In the case where you are using Win98 or Win2K or later,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6101 * and you are using a Hebrew font (or Arabic!), Windows does you a favor and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6102 * reverses the string sent to the TextOut... family. This sucks, because we
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6103 * go to a lot of effort to do the right thing, and there doesn't seem to be a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6104 * way to tell Windblows not to do this!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6105 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6106 * The short of it is that this 'RevOut' only gets called if you are running
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6107 * one of the new, "improved" MS OSes, and only if you are running in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6108 * 'rightleft' mode. It makes display take *slightly* longer, but not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6109 * noticeably so.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6110 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6111 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6112 RevOut( HDC s_hdc,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6113 int col,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6114 int row,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6115 UINT foptions,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6116 CONST RECT *pcliprect,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6117 LPCTSTR text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6118 UINT len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6119 CONST INT *padding)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6120 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6121 int ix;
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6122
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6123 for (ix = 0; ix < (int)len; ++ix)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6124 ExtTextOut(s_hdc, col + TEXT_X(ix), row, foptions,
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6125 pcliprect, text + ix, 1, padding);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6126 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6127 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6128
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6129 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6130 gui_mch_draw_string(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6131 int row,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6132 int col,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6133 char_u *text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6134 int len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6135 int flags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6136 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6137 static int *padding = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6138 static int pad_size = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6139 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6140 const RECT *pcliprect = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6141 UINT foptions = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6142 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6143 static WCHAR *unicodebuf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6144 static int *unicodepdy = NULL;
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 205
diff changeset
6145 static int unibuflen = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6146 int n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6147 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6148 HPEN hpen, old_pen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6149 int y;
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6150 #ifdef FEAT_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6151 int font_is_ttf_or_vector = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6152 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6153
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6154 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6155 * Italic and bold text seems to have an extra row of pixels at the bottom
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6156 * (below where the bottom of the character should be). If we draw the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6157 * characters with a solid background, the top row of pixels in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6158 * character below will be overwritten. We can fix this by filling in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6159 * background ourselves, to the correct character proportions, and then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6160 * writing the character in transparent mode. Still have a problem when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6161 * the character is "_", which gets written on to the character below.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6162 * New fix: set gui.char_ascent to -1. This shifts all characters up one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6163 * pixel in their slots, which fixes the problem with the bottom row of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6164 * pixels. We still need this code because otherwise the top row of pixels
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6165 * becomes a problem. - webb.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6166 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6167 static HBRUSH hbr_cache[2] = {NULL, NULL};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6168 static guicolor_T brush_color[2] = {INVALCOLOR, INVALCOLOR};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6169 static int brush_lru = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6170 HBRUSH hbr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6171 RECT rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6172
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6173 if (!(flags & DRAW_TRANSP))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6174 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6175 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6176 * Clear background first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6177 * Note: FillRect() excludes right and bottom of rectangle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6178 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6179 rc.left = FILL_X(col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6180 rc.top = FILL_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6181 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6182 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6183 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6184 /* Compute the length in display cells. */
2338
da6ec32d8d8f Added strwidth() and strchars() functions.
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
6185 rc.right = FILL_X(col + mb_string2cells(text, len));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6186 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6187 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6188 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6189 rc.right = FILL_X(col + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6190 rc.bottom = FILL_Y(row + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6191
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6192 /* Cache the created brush, that saves a lot of time. We need two:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6193 * one for cursor background and one for the normal background. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6194 if (gui.currBgColor == brush_color[0])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6195 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6196 hbr = hbr_cache[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6197 brush_lru = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6198 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6199 else if (gui.currBgColor == brush_color[1])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6200 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6201 hbr = hbr_cache[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6202 brush_lru = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6203 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6204 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6205 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6206 if (hbr_cache[brush_lru] != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6207 DeleteBrush(hbr_cache[brush_lru]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6208 hbr_cache[brush_lru] = CreateSolidBrush(gui.currBgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6209 brush_color[brush_lru] = gui.currBgColor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6210 hbr = hbr_cache[brush_lru];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6211 brush_lru = !brush_lru;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6212 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6213 FillRect(s_hdc, &rc, hbr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6214
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6215 SetBkMode(s_hdc, TRANSPARENT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6217 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6218 * When drawing block cursor, prevent inverted character spilling
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6219 * over character cell (can happen with bold/italic)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6220 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6221 if (flags & DRAW_CURSOR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6222 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6223 pcliprect = &rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6224 foptions = ETO_CLIPPED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6225 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6226 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6227 SetTextColor(s_hdc, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6228 SelectFont(s_hdc, gui.currFont);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6229
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6230 #ifdef FEAT_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6231 if (IS_ENABLE_DIRECTX())
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6232 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6233 TEXTMETRIC tm;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6234
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6235 GetTextMetrics(s_hdc, &tm);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6236 if (tm.tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6237 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6238 font_is_ttf_or_vector = 1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6239 DWriteContext_SetFont(s_dwc, (HFONT)gui.currFont);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6240 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6241 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6242 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6243
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6244 if (pad_size != Columns || padding == NULL || padding[0] != gui.char_width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6245 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6246 vim_free(padding);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6247 pad_size = Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6248
537
e321639cfa3e updated for version 7.0152
vimboss
parents: 474
diff changeset
6249 /* Don't give an out-of-memory message here, it would call us
e321639cfa3e updated for version 7.0152
vimboss
parents: 474
diff changeset
6250 * recursively. */
e321639cfa3e updated for version 7.0152
vimboss
parents: 474
diff changeset
6251 padding = (int *)lalloc(pad_size * sizeof(int), FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6252 if (padding != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6253 for (i = 0; i < pad_size; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6254 padding[i] = gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6255 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6256
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6257 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6258 * We have to provide the padding argument because italic and bold versions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6259 * of fixed-width fonts are often one pixel or so wider than their normal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6260 * versions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6261 * No check for DRAW_BOLD, Windows will have done it already.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6262 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6263
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6264 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6265 /* Check if there are any UTF-8 characters. If not, use normal text
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6266 * output to speed up output. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6267 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6268 for (n = 0; n < len; ++n)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6269 if (text[n] >= 0x80)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6270 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6271
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6272 #if defined(FEAT_DIRECTX)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6273 /* Quick hack to enable DirectWrite. To use DirectWrite (antialias), it is
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6274 * required that unicode drawing routine, currently. So this forces it
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6275 * enabled. */
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6276 if (enc_utf8 && IS_ENABLE_DIRECTX())
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6277 n = 0; /* Keep n < len, to enter block for unicode. */
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6278 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6279
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6280 /* Check if the Unicode buffer exists and is big enough. Create it
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 205
diff changeset
6281 * with the same length as the multi-byte string, the number of wide
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6282 * characters is always equal or smaller. */
26
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6283 if ((enc_utf8
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6284 || (enc_codepage > 0 && (int)GetACP() != enc_codepage)
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6285 || enc_latin9)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6286 && (unicodebuf == NULL || len > unibuflen))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6287 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6288 vim_free(unicodebuf);
537
e321639cfa3e updated for version 7.0152
vimboss
parents: 474
diff changeset
6289 unicodebuf = (WCHAR *)lalloc(len * sizeof(WCHAR), FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6290
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6291 vim_free(unicodepdy);
537
e321639cfa3e updated for version 7.0152
vimboss
parents: 474
diff changeset
6292 unicodepdy = (int *)lalloc(len * sizeof(int), FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6293
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6294 unibuflen = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6295 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6297 if (enc_utf8 && n < len && unicodebuf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6298 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6299 /* Output UTF-8 characters. Caller has already separated
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6300 * composing characters. */
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6301 int i;
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6302 int wlen; /* string length in words */
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6303 int clen; /* string length in characters */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6304 int cells; /* cell width of string up to composing char */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6305 int cw; /* width of current cell */
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6306 int c;
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6307
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 777
diff changeset
6308 wlen = 0;
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6309 clen = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6310 cells = 0;
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6311 for (i = 0; i < len; )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6312 {
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6313 c = utf_ptr2char(text + i);
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6314 if (c >= 0x10000)
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6315 {
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6316 /* Turn into UTF-16 encoding. */
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6317 unicodebuf[wlen++] = ((c - 0x10000) >> 10) + 0xD800;
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6318 unicodebuf[wlen++] = ((c - 0x10000) & 0x3ff) + 0xDC00;
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6319 }
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6320 else
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6321 {
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6322 unicodebuf[wlen++] = c;
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6323 }
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6324 cw = utf_char2cells(c);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6325 if (cw > 2) /* don't use 4 for unprintable char */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6326 cw = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6327 if (unicodepdy != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6328 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6329 /* Use unicodepdy to make characters fit as we expect, even
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6330 * when the font uses different widths (e.g., bold character
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6331 * is wider). */
8273
0c3210caefa6 commit https://github.com/vim/vim/commit/d804fdf4c25435284333258856bc265f1ff10b09
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
6332 if (c >= 0x10000)
0c3210caefa6 commit https://github.com/vim/vim/commit/d804fdf4c25435284333258856bc265f1ff10b09
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
6333 {
0c3210caefa6 commit https://github.com/vim/vim/commit/d804fdf4c25435284333258856bc265f1ff10b09
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
6334 unicodepdy[wlen - 2] = cw * gui.char_width;
0c3210caefa6 commit https://github.com/vim/vim/commit/d804fdf4c25435284333258856bc265f1ff10b09
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
6335 unicodepdy[wlen - 1] = 0;
0c3210caefa6 commit https://github.com/vim/vim/commit/d804fdf4c25435284333258856bc265f1ff10b09
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
6336 }
0c3210caefa6 commit https://github.com/vim/vim/commit/d804fdf4c25435284333258856bc265f1ff10b09
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
6337 else
0c3210caefa6 commit https://github.com/vim/vim/commit/d804fdf4c25435284333258856bc265f1ff10b09
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
6338 unicodepdy[wlen - 1] = cw * gui.char_width;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6340 cells += cw;
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 435
diff changeset
6341 i += utfc_ptr2len_len(text + i, len - i);
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6342 ++clen;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6343 }
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6344 #if defined(FEAT_DIRECTX)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6345 if (IS_ENABLE_DIRECTX() && font_is_ttf_or_vector)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6346 {
6112
d594c1552137 updated for version 7.4.394
Bram Moolenaar <bram@vim.org>
parents: 6110
diff changeset
6347 /* Add one to "cells" for italics. */
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6348 DWriteContext_DrawText(s_dwc, s_hdc, unicodebuf, wlen,
6112
d594c1552137 updated for version 7.4.394
Bram Moolenaar <bram@vim.org>
parents: 6110
diff changeset
6349 TEXT_X(col), TEXT_Y(row), FILL_X(cells + 1), FILL_Y(1),
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6350 gui.char_width, gui.currFgColor);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6351 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6352 else
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6353 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6354 ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row),
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6355 foptions, pcliprect, unicodebuf, wlen, unicodepdy);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6356 len = cells; /* used for underlining */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6357 }
26
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6358 else if ((enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6359 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6360 /* If we want to display codepage data, and the current CP is not the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6361 * ANSI one, we need to go via Unicode. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6362 if (unicodebuf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6363 {
26
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6364 if (enc_latin9)
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6365 latin9_to_ucs(text, len, unicodebuf);
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6366 else
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6367 len = MultiByteToWideChar(enc_codepage,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6368 MB_PRECOMPOSED,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6369 (char *)text, len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6370 (LPWSTR)unicodebuf, unibuflen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6371 if (len != 0)
179
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6372 {
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6373 /* Use unicodepdy to make characters fit as we expect, even
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6374 * when the font uses different widths (e.g., bold character
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6375 * is wider). */
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6376 if (unicodepdy != NULL)
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6377 {
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6378 int i;
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6379 int cw;
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6380
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6381 for (i = 0; i < len; ++i)
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6382 {
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6383 cw = utf_char2cells(unicodebuf[i]);
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6384 if (cw > 2)
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6385 cw = 1;
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6386 unicodepdy[i] = cw * gui.char_width;
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6387 }
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6388 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6389 ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row),
179
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6390 foptions, pcliprect, unicodebuf, len, unicodepdy);
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6391 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6392 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6393 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6394 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6395 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6396 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6397 #ifdef FEAT_RIGHTLEFT
6226
2fd96725b063 updated for version 7.4.448
Bram Moolenaar <bram@vim.org>
parents: 6112
diff changeset
6398 /* Windows will mess up RL text, so we have to draw it character by
2fd96725b063 updated for version 7.4.448
Bram Moolenaar <bram@vim.org>
parents: 6112
diff changeset
6399 * character. Only do this if RL is on, since it's slow. */
2fd96725b063 updated for version 7.4.448
Bram Moolenaar <bram@vim.org>
parents: 6112
diff changeset
6400 if (curwin->w_p_rl)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6401 RevOut(s_hdc, TEXT_X(col), TEXT_Y(row),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6402 foptions, pcliprect, (char *)text, len, padding);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6403 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6404 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6405 ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6406 foptions, pcliprect, (char *)text, len, padding);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6408
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6409 /* Underline */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6410 if (flags & DRAW_UNDERL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6411 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6412 hpen = CreatePen(PS_SOLID, 1, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6413 old_pen = SelectObject(s_hdc, hpen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6414 /* When p_linespace is 0, overwrite the bottom row of pixels.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6415 * Otherwise put the line just below the character. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6416 y = FILL_Y(row + 1) - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6417 if (p_linespace > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6418 y -= p_linespace - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6419 MoveToEx(s_hdc, FILL_X(col), y, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6420 /* Note: LineTo() excludes the last pixel in the line. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6421 LineTo(s_hdc, FILL_X(col + len), y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6422 DeleteObject(SelectObject(s_hdc, old_pen));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6423 }
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6424
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6425 /* Undercurl */
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6426 if (flags & DRAW_UNDERC)
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6427 {
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6428 int x;
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6429 int offset;
323
03b3684919e3 updated for version 7.0084
vimboss
parents: 293
diff changeset
6430 static const int val[8] = {1, 0, 0, 0, 1, 2, 2, 2 };
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6431
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6432 y = FILL_Y(row + 1) - 1;
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6433 for (x = FILL_X(col); x < FILL_X(col + len); ++x)
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6434 {
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6435 offset = val[x % 8];
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6436 SetPixel(s_hdc, x, y - offset, gui.currSpColor);
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6437 }
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6438 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6439 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6440
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6441
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6442 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6443 * Output routines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6444 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6445
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6446 /* Flush any output to the screen */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6447 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6448 gui_mch_flush(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6449 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6450 # if defined(__BORLANDC__)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6451 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6452 * The GdiFlush declaration (in Borland C 5.01 <wingdi.h>) is not a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6453 * prototype declaration.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6454 * The compiler complains if __stdcall is not used in both declarations.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6455 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6456 BOOL __stdcall GdiFlush(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6457 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6458
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6459 GdiFlush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6460 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6462 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6463 clear_rect(RECT *rcp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6464 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6465 HBRUSH hbr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6466
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6467 hbr = CreateSolidBrush(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6468 FillRect(s_hdc, rcp, hbr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6469 DeleteBrush(hbr);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6470 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6471
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6472
636
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6473 void
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6474 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6475 {
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6476 RECT workarea_rect;
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6477
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6478 get_work_area(&workarea_rect);
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6479
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
6480 *screen_w = workarea_rect.right - workarea_rect.left
5225
8f983df0299f updated for version 7.4a.038
Bram Moolenaar <bram@vim.org>
parents: 5223
diff changeset
6481 - (GetSystemMetrics(SM_CXFRAME) +
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6482 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2;
636
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6483
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6484 /* FIXME: dirty trick: Because the gui_get_base_height() doesn't include
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6485 * the menubar for MSwin, we subtract it from the screen height, so that
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6486 * the window size can be made to fit on the screen. */
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
6487 *screen_h = workarea_rect.bottom - workarea_rect.top
5225
8f983df0299f updated for version 7.4a.038
Bram Moolenaar <bram@vim.org>
parents: 5223
diff changeset
6488 - (GetSystemMetrics(SM_CYFRAME) +
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6489 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2
636
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6490 - GetSystemMetrics(SM_CYCAPTION)
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6491 #ifdef FEAT_MENU
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
6492 - gui_mswin_get_menu_height(FALSE)
636
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6493 #endif
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
6494 ;
636
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6495 }
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6496
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6497
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6498 #if defined(FEAT_MENU) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6499 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6500 * Add a sub menu to the menu bar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6501 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6502 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6503 gui_mch_add_menu(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6504 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6505 int pos)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6506 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6507 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6509 menu->submenu_id = CreatePopupMenu();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6510 menu->id = s_menu_id++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6511
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6512 if (menu_is_menubar(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6513 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6514 #ifdef FEAT_MBYTE
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6515 WCHAR *wn = NULL;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6516
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6517 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6518 {
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6519 /* 'encoding' differs from active codepage: convert menu name
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6520 * and use wide function */
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6521 wn = enc_to_utf16(menu->name, NULL);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6522 if (wn != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6523 {
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6524 MENUITEMINFOW infow;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6525
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6526 infow.cbSize = sizeof(infow);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6527 infow.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6528 | MIIM_SUBMENU;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6529 infow.dwItemData = (long_u)menu;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6530 infow.wID = menu->id;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6531 infow.fType = MFT_STRING;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6532 infow.dwTypeData = wn;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6533 infow.cch = (UINT)wcslen(wn);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6534 infow.hSubMenu = menu->submenu_id;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6535 InsertMenuItemW((parent == NULL)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6536 ? s_menuBar : parent->submenu_id,
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6537 (UINT)pos, TRUE, &infow);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6538 vim_free(wn);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6539 }
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6540 }
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6541
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6542 if (wn == NULL)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6543 #endif
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6544 {
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6545 MENUITEMINFO info;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6546
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6547 info.cbSize = sizeof(info);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6548 info.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID | MIIM_SUBMENU;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6549 info.dwItemData = (long_u)menu;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6550 info.wID = menu->id;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6551 info.fType = MFT_STRING;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6552 info.dwTypeData = (LPTSTR)menu->name;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6553 info.cch = (UINT)STRLEN(menu->name);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6554 info.hSubMenu = menu->submenu_id;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6555 InsertMenuItem((parent == NULL)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6556 ? s_menuBar : parent->submenu_id,
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6557 (UINT)pos, TRUE, &info);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6558 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6559 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6560
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6561 /* Fix window size if menu may have wrapped */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6562 if (parent == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6563 gui_mswin_get_menu_height(!gui.starting);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6564 #ifdef FEAT_TEAROFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6565 else if (IsWindow(parent->tearoff_handle))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6566 rebuild_tearoff(parent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6567 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6568 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6569
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6570 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6571 gui_mch_show_popupmenu(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6572 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6573 POINT mp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6574
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6575 (void)GetCursorPos((LPPOINT)&mp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6576 gui_mch_show_popupmenu_at(menu, (int)mp.x, (int)mp.y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6577 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6578
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6579 void
401
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6580 gui_make_popup(char_u *path_name, int mouse_pos)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6581 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6582 vimmenu_T *menu = gui_find_menu(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6583
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6584 if (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6585 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6586 POINT p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6587
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6588 /* Find the position of the current cursor */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6589 GetDCOrgEx(s_hdc, &p);
401
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6590 if (mouse_pos)
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6591 {
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6592 int mx, my;
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6593
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6594 gui_mch_getmouse(&mx, &my);
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6595 p.x += mx;
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6596 p.y += my;
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6597 }
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6598 else if (curwin != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6599 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6600 p.x += TEXT_X(W_WINCOL(curwin) + curwin->w_wcol + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6601 p.y += TEXT_Y(W_WINROW(curwin) + curwin->w_wrow + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6602 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6603 msg_scroll = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6604 gui_mch_show_popupmenu_at(menu, (int)p.x, (int)p.y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6605 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6606 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6607
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6608 #if defined(FEAT_TEAROFF) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6609 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6610 * Given a menu descriptor, e.g. "File.New", find it in the menu hierarchy and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6611 * create it as a pseudo-"tearoff menu".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6612 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6613 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6614 gui_make_tearoff(char_u *path_name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6615 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6616 vimmenu_T *menu = gui_find_menu(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6617
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6618 /* Found the menu, so tear it off. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6619 if (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6620 gui_mch_tearoff(menu->dname, menu, 0xffffL, 0xffffL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6621 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6622 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6623
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6624 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6625 * Add a menu item to a menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6626 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6627 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6628 gui_mch_add_menu_item(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6629 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6630 int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6631 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6632 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6633
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6634 menu->id = s_menu_id++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6635 menu->submenu_id = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6636
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6637 #ifdef FEAT_TEAROFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6638 if (STRNCMP(menu->name, TEAR_STRING, TEAR_LEN) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6639 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6640 InsertMenu(parent->submenu_id, (UINT)idx, MF_BITMAP|MF_BYPOSITION,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6641 (UINT)menu->id, (LPCTSTR) s_htearbitmap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6642 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6643 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6644 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6645 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6646 if (menu_is_toolbar(parent->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6647 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6648 TBBUTTON newtb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6649
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6650 vim_memset(&newtb, 0, sizeof(newtb));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6651 if (menu_is_separator(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6652 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6653 newtb.iBitmap = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6654 newtb.fsStyle = TBSTYLE_SEP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6655 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6656 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6657 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6658 newtb.iBitmap = get_toolbar_bitmap(menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6659 newtb.fsStyle = TBSTYLE_BUTTON;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6660 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6661 newtb.idCommand = menu->id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6662 newtb.fsState = TBSTATE_ENABLED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6663 newtb.iString = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6664 SendMessage(s_toolbarhwnd, TB_INSERTBUTTON, (WPARAM)idx,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6665 (LPARAM)&newtb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6666 menu->submenu_id = (HMENU)-1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6667 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6668 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6669 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6670 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6671 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6672 WCHAR *wn = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6673
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6674 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6675 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6676 /* 'encoding' differs from active codepage: convert menu item name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6677 * and use wide function */
1752
a8aae2e1d2ae updated for version 7.2-049
vimboss
parents: 1621
diff changeset
6678 wn = enc_to_utf16(menu->name, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6679 if (wn != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6680 {
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6681 InsertMenuW(parent->submenu_id, (UINT)idx,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6682 (menu_is_separator(menu->name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6683 ? MF_SEPARATOR : MF_STRING) | MF_BYPOSITION,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6684 (UINT)menu->id, wn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6685 vim_free(wn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6686 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6687 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6688 if (wn == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6689 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6690 InsertMenu(parent->submenu_id, (UINT)idx,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6691 (menu_is_separator(menu->name) ? MF_SEPARATOR : MF_STRING)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6692 | MF_BYPOSITION,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6693 (UINT)menu->id, (LPCTSTR)menu->name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6694 #ifdef FEAT_TEAROFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6695 if (IsWindow(parent->tearoff_handle))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6696 rebuild_tearoff(parent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6697 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6698 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6699 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6700
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6701 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6702 * Destroy the machine specific menu widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6703 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6704 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6705 gui_mch_destroy_menu(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6706 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6707 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6708 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6709 * is this a toolbar button?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6710 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6711 if (menu->submenu_id == (HMENU)-1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6712 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6713 int iButton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6714
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6715 iButton = (int)SendMessage(s_toolbarhwnd, TB_COMMANDTOINDEX,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6716 (WPARAM)menu->id, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6717 SendMessage(s_toolbarhwnd, TB_DELETEBUTTON, (WPARAM)iButton, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6718 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6719 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6720 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6721 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6722 if (menu->parent != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6723 && menu_is_popup(menu->parent->dname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6724 && menu->parent->submenu_id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6725 RemoveMenu(menu->parent->submenu_id, menu->id, MF_BYCOMMAND);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6726 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6727 RemoveMenu(s_menuBar, menu->id, MF_BYCOMMAND);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6728 if (menu->submenu_id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6729 DestroyMenu(menu->submenu_id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6730 #ifdef FEAT_TEAROFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6731 if (IsWindow(menu->tearoff_handle))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6732 DestroyWindow(menu->tearoff_handle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6733 if (menu->parent != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6734 && menu->parent->children != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6735 && IsWindow(menu->parent->tearoff_handle))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6736 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6737 /* This menu must not show up when rebuilding the tearoff window. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6738 menu->modes = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6739 rebuild_tearoff(menu->parent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6740 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6741 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6742 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6743 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6744
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6745 #ifdef FEAT_TEAROFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6746 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6747 rebuild_tearoff(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6748 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6749 /*hackish*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6750 char_u tbuf[128];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6751 RECT trect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6752 RECT rct;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6753 RECT roct;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6754 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6755
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6756 HWND thwnd = menu->tearoff_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6757
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
6758 GetWindowText(thwnd, (LPSTR)tbuf, 127);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6759 if (GetWindowRect(thwnd, &trect)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6760 && GetWindowRect(s_hwnd, &rct)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6761 && GetClientRect(s_hwnd, &roct))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6762 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6763 x = trect.left - rct.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6764 y = (trect.top - rct.bottom + roct.bottom);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6765 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6766 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6767 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6768 x = y = 0xffffL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6769 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6770 DestroyWindow(thwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6771 if (menu->children != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6772 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6773 gui_mch_tearoff(tbuf, menu, x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6774 if (IsWindow(menu->tearoff_handle))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6775 (void) SetWindowPos(menu->tearoff_handle,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6776 NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6777 (int)trect.left,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6778 (int)trect.top,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6779 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6780 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6781 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6782 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6783 #endif /* FEAT_TEAROFF */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6784
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6785 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6786 * Make a menu either grey or not grey.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6787 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6788 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6789 gui_mch_menu_grey(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6790 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6791 int grey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6792 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6793 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6794 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6795 * is this a toolbar button?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6796 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6797 if (menu->submenu_id == (HMENU)-1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6798 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6799 SendMessage(s_toolbarhwnd, TB_ENABLEBUTTON,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6800 (WPARAM)menu->id, (LPARAM) MAKELONG((grey ? FALSE : TRUE), 0) );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6801 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6802 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6803 #endif
9236
9940e9b2a725 commit https://github.com/vim/vim/commit/762f1754370a1278167c8cba6c047ef319fc099c
Christian Brabandt <cb@256bit.org>
parents: 9213
diff changeset
6804 (void)EnableMenuItem(menu->parent ? menu->parent->submenu_id : s_menuBar,
9940e9b2a725 commit https://github.com/vim/vim/commit/762f1754370a1278167c8cba6c047ef319fc099c
Christian Brabandt <cb@256bit.org>
parents: 9213
diff changeset
6805 menu->id, MF_BYCOMMAND | (grey ? MF_GRAYED : MF_ENABLED));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6806
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6807 #ifdef FEAT_TEAROFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6808 if ((menu->parent != NULL) && (IsWindow(menu->parent->tearoff_handle)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6809 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6810 WORD menuID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6811 HWND menuHandle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6812
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6813 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6814 * A tearoff button has changed state.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6815 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6816 if (menu->children == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6817 menuID = (WORD)(menu->id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6818 else
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
6819 menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6820 menuHandle = GetDlgItem(menu->parent->tearoff_handle, menuID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6821 if (menuHandle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6822 EnableWindow(menuHandle, !grey);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6823
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6824 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6825 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6826 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6827
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6828 #endif /* FEAT_MENU */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6829
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6830
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6831 /* define some macros used to make the dialogue creation more readable */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6832
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6833 #define add_string(s) strcpy((LPSTR)p, s); (LPSTR)p += (strlen((LPSTR)p) + 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6834 #define add_word(x) *p++ = (x)
615
7fe13e0f5dce updated for version 7.0175
vimboss
parents: 537
diff changeset
6835 #define add_long(x) dwp = (DWORD *)p; *dwp++ = (x); p = (WORD *)dwp
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6836
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6837 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6838 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6839 * stuff for dialogs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6840 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6841
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6842 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6843 * The callback routine used by all the dialogs. Very simple. First,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6844 * acknowledges the INITDIALOG message so that Windows knows to do standard
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6845 * dialog stuff (Return = default, Esc = cancel....) Second, if a button is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6846 * pressed, return that button's ID - IDCANCEL (2), which is the button's
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6847 * number.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6848 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6849 static LRESULT CALLBACK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6850 dialog_callback(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6851 HWND hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6852 UINT message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6853 WPARAM wParam,
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
6854 LPARAM lParam UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6855 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6856 if (message == WM_INITDIALOG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6857 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6858 CenterWindow(hwnd, GetWindow(hwnd, GW_OWNER));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6859 /* Set focus to the dialog. Set the default button, if specified. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6860 (void)SetFocus(hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6861 if (dialog_default_button > IDCANCEL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6862 (void)SetFocus(GetDlgItem(hwnd, dialog_default_button));
1356
c87f38b71d27 updated for version 7.1-070
vimboss
parents: 1288
diff changeset
6863 else
c87f38b71d27 updated for version 7.1-070
vimboss
parents: 1288
diff changeset
6864 /* We don't have a default, set focus on another element of the
c87f38b71d27 updated for version 7.1-070
vimboss
parents: 1288
diff changeset
6865 * dialog window, probably the icon */
c87f38b71d27 updated for version 7.1-070
vimboss
parents: 1288
diff changeset
6866 (void)SetFocus(GetDlgItem(hwnd, DLG_NONBUTTON_CONTROL));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6867 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6868 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6869
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6870 if (message == WM_COMMAND)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6871 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6872 int button = LOWORD(wParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6873
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6874 /* Don't end the dialog if something was selected that was
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6875 * not a button.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6876 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6877 if (button >= DLG_NONBUTTON_CONTROL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6878 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6879
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6880 /* If the edit box exists, copy the string. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6881 if (s_textfield != NULL)
1795
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6882 {
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6883 # ifdef FEAT_MBYTE
1795
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6884 /* If the OS is Windows NT, and 'encoding' differs from active
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6885 * codepage: use wide function and convert text. */
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6886 if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2224
diff changeset
6887 {
1795
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6888 WCHAR *wp = (WCHAR *)alloc(IOSIZE * sizeof(WCHAR));
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6889 char_u *p;
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6890
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6891 GetDlgItemTextW(hwnd, DLG_NONBUTTON_CONTROL + 2, wp, IOSIZE);
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6892 p = utf16_to_enc(wp, NULL);
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6893 vim_strncpy(s_textfield, p, IOSIZE);
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6894 vim_free(p);
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6895 vim_free(wp);
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6896 }
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6897 else
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6898 # endif
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6899 GetDlgItemText(hwnd, DLG_NONBUTTON_CONTROL + 2,
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
6900 (LPSTR)s_textfield, IOSIZE);
1795
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6901 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6902
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6903 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6904 * Need to check for IDOK because if the user just hits Return to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6905 * accept the default value, some reason this is what we get.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6906 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6907 if (button == IDOK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6908 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6909 if (dialog_default_button > IDCANCEL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6910 EndDialog(hwnd, dialog_default_button);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6911 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6912 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6913 EndDialog(hwnd, button - IDCANCEL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6914 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6915 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6916
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6917 if ((message == WM_SYSCOMMAND) && (wParam == SC_CLOSE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6918 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6919 EndDialog(hwnd, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6920 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6921 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6922 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6923 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6924
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6925 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6926 * Create a dialog dynamically from the parameter strings.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6927 * type = type of dialog (question, alert, etc.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6928 * title = dialog title. may be NULL for default title.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6929 * message = text to display. Dialog sizes to accommodate it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6930 * buttons = '\n' separated list of button captions, default first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6931 * dfltbutton = number of default button.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6932 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6933 * This routine returns 1 if the first button is pressed,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6934 * 2 for the second, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6935 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6936 * 0 indicates Esc was pressed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6937 * -1 for unexpected error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6938 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6939 * If stubbing out this fn, return 1.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6940 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6941
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
6942 static const char *dlg_icons[] = /* must match names in resource file */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6943 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6944 "IDR_VIM",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6945 "IDR_VIM_ERROR",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6946 "IDR_VIM_ALERT",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6947 "IDR_VIM_INFO",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6948 "IDR_VIM_QUESTION"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6949 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6950
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6951 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6952 gui_mch_dialog(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6953 int type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6954 char_u *title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6955 char_u *message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6956 char_u *buttons,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6957 int dfltbutton,
2684
951641b8784d updated for version 7.3.102
Bram Moolenaar <bram@vim.org>
parents: 2616
diff changeset
6958 char_u *textfield,
951641b8784d updated for version 7.3.102
Bram Moolenaar <bram@vim.org>
parents: 2616
diff changeset
6959 int ex_cmd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6960 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6961 WORD *p, *pdlgtemplate, *pnumitems;
615
7fe13e0f5dce updated for version 7.0175
vimboss
parents: 537
diff changeset
6962 DWORD *dwp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6963 int numButtons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6964 int *buttonWidths, *buttonPositions;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6965 int buttonYpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6966 int nchar, i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6967 DWORD lStyle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6968 int dlgwidth = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6969 int dlgheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6970 int editboxheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6971 int horizWidth = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6972 int msgheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6973 char_u *pstart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6974 char_u *pend;
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6975 char_u *last_white;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6976 char_u *tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6977 RECT rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6978 HWND hwnd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6979 HDC hdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6980 HFONT font, oldFont;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6981 TEXTMETRIC fontInfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6982 int fontHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6983 int textWidth, minButtonWidth, messageWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6984 int maxDialogWidth;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
6985 int maxDialogHeight;
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
6986 int scroll_flag = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6987 int vertical;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6988 int dlgPaddingX;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6989 int dlgPaddingY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6990 #ifdef USE_SYSMENU_FONT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6991 LOGFONT lfSysmenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6992 int use_lfSysmenu = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6993 #endif
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6994 garray_T ga;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6995 int l;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6996
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6997 #ifndef NO_CONSOLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6998 /* Don't output anything in silent mode ("ex -s") */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6999 if (silent_mode)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7000 return dfltbutton; /* return default option */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7001 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7002
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7003 if (s_hwnd == NULL)
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7004 get_dialog_font_metrics();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7005
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7006 if ((type < 0) || (type > VIM_LAST_TYPE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7007 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7008
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7009 /* allocate some memory for dialog template */
39
410fa1a31baf updated for version 7.0023
vimboss
parents: 36
diff changeset
7010 /* TODO should compute this really */
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7011 pdlgtemplate = p = (PWORD)LocalAlloc(LPTR,
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7012 DLG_ALLOC_SIZE + STRLEN(message) * 2);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7013
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7014 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7015 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7016
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7017 /*
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 4238
diff changeset
7018 * make a copy of 'buttons' to fiddle with it. compiler grizzles because
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7019 * vim_strsave() doesn't take a const arg (why not?), so cast away the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7020 * const.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7021 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7022 tbuffer = vim_strsave(buttons);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7023 if (tbuffer == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7024 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7025
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7026 --dfltbutton; /* Change from one-based to zero-based */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7027
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7028 /* Count buttons */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7029 numButtons = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7030 for (i = 0; tbuffer[i] != '\0'; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7031 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7032 if (tbuffer[i] == DLG_BUTTON_SEP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7033 numButtons++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7034 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7035 if (dfltbutton >= numButtons)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7036 dfltbutton = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7037
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7038 /* Allocate array to hold the width of each button */
537
e321639cfa3e updated for version 7.0152
vimboss
parents: 474
diff changeset
7039 buttonWidths = (int *)lalloc(numButtons * sizeof(int), TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7040 if (buttonWidths == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7041 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7042
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7043 /* Allocate array to hold the X position of each button */
537
e321639cfa3e updated for version 7.0152
vimboss
parents: 474
diff changeset
7044 buttonPositions = (int *)lalloc(numButtons * sizeof(int), TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7045 if (buttonPositions == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7046 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7047
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7048 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7049 * Calculate how big the dialog must be.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7050 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7051 hwnd = GetDesktopWindow();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7052 hdc = GetWindowDC(hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7053 #ifdef USE_SYSMENU_FONT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7054 if (gui_w32_get_menu_font(&lfSysmenu) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7055 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7056 font = CreateFontIndirect(&lfSysmenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7057 use_lfSysmenu = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7058 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7059 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7060 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7061 font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7062 VARIABLE_PITCH , DLG_FONT_NAME);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7063 if (s_usenewlook)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7064 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7065 oldFont = SelectFont(hdc, font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7066 dlgPaddingX = DLG_PADDING_X;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7067 dlgPaddingY = DLG_PADDING_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7068 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7069 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7070 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7071 oldFont = SelectFont(hdc, GetStockObject(SYSTEM_FONT));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7072 dlgPaddingX = DLG_OLD_STYLE_PADDING_X;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7073 dlgPaddingY = DLG_OLD_STYLE_PADDING_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7074 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7075 GetTextMetrics(hdc, &fontInfo);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7076 fontHeight = fontInfo.tmHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7077
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7078 /* Minimum width for horizontal button */
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7079 minButtonWidth = GetTextWidth(hdc, (char_u *)"Cancel", 6);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7080
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7081 /* Maximum width of a dialog, if possible */
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7082 if (s_hwnd == NULL)
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7083 {
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7084 RECT workarea_rect;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7085
636
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
7086 /* We don't have a window, use the desktop area. */
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7087 get_work_area(&workarea_rect);
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7088 maxDialogWidth = workarea_rect.right - workarea_rect.left - 100;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7089 if (maxDialogWidth > 600)
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7090 maxDialogWidth = 600;
5249
47a09a572ea6 updated for version 7.4b.001
Bram Moolenaar <bram@vim.org>
parents: 5225
diff changeset
7091 /* Leave some room for the taskbar. */
47a09a572ea6 updated for version 7.4b.001
Bram Moolenaar <bram@vim.org>
parents: 5225
diff changeset
7092 maxDialogHeight = workarea_rect.bottom - workarea_rect.top - 150;
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7093 }
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7094 else
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7095 {
5284
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7096 /* Use our own window for the size, unless it's very small. */
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7097 GetWindowRect(s_hwnd, &rect);
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7098 maxDialogWidth = rect.right - rect.left
5225
8f983df0299f updated for version 7.4a.038
Bram Moolenaar <bram@vim.org>
parents: 5223
diff changeset
7099 - (GetSystemMetrics(SM_CXFRAME) +
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
7100 GetSystemMetrics(SM_CXPADDEDBORDER)) * 2;
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7101 if (maxDialogWidth < DLG_MIN_MAX_WIDTH)
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7102 maxDialogWidth = DLG_MIN_MAX_WIDTH;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7103
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7104 maxDialogHeight = rect.bottom - rect.top
5249
47a09a572ea6 updated for version 7.4b.001
Bram Moolenaar <bram@vim.org>
parents: 5225
diff changeset
7105 - (GetSystemMetrics(SM_CYFRAME) +
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
7106 GetSystemMetrics(SM_CXPADDEDBORDER)) * 4
5284
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7107 - GetSystemMetrics(SM_CYCAPTION);
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7108 if (maxDialogHeight < DLG_MIN_MAX_HEIGHT)
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7109 maxDialogHeight = DLG_MIN_MAX_HEIGHT;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7110 }
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7111
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7112 /* Set dlgwidth to width of message.
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7113 * Copy the message into "ga", changing NL to CR-NL and inserting line
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7114 * breaks where needed. */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7115 pstart = message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7116 messageWidth = 0;
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7117 msgheight = 0;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7118 ga_init2(&ga, sizeof(char), 500);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7119 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7120 {
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7121 msgheight += fontHeight; /* at least one line */
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7122
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7123 /* Need to figure out where to break the string. The system does it
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7124 * at a word boundary, which would mean we can't compute the number of
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7125 * wrapped lines. */
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7126 textWidth = 0;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7127 last_white = NULL;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7128 for (pend = pstart; *pend != NUL && *pend != '\n'; )
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7129 {
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7130 #ifdef FEAT_MBYTE
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 435
diff changeset
7131 l = (*mb_ptr2len)(pend);
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7132 #else
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7133 l = 1;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7134 #endif
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10783
diff changeset
7135 if (l == 1 && VIM_ISWHITE(*pend)
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7136 && textWidth > maxDialogWidth * 3 / 4)
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7137 last_white = pend;
4999
b4a71dbdb787 updated for version 7.3.1244
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
7138 textWidth += GetTextWidthEnc(hdc, pend, l);
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7139 if (textWidth >= maxDialogWidth)
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7140 {
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7141 /* Line will wrap. */
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7142 messageWidth = maxDialogWidth;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7143 msgheight += fontHeight;
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7144 textWidth = 0;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7145
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7146 if (last_white != NULL)
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7147 {
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7148 /* break the line just after a space */
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 824
diff changeset
7149 ga.ga_len -= (int)(pend - (last_white + 1));
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7150 pend = last_white + 1;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7151 last_white = NULL;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7152 }
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7153 ga_append(&ga, '\r');
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7154 ga_append(&ga, '\n');
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7155 continue;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7156 }
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7157
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7158 while (--l >= 0)
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7159 ga_append(&ga, *pend++);
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7160 }
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7161 if (textWidth > messageWidth)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7162 messageWidth = textWidth;
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7163
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7164 ga_append(&ga, '\r');
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7165 ga_append(&ga, '\n');
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7166 pstart = pend + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7167 } while (*pend != NUL);
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7168
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7169 if (ga.ga_data != NULL)
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7170 message = ga.ga_data;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7171
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7172 messageWidth += 10; /* roundoff space */
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7173
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7174 /* Add width of icon to dlgwidth, and some space */
5284
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7175 dlgwidth = messageWidth + DLG_ICON_WIDTH + 3 * dlgPaddingX
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7176 + GetSystemMetrics(SM_CXVSCROLL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7178 if (msgheight < DLG_ICON_HEIGHT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7179 msgheight = DLG_ICON_HEIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7181 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7182 * Check button names. A long one will make the dialog wider.
1116
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
7183 * When called early (-register error message) p_go isn't initialized.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7184 */
1116
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
7185 vertical = (p_go != NULL && vim_strchr(p_go, GO_VERTICAL) != NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7186 if (!vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7187 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7188 // Place buttons horizontally if they fit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7189 horizWidth = dlgPaddingX;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7190 pstart = tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7191 i = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7192 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7193 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7194 pend = vim_strchr(pstart, DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7195 if (pend == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7196 pend = pstart + STRLEN(pstart); // Last button name.
5001
43329b2b5b79 updated for version 7.3.1245
Bram Moolenaar <bram@vim.org>
parents: 4999
diff changeset
7197 textWidth = GetTextWidthEnc(hdc, pstart, (int)(pend - pstart));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7198 if (textWidth < minButtonWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7199 textWidth = minButtonWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7200 textWidth += dlgPaddingX; /* Padding within button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7201 buttonWidths[i] = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7202 buttonPositions[i++] = horizWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7203 horizWidth += textWidth + dlgPaddingX; /* Pad between buttons */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7204 pstart = pend + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7205 } while (*pend != NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7207 if (horizWidth > maxDialogWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7208 vertical = TRUE; // Too wide to fit on the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7209 else if (horizWidth > dlgwidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7210 dlgwidth = horizWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7211 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7212
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7213 if (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7214 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7215 // Stack buttons vertically.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7216 pstart = tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7217 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7218 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7219 pend = vim_strchr(pstart, DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7220 if (pend == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7221 pend = pstart + STRLEN(pstart); // Last button name.
5001
43329b2b5b79 updated for version 7.3.1245
Bram Moolenaar <bram@vim.org>
parents: 4999
diff changeset
7222 textWidth = GetTextWidthEnc(hdc, pstart, (int)(pend - pstart));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7223 textWidth += dlgPaddingX; /* Padding within button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7224 textWidth += DLG_VERT_PADDING_X * 2; /* Padding around button */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7225 if (textWidth > dlgwidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7226 dlgwidth = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7227 pstart = pend + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7228 } while (*pend != NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7229 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7230
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7231 if (dlgwidth < DLG_MIN_WIDTH)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7232 dlgwidth = DLG_MIN_WIDTH; /* Don't allow a really thin dialog!*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7233
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7234 /* start to fill in the dlgtemplate information. addressing by WORDs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7235 if (s_usenewlook)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7236 lStyle = DS_MODALFRAME | WS_CAPTION |DS_3DLOOK| WS_VISIBLE |DS_SETFONT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7237 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7238 lStyle = DS_MODALFRAME | WS_CAPTION |DS_3DLOOK| WS_VISIBLE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7239
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7240 add_long(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7241 add_long(0); // (lExtendedStyle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7242 pnumitems = p; /*save where the number of items must be stored*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7243 add_word(0); // NumberOfItems(will change later)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7244 add_word(10); // x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7245 add_word(10); // y
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7246 add_word(PixelToDialogX(dlgwidth)); // cx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7247
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7248 // Dialog height.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7249 if (vertical)
5284
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7250 dlgheight = msgheight + 2 * dlgPaddingY
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7251 + DLG_VERT_PADDING_Y + 2 * fontHeight * numButtons;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7252 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7253 dlgheight = msgheight + 3 * dlgPaddingY + 2 * fontHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7255 // Dialog needs to be taller if contains an edit box.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7256 editboxheight = fontHeight + dlgPaddingY + 4 * DLG_VERT_PADDING_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7257 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7258 dlgheight += editboxheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7259
5284
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7260 /* Restrict the size to a maximum. Causes a scrollbar to show up. */
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7261 if (dlgheight > maxDialogHeight)
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7262 {
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
7263 msgheight = msgheight - (dlgheight - maxDialogHeight);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
7264 dlgheight = maxDialogHeight;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
7265 scroll_flag = WS_VSCROLL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
7266 /* Make sure scrollbar doesn't appear in the middle of the dialog */
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
7267 messageWidth = dlgwidth - DLG_ICON_WIDTH - 3 * dlgPaddingX;
5284
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7268 }
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7269
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7270 add_word(PixelToDialogY(dlgheight));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7271
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7272 add_word(0); // Menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7273 add_word(0); // Class
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7274
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7275 /* copy the title of the dialog */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7276 nchar = nCopyAnsiToWideChar(p, (title ?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7277 (LPSTR)title :
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7278 (LPSTR)("Vim "VIM_VERSION_MEDIUM)));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7279 p += nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7280
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7281 if (s_usenewlook)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7282 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7283 /* do the font, since DS_3DLOOK doesn't work properly */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7284 #ifdef USE_SYSMENU_FONT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7285 if (use_lfSysmenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7286 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7287 /* point size */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7288 *p++ = -MulDiv(lfSysmenu.lfHeight, 72,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7289 GetDeviceCaps(hdc, LOGPIXELSY));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7290 nchar = nCopyAnsiToWideChar(p, TEXT(lfSysmenu.lfFaceName));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7291 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7292 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7293 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7294 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7295 *p++ = DLG_FONT_POINT_SIZE; // point size
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7296 nchar = nCopyAnsiToWideChar(p, TEXT(DLG_FONT_NAME));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7297 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7298 p += nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7299 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7300
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7301 buttonYpos = msgheight + 2 * dlgPaddingY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7302
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7303 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7304 buttonYpos += editboxheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7305
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7306 pstart = tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7307 if (!vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7308 horizWidth = (dlgwidth - horizWidth) / 2; /* Now it's X offset */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7309 for (i = 0; i < numButtons; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7310 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7311 /* get end of this button. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7312 for ( pend = pstart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7313 *pend && (*pend != DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7314 pend++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7315 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7316
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7317 if (*pend)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7318 *pend = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7319
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7320 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7321 * old NOTE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7322 * setting the BS_DEFPUSHBUTTON style doesn't work because Windows sets
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7323 * the focus to the first tab-able button and in so doing makes that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7324 * the default!! Grrr. Workaround: Make the default button the only
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7325 * one with WS_TABSTOP style. Means user can't tab between buttons, but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7326 * he/she can use arrow keys.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7327 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7328 * new NOTE: BS_DEFPUSHBUTTON is required to be able to select the
1213
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
7329 * right button when hitting <Enter>. E.g., for the ":confirm quit"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7330 * dialog. Also needed for when the textfield is the default control.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7331 * It appears to work now (perhaps not on Win95?).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7332 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7333 if (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7334 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7335 p = add_dialog_element(p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7336 (i == dfltbutton
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7337 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7338 PixelToDialogX(DLG_VERT_PADDING_X),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7339 PixelToDialogY(buttonYpos /* TBK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7340 + 2 * fontHeight * i),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7341 PixelToDialogX(dlgwidth - 2 * DLG_VERT_PADDING_X),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7342 (WORD)(PixelToDialogY(2 * fontHeight) - 1),
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7343 (WORD)(IDCANCEL + 1 + i), (WORD)0x0080, (char *)pstart);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7344 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7345 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7346 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7347 p = add_dialog_element(p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7348 (i == dfltbutton
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7349 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7350 PixelToDialogX(horizWidth + buttonPositions[i]),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7351 PixelToDialogY(buttonYpos), /* TBK */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7352 PixelToDialogX(buttonWidths[i]),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7353 (WORD)(PixelToDialogY(2 * fontHeight) - 1),
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7354 (WORD)(IDCANCEL + 1 + i), (WORD)0x0080, (char *)pstart);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7355 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7356 pstart = pend + 1; /*next button*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7357 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7358 *pnumitems += numButtons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7359
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7360 /* Vim icon */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7361 p = add_dialog_element(p, SS_ICON,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7362 PixelToDialogX(dlgPaddingX),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7363 PixelToDialogY(dlgPaddingY),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7364 PixelToDialogX(DLG_ICON_WIDTH),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7365 PixelToDialogY(DLG_ICON_HEIGHT),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7366 DLG_NONBUTTON_CONTROL + 0, (WORD)0x0082,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7367 dlg_icons[type]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7368
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7369 /* Dialog message */
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7370 p = add_dialog_element(p, ES_LEFT|scroll_flag|ES_MULTILINE|ES_READONLY,
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7371 PixelToDialogX(2 * dlgPaddingX + DLG_ICON_WIDTH),
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7372 PixelToDialogY(dlgPaddingY),
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7373 (WORD)(PixelToDialogX(messageWidth) + 1),
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7374 PixelToDialogY(msgheight),
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7375 DLG_NONBUTTON_CONTROL + 1, (WORD)0x0081, (char *)message);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7376
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7377 /* Edit box */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7378 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7379 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7380 p = add_dialog_element(p, ES_LEFT|ES_AUTOHSCROLL|WS_TABSTOP|WS_BORDER,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7381 PixelToDialogX(2 * dlgPaddingX),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7382 PixelToDialogY(2 * dlgPaddingY + msgheight),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7383 PixelToDialogX(dlgwidth - 4 * dlgPaddingX),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7384 PixelToDialogY(fontHeight + dlgPaddingY),
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7385 DLG_NONBUTTON_CONTROL + 2, (WORD)0x0081, (char *)textfield);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7386 *pnumitems += 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7387 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7388
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7389 *pnumitems += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7390
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7391 SelectFont(hdc, oldFont);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7392 DeleteObject(font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7393 ReleaseDC(hwnd, hdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7394
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7395 /* Let the dialog_callback() function know which button to make default
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7396 * If we have an edit box, make that the default. We also need to tell
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7397 * dialog_callback() if this dialog contains an edit box or not. We do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7398 * this by setting s_textfield if it does.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7399 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7400 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7401 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7402 dialog_default_button = DLG_NONBUTTON_CONTROL + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7403 s_textfield = textfield;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7404 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7405 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7406 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7407 dialog_default_button = IDCANCEL + 1 + dfltbutton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7408 s_textfield = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7409 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7410
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7411 /* show the dialog box modally and get a return value */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7412 nchar = (int)DialogBoxIndirect(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7413 s_hinst,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7414 (LPDLGTEMPLATE)pdlgtemplate,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7415 s_hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7416 (DLGPROC)dialog_callback);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7417
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7418 LocalFree(LocalHandle(pdlgtemplate));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7419 vim_free(tbuffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7420 vim_free(buttonWidths);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7421 vim_free(buttonPositions);
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7422 vim_free(ga.ga_data);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7423
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7424 /* Focus back to our window (for when MDI is used). */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7425 (void)SetFocus(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7426
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7427 return nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7428 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7429
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7430 #endif /* FEAT_GUI_DIALOG */
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7431
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7432 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7433 * Put a simple element (basic class) onto a dialog template in memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7434 * return a pointer to where the next item should be added.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7435 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7436 * parameters:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7437 * lStyle = additional style flags
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7438 * (be careful, NT3.51 & Win32s will ignore the new ones)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7439 * x,y = x & y positions IN DIALOG UNITS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7440 * w,h = width and height IN DIALOG UNITS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7441 * Id = ID used in messages
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7442 * clss = class ID, e.g 0x0080 for a button, 0x0082 for a static
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7443 * caption = usually text or resource name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7444 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7445 * TODO: use the length information noted here to enable the dialog creation
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7446 * routines to work out more exactly how much memory they need to alloc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7447 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7448 static PWORD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7449 add_dialog_element(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7450 PWORD p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7451 DWORD lStyle,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7452 WORD x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7453 WORD y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7454 WORD w,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7455 WORD h,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7456 WORD Id,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7457 WORD clss,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7458 const char *caption)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7459 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7460 int nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7461
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7462 p = lpwAlign(p); /* Align to dword boundary*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7463 lStyle = lStyle | WS_VISIBLE | WS_CHILD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7464 *p++ = LOWORD(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7465 *p++ = HIWORD(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7466 *p++ = 0; // LOWORD (lExtendedStyle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7467 *p++ = 0; // HIWORD (lExtendedStyle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7468 *p++ = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7469 *p++ = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7470 *p++ = w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7471 *p++ = h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7472 *p++ = Id; //9 or 10 words in all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7473
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7474 *p++ = (WORD)0xffff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7475 *p++ = clss; //2 more here
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7476
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7477 nchar = nCopyAnsiToWideChar(p, (LPSTR)caption); //strlen(caption)+1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7478 p += nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7479
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7480 *p++ = 0; // advance pointer over nExtraStuff WORD - 2 more
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7481
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7482 return p; //total = 15+ (strlen(caption)) words
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7483 // = 30 + 2(strlen(caption) bytes reqd
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7484 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7485
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7486
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7487 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7488 * Helper routine. Take an input pointer, return closest pointer that is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7489 * aligned on a DWORD (4 byte) boundary. Taken from the Win32SDK samples.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7490 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7491 static LPWORD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7492 lpwAlign(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7493 LPWORD lpIn)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7494 {
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7495 long_u ul;
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7496
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7497 ul = (long_u)lpIn;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7498 ul += 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7499 ul >>= 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7500 ul <<= 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7501 return (LPWORD)ul;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7502 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7503
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7504 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7505 * Helper routine. Takes second parameter as Ansi string, copies it to first
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7506 * parameter as wide character (16-bits / char) string, and returns integer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7507 * number of wide characters (words) in string (including the trailing wide
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7508 * char NULL). Partly taken from the Win32SDK samples.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7509 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7510 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7511 nCopyAnsiToWideChar(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7512 LPWORD lpWCStr,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7513 LPSTR lpAnsiIn)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7514 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7515 int nChar = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7516 #ifdef FEAT_MBYTE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7517 int len = lstrlen(lpAnsiIn) + 1; /* include NUL character */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7518 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7519 WCHAR *wn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7520
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7521 if (enc_codepage == 0 && (int)GetACP() != enc_codepage)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7522 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7523 /* Not a codepage, use our own conversion function. */
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7524 wn = enc_to_utf16((char_u *)lpAnsiIn, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7525 if (wn != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7526 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7527 wcscpy(lpWCStr, wn);
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 824
diff changeset
7528 nChar = (int)wcslen(wn) + 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7529 vim_free(wn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7530 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7531 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7532 if (nChar == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7533 /* Use Win32 conversion function. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7534 nChar = MultiByteToWideChar(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7535 enc_codepage > 0 ? enc_codepage : CP_ACP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7536 MB_PRECOMPOSED,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7537 lpAnsiIn, len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7538 lpWCStr, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7539 for (i = 0; i < nChar; ++i)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7540 if (lpWCStr[i] == (WORD)'\t') /* replace tabs with spaces */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7541 lpWCStr[i] = (WORD)' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7542 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7543 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7544 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7545 if (*lpAnsiIn == '\t')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7546 *lpWCStr++ = (WORD)' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7547 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7548 *lpWCStr++ = (WORD)*lpAnsiIn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7549 nChar++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7550 } while (*lpAnsiIn++);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7551 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7552
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7553 return nChar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7554 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7555
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7556
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7557 #ifdef FEAT_TEAROFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7558 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7559 * The callback function for all the modeless dialogs that make up the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7560 * "tearoff menus" Very simple - forward button presses (to fool Vim into
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7561 * thinking its menus have been clicked), and go away when closed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7562 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7563 static LRESULT CALLBACK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7564 tearoff_callback(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7565 HWND hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7566 UINT message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7567 WPARAM wParam,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7568 LPARAM lParam)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7569 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7570 if (message == WM_INITDIALOG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7571 return (TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7573 /* May show the mouse pointer again. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7574 HandleMouseHide(message, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7575
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7576 if (message == WM_COMMAND)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7577 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7578 if ((WORD)(LOWORD(wParam)) & 0x8000)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7579 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7580 POINT mp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7581 RECT rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7582
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7583 if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7584 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7585 (void)TrackPopupMenu(
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7586 (HMENU)(long_u)(LOWORD(wParam) ^ 0x8000),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7587 TPM_LEFTALIGN | TPM_LEFTBUTTON,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7588 (int)rect.right - 8,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7589 (int)mp.y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7590 (int)0, /*reserved param*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7591 s_hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7592 NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7593 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7594 * NOTE: The pop-up menu can eat the mouse up event.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7595 * We deal with this in normal.c.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7596 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7597 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7598 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7599 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7600 /* Pass on messages to the main Vim window */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7601 PostMessage(s_hwnd, WM_COMMAND, LOWORD(wParam), 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7602 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7603 * Give main window the focus back: this is so after
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7604 * choosing a tearoff button you can start typing again
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7605 * straight away.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7606 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7607 (void)SetFocus(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7608 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7609 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7610 if ((message == WM_SYSCOMMAND) && (wParam == SC_CLOSE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7611 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7612 DestroyWindow(hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7613 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7614 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7615
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7616 /* When moved around, give main window the focus back. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7617 if (message == WM_EXITSIZEMOVE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7618 (void)SetActiveWindow(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7619
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7620 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7621 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7622 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7623
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7624
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7625 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7626 * Decide whether to use the "new look" (small, non-bold font) or the "old
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7627 * look" (big, clanky font) for dialogs, and work out a few values for use
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7628 * later accordingly.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7629 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7630 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7631 get_dialog_font_metrics(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7632 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7633 HDC hdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7634 HFONT hfontTools = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7635 DWORD dlgFontSize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7636 SIZE size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7637 #ifdef USE_SYSMENU_FONT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7638 LOGFONT lfSysmenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7639 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7640
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7641 s_usenewlook = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7642
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7643 #ifdef USE_SYSMENU_FONT
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7644 if (gui_w32_get_menu_font(&lfSysmenu) == OK)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7645 hfontTools = CreateFontIndirect(&lfSysmenu);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7646 else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7647 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7648 hfontTools = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7649 0, 0, 0, 0, VARIABLE_PITCH , DLG_FONT_NAME);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7650
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7651 if (hfontTools)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7652 {
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7653 hdc = GetDC(s_hwnd);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7654 SelectObject(hdc, hfontTools);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7655 /*
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7656 * GetTextMetrics() doesn't return the right value in
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7657 * tmAveCharWidth, so we have to figure out the dialog base units
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7658 * ourselves.
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7659 */
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7660 GetTextExtentPoint(hdc,
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7661 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7662 52, &size);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7663 ReleaseDC(s_hwnd, hdc);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7664
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7665 s_dlgfntwidth = (WORD)((size.cx / 26 + 1) / 2);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7666 s_dlgfntheight = (WORD)size.cy;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7667 s_usenewlook = TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7668 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7669
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7670 if (!s_usenewlook)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7671 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7672 dlgFontSize = GetDialogBaseUnits(); /* fall back to big old system*/
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7673 s_dlgfntwidth = LOWORD(dlgFontSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7674 s_dlgfntheight = HIWORD(dlgFontSize);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7675 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7676 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7677
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7678 #if defined(FEAT_MENU) && defined(FEAT_TEAROFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7679 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7680 * Create a pseudo-"tearoff menu" based on the child
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7681 * items of a given menu pointer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7682 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7683 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7684 gui_mch_tearoff(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7685 char_u *title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7686 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7687 int initX,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7688 int initY)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7689 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7690 WORD *p, *pdlgtemplate, *pnumitems, *ptrueheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7691 int template_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7692 int nchar, textWidth, submenuWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7693 DWORD lStyle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7694 DWORD lExtendedStyle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7695 WORD dlgwidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7696 WORD menuID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7697 vimmenu_T *pmenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7698 vimmenu_T *the_menu = menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7699 HWND hwnd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7700 HDC hdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7701 HFONT font, oldFont;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7702 int col, spaceWidth, len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7703 int columnWidths[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7704 char_u *label, *text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7705 int acLen = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7706 int nameLen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7707 int padding0, padding1, padding2 = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7708 int sepPadding=0;
87
014ba200db86 updated for version 7.0035
vimboss
parents: 39
diff changeset
7709 int x;
014ba200db86 updated for version 7.0035
vimboss
parents: 39
diff changeset
7710 int y;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7711 #ifdef USE_SYSMENU_FONT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7712 LOGFONT lfSysmenu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7713 int use_lfSysmenu = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7714 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7715
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7716 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7717 * If this menu is already torn off, move it to the mouse position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7718 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7719 if (IsWindow(menu->tearoff_handle))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7720 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7721 POINT mp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7722 if (GetCursorPos((LPPOINT)&mp))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7723 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7724 SetWindowPos(menu->tearoff_handle, NULL, mp.x, mp.y, 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7725 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7726 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7727 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7728 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7729
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7730 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7731 * Create a new tearoff.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7732 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7733 if (*title == MNU_HIDDEN_CHAR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7734 title++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7735
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7736 /* Allocate memory to store the dialog template. It's made bigger when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7737 * needed. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7738 template_len = DLG_ALLOC_SIZE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7739 pdlgtemplate = p = (WORD *)LocalAlloc(LPTR, template_len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7740 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7741 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7742
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7743 hwnd = GetDesktopWindow();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7744 hdc = GetWindowDC(hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7745 #ifdef USE_SYSMENU_FONT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7746 if (gui_w32_get_menu_font(&lfSysmenu) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7747 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7748 font = CreateFontIndirect(&lfSysmenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7749 use_lfSysmenu = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7750 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7751 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7752 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7753 font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7754 VARIABLE_PITCH , DLG_FONT_NAME);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7755 if (s_usenewlook)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7756 oldFont = SelectFont(hdc, font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7757 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7758 oldFont = SelectFont(hdc, GetStockObject(SYSTEM_FONT));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7759
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7760 /* Calculate width of a single space. Used for padding columns to the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7761 * right width. */
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7762 spaceWidth = GetTextWidth(hdc, (char_u *)" ", 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7763
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7764 /* Figure out max width of the text column, the accelerator column and the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7765 * optional submenu column. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7766 submenuWidth = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7767 for (col = 0; col < 2; col++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7768 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7769 columnWidths[col] = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7770 for (pmenu = menu->children; pmenu != NULL; pmenu = pmenu->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7771 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7772 /* Use "dname" here to compute the width of the visible text. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7773 text = (col == 0) ? pmenu->dname : pmenu->actext;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7774 if (text != NULL && *text != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7775 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7776 textWidth = GetTextWidthEnc(hdc, text, (int)STRLEN(text));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7777 if (textWidth > columnWidths[col])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7778 columnWidths[col] = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7779 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7780 if (pmenu->children != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7781 submenuWidth = TEAROFF_COLUMN_PADDING * spaceWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7782 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7783 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7784 if (columnWidths[1] == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7785 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7786 /* no accelerators */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7787 if (submenuWidth != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7788 columnWidths[0] += submenuWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7789 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7790 columnWidths[0] += spaceWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7791 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7792 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7793 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7794 /* there is an accelerator column */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7795 columnWidths[0] += TEAROFF_COLUMN_PADDING * spaceWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7796 columnWidths[1] += submenuWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7797 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7798
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7799 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7800 * Now find the total width of our 'menu'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7801 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7802 textWidth = columnWidths[0] + columnWidths[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7803 if (submenuWidth != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7804 {
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7805 submenuWidth = GetTextWidth(hdc, (char_u *)TEAROFF_SUBMENU_LABEL,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7806 (int)STRLEN(TEAROFF_SUBMENU_LABEL));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7807 textWidth += submenuWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7808 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7809 dlgwidth = GetTextWidthEnc(hdc, title, (int)STRLEN(title));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7810 if (textWidth > dlgwidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7811 dlgwidth = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7812 dlgwidth += 2 * TEAROFF_PADDING_X + TEAROFF_BUTTON_PAD_X;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7813
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7814 /* start to fill in the dlgtemplate information. addressing by WORDs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7815 if (s_usenewlook)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7816 lStyle = DS_MODALFRAME | WS_CAPTION| WS_SYSMENU |DS_SETFONT| WS_VISIBLE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7817 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7818 lStyle = DS_MODALFRAME | WS_CAPTION| WS_SYSMENU | WS_VISIBLE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7819
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7820 lExtendedStyle = WS_EX_TOOLWINDOW|WS_EX_STATICEDGE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7821 *p++ = LOWORD(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7822 *p++ = HIWORD(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7823 *p++ = LOWORD(lExtendedStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7824 *p++ = HIWORD(lExtendedStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7825 pnumitems = p; /* save where the number of items must be stored */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7826 *p++ = 0; // NumberOfItems(will change later)
87
014ba200db86 updated for version 7.0035
vimboss
parents: 39
diff changeset
7827 gui_mch_getmouse(&x, &y);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7828 if (initX == 0xffffL)
87
014ba200db86 updated for version 7.0035
vimboss
parents: 39
diff changeset
7829 *p++ = PixelToDialogX(x); // x
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7830 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7831 *p++ = PixelToDialogX(initX); // x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7832 if (initY == 0xffffL)
87
014ba200db86 updated for version 7.0035
vimboss
parents: 39
diff changeset
7833 *p++ = PixelToDialogY(y); // y
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7834 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7835 *p++ = PixelToDialogY(initY); // y
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7836 *p++ = PixelToDialogX(dlgwidth); // cx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7837 ptrueheight = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7838 *p++ = 0; // dialog height: changed later anyway
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7839 *p++ = 0; // Menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7840 *p++ = 0; // Class
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7841
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7842 /* copy the title of the dialog */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7843 nchar = nCopyAnsiToWideChar(p, ((*title)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7844 ? (LPSTR)title
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7845 : (LPSTR)("Vim "VIM_VERSION_MEDIUM)));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7846 p += nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7847
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7848 if (s_usenewlook)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7849 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7850 /* do the font, since DS_3DLOOK doesn't work properly */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7851 #ifdef USE_SYSMENU_FONT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7852 if (use_lfSysmenu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7853 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7854 /* point size */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7855 *p++ = -MulDiv(lfSysmenu.lfHeight, 72,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7856 GetDeviceCaps(hdc, LOGPIXELSY));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7857 nchar = nCopyAnsiToWideChar(p, TEXT(lfSysmenu.lfFaceName));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7858 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7859 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7860 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7861 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7862 *p++ = DLG_FONT_POINT_SIZE; // point size
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7863 nchar = nCopyAnsiToWideChar (p, TEXT(DLG_FONT_NAME));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7864 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7865 p += nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7866 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7867
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7868 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7869 * Loop over all the items in the menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7870 * But skip over the tearbar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7871 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7872 if (STRCMP(menu->children->name, TEAR_STRING) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7873 menu = menu->children->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7874 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7875 menu = menu->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7876 for ( ; menu != NULL; menu = menu->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7877 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7878 if (menu->modes == 0) /* this menu has just been deleted */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7879 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7880 if (menu_is_separator(menu->dname))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7881 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7882 sepPadding += 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7883 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7884 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7885
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7886 /* Check if there still is plenty of room in the template. Make it
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7887 * larger when needed. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7888 if (((char *)p - (char *)pdlgtemplate) + 1000 > template_len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7889 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7890 WORD *newp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7891
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7892 newp = (WORD *)LocalAlloc(LPTR, template_len + 4096);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7893 if (newp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7894 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7895 template_len += 4096;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7896 mch_memmove(newp, pdlgtemplate,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7897 (char *)p - (char *)pdlgtemplate);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7898 p = newp + (p - pdlgtemplate);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7899 pnumitems = newp + (pnumitems - pdlgtemplate);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7900 ptrueheight = newp + (ptrueheight - pdlgtemplate);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7901 LocalFree(LocalHandle(pdlgtemplate));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7902 pdlgtemplate = newp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7903 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7904 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7905
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7906 /* Figure out minimal length of this menu label. Use "name" for the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7907 * actual text, "dname" for estimating the displayed size. "name"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7908 * has "&a" for mnemonic and includes the accelerator. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7909 len = nameLen = (int)STRLEN(menu->name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7910 padding0 = (columnWidths[0] - GetTextWidthEnc(hdc, menu->dname,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7911 (int)STRLEN(menu->dname))) / spaceWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7912 len += padding0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7913
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7914 if (menu->actext != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7915 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7916 acLen = (int)STRLEN(menu->actext);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7917 len += acLen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7918 textWidth = GetTextWidthEnc(hdc, menu->actext, acLen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7919 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7920 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7921 textWidth = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7922 padding1 = (columnWidths[1] - textWidth) / spaceWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7923 len += padding1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7924
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7925 if (menu->children == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7926 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7927 padding2 = submenuWidth / spaceWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7928 len += padding2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7929 menuID = (WORD)(menu->id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7930 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7931 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7932 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7933 len += (int)STRLEN(TEAROFF_SUBMENU_LABEL);
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7934 menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7935 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7936
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7937 /* Allocate menu label and fill it in */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7938 text = label = alloc((unsigned)len + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7939 if (label == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7940 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7941
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 401
diff changeset
7942 vim_strncpy(text, menu->name, nameLen);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7943 text = vim_strchr(text, TAB); /* stop at TAB before actext */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7944 if (text == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7945 text = label + nameLen; /* no actext, use whole name */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7946 while (padding0-- > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7947 *text++ = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7948 if (menu->actext != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7949 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7950 STRNCPY(text, menu->actext, acLen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7951 text += acLen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7952 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7953 while (padding1-- > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7954 *text++ = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7955 if (menu->children != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7956 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7957 STRCPY(text, TEAROFF_SUBMENU_LABEL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7958 text += STRLEN(TEAROFF_SUBMENU_LABEL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7959 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7960 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7961 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7962 while (padding2-- > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7963 *text++ = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7964 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7965 *text = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7966
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7967 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7968 * BS_LEFT will just be ignored on Win32s/NT3.5x - on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7969 * W95/NT4 it makes the tear-off look more like a menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7970 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7971 p = add_dialog_element(p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7972 BS_PUSHBUTTON|BS_LEFT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7973 (WORD)PixelToDialogX(TEAROFF_PADDING_X),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7974 (WORD)(sepPadding + 1 + 13 * (*pnumitems)),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7975 (WORD)PixelToDialogX(dlgwidth - 2 * TEAROFF_PADDING_X),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7976 (WORD)12,
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7977 menuID, (WORD)0x0080, (char *)label);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7978 vim_free(label);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7979 (*pnumitems)++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7980 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7981
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7982 *ptrueheight = (WORD)(sepPadding + 1 + 13 * (*pnumitems));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7983
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7984
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7985 /* show modelessly */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7986 the_menu->tearoff_handle = CreateDialogIndirect(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7987 s_hinst,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7988 (LPDLGTEMPLATE)pdlgtemplate,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7989 s_hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7990 (DLGPROC)tearoff_callback);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7991
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7992 LocalFree(LocalHandle(pdlgtemplate));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7993 SelectFont(hdc, oldFont);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7994 DeleteObject(font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7995 ReleaseDC(hwnd, hdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7996
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7997 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7998 * Reassert ourselves as the active window. This is so that after creating
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7999 * a tearoff, the user doesn't have to click with the mouse just to start
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8000 * typing again!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8001 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8002 (void)SetActiveWindow(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8003
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8004 /* make sure the right buttons are enabled */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8005 force_menu_update = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8006 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8007 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8008
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8009 #if defined(FEAT_TOOLBAR) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8010 #include "gui_w32_rc.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8011
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8012 /* This not defined in older SDKs */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8013 # ifndef TBSTYLE_FLAT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8014 # define TBSTYLE_FLAT 0x0800
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8015 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8016
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8017 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8018 * Create the toolbar, initially unpopulated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8019 * (just like the menu, there are no defaults, it's all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8020 * set up through menu.vim)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8021 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8022 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8023 initialise_toolbar(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8024 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8025 InitCommonControls();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8026 s_toolbarhwnd = CreateToolbarEx(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8027 s_hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8028 WS_CHILD | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8029 4000, //any old big number
1213
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
8030 31, //number of images in initial bitmap
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8031 s_hinst,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8032 IDR_TOOLBAR1, // id of initial bitmap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8033 NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8034 0, // initial number of buttons
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8035 TOOLBAR_BUTTON_WIDTH, //api guide is wrong!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8036 TOOLBAR_BUTTON_HEIGHT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8037 TOOLBAR_BUTTON_WIDTH,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8038 TOOLBAR_BUTTON_HEIGHT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8039 sizeof(TBBUTTON)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8040 );
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8041 s_toolbar_wndproc = SubclassWindow(s_toolbarhwnd, toolbar_wndproc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8042
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8043 gui_mch_show_toolbar(vim_strchr(p_go, GO_TOOLBAR) != NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8044 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8045
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8046 static LRESULT CALLBACK
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8047 toolbar_wndproc(
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8048 HWND hwnd,
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8049 UINT uMsg,
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8050 WPARAM wParam,
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8051 LPARAM lParam)
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8052 {
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8053 HandleMouseHide(uMsg, lParam);
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8054 return CallWindowProc(s_toolbar_wndproc, hwnd, uMsg, wParam, lParam);
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8055 }
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8056
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8057 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8058 get_toolbar_bitmap(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8059 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8060 int i = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8061
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8062 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8063 * Check user bitmaps first, unless builtin is specified.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8064 */
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
8065 if (!menu->icon_builtin)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8066 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8067 char_u fname[MAXPATHL];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8068 HANDLE hbitmap = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8069
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8070 if (menu->iconfile != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8071 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8072 gui_find_iconfile(menu->iconfile, fname, "bmp");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8073 hbitmap = LoadImage(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8074 NULL,
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8075 (LPCSTR)fname,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8076 IMAGE_BITMAP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8077 TOOLBAR_BUTTON_WIDTH,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8078 TOOLBAR_BUTTON_HEIGHT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8079 LR_LOADFROMFILE |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8080 LR_LOADMAP3DCOLORS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8081 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8082 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8083
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8084 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8085 * If the LoadImage call failed, or the "icon=" file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8086 * didn't exist or wasn't specified, try the menu name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8087 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8088 if (hbitmap == NULL
5020
5eff37e92f03 updated for version 7.3.1254
Bram Moolenaar <bram@vim.org>
parents: 5016
diff changeset
8089 && (gui_find_bitmap(
5eff37e92f03 updated for version 7.3.1254
Bram Moolenaar <bram@vim.org>
parents: 5016
diff changeset
8090 #ifdef FEAT_MULTI_LANG
5eff37e92f03 updated for version 7.3.1254
Bram Moolenaar <bram@vim.org>
parents: 5016
diff changeset
8091 menu->en_dname != NULL ? menu->en_dname :
5eff37e92f03 updated for version 7.3.1254
Bram Moolenaar <bram@vim.org>
parents: 5016
diff changeset
8092 #endif
5eff37e92f03 updated for version 7.3.1254
Bram Moolenaar <bram@vim.org>
parents: 5016
diff changeset
8093 menu->dname, fname, "bmp") == OK))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8094 hbitmap = LoadImage(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8095 NULL,
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8096 (LPCSTR)fname,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8097 IMAGE_BITMAP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8098 TOOLBAR_BUTTON_WIDTH,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8099 TOOLBAR_BUTTON_HEIGHT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8100 LR_LOADFROMFILE |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8101 LR_LOADMAP3DCOLORS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8102 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8103
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8104 if (hbitmap != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8105 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8106 TBADDBITMAP tbAddBitmap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8108 tbAddBitmap.hInst = NULL;
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
8109 tbAddBitmap.nID = (long_u)hbitmap;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8111 i = (int)SendMessage(s_toolbarhwnd, TB_ADDBITMAP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8112 (WPARAM)1, (LPARAM)&tbAddBitmap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8113 /* i will be set to -1 if it fails */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8114 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8115 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8116 if (i == -1 && menu->iconidx >= 0 && menu->iconidx < TOOLBAR_BITMAP_COUNT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8117 i = menu->iconidx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8119 return i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8120 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8121 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8122
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
8123 #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
8124 static void
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
8125 initialise_tabline(void)
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
8126 {
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
8127 InitCommonControls();
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
8128
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
8129 s_tabhwnd = CreateWindow(WC_TABCONTROL, "Vim tabline",
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
8130 WS_CHILD|TCS_FOCUSNEVER|TCS_TOOLTIPS,
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
8131 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
8132 CW_USEDEFAULT, s_hwnd, NULL, s_hinst, NULL);
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8133 s_tabline_wndproc = SubclassWindow(s_tabhwnd, tabline_wndproc);
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
8134
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
8135 gui.tabline_height = TABLINE_HEIGHT;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
8136
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
8137 # ifdef USE_SYSMENU_FONT
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
8138 set_tabline_font();
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
8139 # endif
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
8140 }
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8141
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8142 static LRESULT CALLBACK
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8143 tabline_wndproc(
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8144 HWND hwnd,
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8145 UINT uMsg,
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8146 WPARAM wParam,
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8147 LPARAM lParam)
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8148 {
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8149 HandleMouseHide(uMsg, lParam);
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8150 return CallWindowProc(s_tabline_wndproc, hwnd, uMsg, wParam, lParam);
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8151 }
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
8152 #endif
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
8153
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8154 #if defined(FEAT_OLE) || defined(FEAT_EVAL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8155 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8156 * Make the GUI window come to the foreground.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8157 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8158 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8159 gui_mch_set_foreground(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8160 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8161 if (IsIconic(s_hwnd))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8162 SendMessage(s_hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8163 SetForegroundWindow(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8164 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8165 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8167 #if defined(FEAT_MBYTE_IME) && defined(DYNAMIC_IME)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8168 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8169 dyn_imm_load(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8170 {
2612
fa5dee44df3f updated for version 7.3.034
Bram Moolenaar <bram@vim.org>
parents: 2520
diff changeset
8171 hLibImm = vimLoadLib("imm32.dll");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8172 if (hLibImm == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8173 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8174
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8175 pImmGetCompositionStringA
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8176 = (void *)GetProcAddress(hLibImm, "ImmGetCompositionStringA");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8177 pImmGetCompositionStringW
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8178 = (void *)GetProcAddress(hLibImm, "ImmGetCompositionStringW");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8179 pImmGetContext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8180 = (void *)GetProcAddress(hLibImm, "ImmGetContext");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8181 pImmAssociateContext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8182 = (void *)GetProcAddress(hLibImm, "ImmAssociateContext");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8183 pImmReleaseContext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8184 = (void *)GetProcAddress(hLibImm, "ImmReleaseContext");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8185 pImmGetOpenStatus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8186 = (void *)GetProcAddress(hLibImm, "ImmGetOpenStatus");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8187 pImmSetOpenStatus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8188 = (void *)GetProcAddress(hLibImm, "ImmSetOpenStatus");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8189 pImmGetCompositionFont
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8190 = (void *)GetProcAddress(hLibImm, "ImmGetCompositionFontA");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8191 pImmSetCompositionFont
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8192 = (void *)GetProcAddress(hLibImm, "ImmSetCompositionFontA");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8193 pImmSetCompositionWindow
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8194 = (void *)GetProcAddress(hLibImm, "ImmSetCompositionWindow");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8195 pImmGetConversionStatus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8196 = (void *)GetProcAddress(hLibImm, "ImmGetConversionStatus");
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
8197 pImmSetConversionStatus
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
8198 = (void *)GetProcAddress(hLibImm, "ImmSetConversionStatus");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8199
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8200 if ( pImmGetCompositionStringA == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8201 || pImmGetCompositionStringW == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8202 || pImmGetContext == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8203 || pImmAssociateContext == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8204 || pImmReleaseContext == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8205 || pImmGetOpenStatus == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8206 || pImmSetOpenStatus == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8207 || pImmGetCompositionFont == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8208 || pImmSetCompositionFont == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8209 || pImmSetCompositionWindow == NULL
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
8210 || pImmGetConversionStatus == NULL
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
8211 || pImmSetConversionStatus == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8212 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8213 FreeLibrary(hLibImm);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8214 hLibImm = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8215 pImmGetContext = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8216 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8217 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8218
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8219 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8220 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8221
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8222 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8223
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8224 #if defined(FEAT_SIGN_ICONS) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8225
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8226 # ifdef FEAT_XPM_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8227 # define IMAGE_XPM 100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8228 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8229
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8230 typedef struct _signicon_t
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8231 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8232 HANDLE hImage;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8233 UINT uType;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8234 #ifdef FEAT_XPM_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8235 HANDLE hShape; /* Mask bitmap handle */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8236 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8237 } signicon_t;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8239 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8240 gui_mch_drawsign(int row, int col, int typenr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8241 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8242 signicon_t *sign;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8243 int x, y, w, h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8244
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8245 if (!gui.in_use || (sign = (signicon_t *)sign_get_image(typenr)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8246 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8247
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8248 x = TEXT_X(col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8249 y = TEXT_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8250 w = gui.char_width * 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8251 h = gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8252 switch (sign->uType)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8253 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8254 case IMAGE_BITMAP:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8255 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8256 HDC hdcMem;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8257 HBITMAP hbmpOld;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8258
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8259 hdcMem = CreateCompatibleDC(s_hdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8260 hbmpOld = (HBITMAP)SelectObject(hdcMem, sign->hImage);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8261 BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCCOPY);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8262 SelectObject(hdcMem, hbmpOld);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8263 DeleteDC(hdcMem);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8264 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8265 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8266 case IMAGE_ICON:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8267 case IMAGE_CURSOR:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8268 DrawIconEx(s_hdc, x, y, (HICON)sign->hImage, w, h, 0, NULL, DI_NORMAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8269 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8270 #ifdef FEAT_XPM_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8271 case IMAGE_XPM:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8272 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8273 HDC hdcMem;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8274 HBITMAP hbmpOld;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8275
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8276 hdcMem = CreateCompatibleDC(s_hdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8277 hbmpOld = (HBITMAP)SelectObject(hdcMem, sign->hShape);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8278 /* Make hole */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8279 BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCAND);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8280
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8281 SelectObject(hdcMem, sign->hImage);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8282 /* Paint sign */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8283 BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCPAINT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8284 SelectObject(hdcMem, hbmpOld);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8285 DeleteDC(hdcMem);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8286 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8287 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8288 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8289 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8290 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8291
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8292 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8293 close_signicon_image(signicon_t *sign)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8294 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8295 if (sign)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8296 switch (sign->uType)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8297 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8298 case IMAGE_BITMAP:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8299 DeleteObject((HGDIOBJ)sign->hImage);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8300 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8301 case IMAGE_CURSOR:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8302 DestroyCursor((HCURSOR)sign->hImage);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8303 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8304 case IMAGE_ICON:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8305 DestroyIcon((HICON)sign->hImage);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8306 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8307 #ifdef FEAT_XPM_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8308 case IMAGE_XPM:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8309 DeleteObject((HBITMAP)sign->hImage);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8310 DeleteObject((HBITMAP)sign->hShape);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8311 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8312 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8313 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8314 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8316 void *
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8317 gui_mch_register_sign(char_u *signfile)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8318 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8319 signicon_t sign, *psign;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8320 char_u *ext;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8321
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8322 sign.hImage = NULL;
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 4238
diff changeset
8323 ext = signfile + STRLEN(signfile) - 4; /* get extension */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8324 if (ext > signfile)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8325 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8326 int do_load = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8327
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8328 if (!STRICMP(ext, ".bmp"))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8329 sign.uType = IMAGE_BITMAP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8330 else if (!STRICMP(ext, ".ico"))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8331 sign.uType = IMAGE_ICON;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8332 else if (!STRICMP(ext, ".cur") || !STRICMP(ext, ".ani"))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8333 sign.uType = IMAGE_CURSOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8334 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8335 do_load = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8336
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8337 if (do_load)
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8338 sign.hImage = (HANDLE)LoadImage(NULL, (LPCSTR)signfile, sign.uType,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8339 gui.char_width * 2, gui.char_height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8340 LR_LOADFROMFILE | LR_CREATEDIBSECTION);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8341 #ifdef FEAT_XPM_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8342 if (!STRICMP(ext, ".xpm"))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8343 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8344 sign.uType = IMAGE_XPM;
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8345 LoadXpmImage((char *)signfile, (HBITMAP *)&sign.hImage,
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8346 (HBITMAP *)&sign.hShape);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8347 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8348 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8349 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8350
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8351 psign = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8352 if (sign.hImage && (psign = (signicon_t *)alloc(sizeof(signicon_t)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8353 != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8354 *psign = sign;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8355
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8356 if (!psign)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8357 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8358 if (sign.hImage)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8359 close_signicon_image(&sign);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8360 EMSG(_(e_signdata));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8361 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8362 return (void *)psign;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8363
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8364 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8365
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8366 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8367 gui_mch_destroy_sign(void *sign)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8368 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8369 if (sign)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8370 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8371 close_signicon_image((signicon_t *)sign);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8372 vim_free(sign);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8373 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8374 }
293
f811be6fa9b5 updated for version 7.0077
vimboss
parents: 236
diff changeset
8375 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8376
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8377 #if defined(FEAT_BEVAL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8378
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8379 /* BALLOON-EVAL IMPLEMENTATION FOR WINDOWS.
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 87
diff changeset
8380 * Added by Sergey Khorev <sergey.khorev@gmail.com>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8381 *
189
504c627f7474 updated for version 7.0057
vimboss
parents: 179
diff changeset
8382 * The only reused thing is gui_beval.h and get_beval_info()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8383 * from gui_beval.c (note it uses x and y of the BalloonEval struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8384 * to get current mouse position).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8385 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8386 * Trying to use as more Windows services as possible, and as less
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8387 * IE version as possible :)).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8388 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8389 * 1) Don't create ToolTip in gui_mch_create_beval_area, only initialize
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8390 * BalloonEval struct.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8391 * 2) Enable/Disable simply create/kill BalloonEval Timer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8392 * 3) When there was enough inactivity, timer procedure posts
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8393 * async request to debugger
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8394 * 4) gui_mch_post_balloon (invoked from netbeans.c) creates tooltip control
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8395 * and performs some actions to show it ASAP
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1489
diff changeset
8396 * 5) WM_NOTIFY:TTN_POP destroys created tooltip
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8397 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8398
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8399 /*
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8400 * determine whether installed Common Controls support multiline tooltips
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8401 * (i.e. their version is >= 4.70
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8402 */
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8403 int
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8404 multiline_balloon_available(void)
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8405 {
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8406 HINSTANCE hDll;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8407 static char comctl_dll[] = "comctl32.dll";
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8408 static int multiline_tip = MAYBE;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8409
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8410 if (multiline_tip != MAYBE)
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8411 return multiline_tip;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8412
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8413 hDll = GetModuleHandle(comctl_dll);
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8414 if (hDll != NULL)
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8415 {
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8416 DLLGETVERSIONPROC pGetVer;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8417 pGetVer = (DLLGETVERSIONPROC)GetProcAddress(hDll, "DllGetVersion");
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8418
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8419 if (pGetVer != NULL)
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8420 {
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8421 DLLVERSIONINFO dvi;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8422 HRESULT hr;
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8423
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8424 ZeroMemory(&dvi, sizeof(dvi));
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8425 dvi.cbSize = sizeof(dvi);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8426
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8427 hr = (*pGetVer)(&dvi);
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8428
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8429 if (SUCCEEDED(hr)
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8430 && (dvi.dwMajorVersion > 4
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8431 || (dvi.dwMajorVersion == 4
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8432 && dvi.dwMinorVersion >= 70)))
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8433 {
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8434 multiline_tip = TRUE;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8435 return multiline_tip;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8436 }
856
8cd729851562 updated for version 7.0g
vimboss
parents: 843
diff changeset
8437 }
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8438 else
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8439 {
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8440 /* there is chance we have ancient CommCtl 4.70
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8441 which doesn't export DllGetVersion */
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8442 DWORD dwHandle = 0;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8443 DWORD len = GetFileVersionInfoSize(comctl_dll, &dwHandle);
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8444 if (len > 0)
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8445 {
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8446 VS_FIXEDFILEINFO *ver;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8447 UINT vlen = 0;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8448 void *data = alloc(len);
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8449
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8450 if ((data != NULL
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8451 && GetFileVersionInfo(comctl_dll, 0, len, data)
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8452 && VerQueryValue(data, "\\", (void **)&ver, &vlen)
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8453 && vlen
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8454 && HIWORD(ver->dwFileVersionMS) > 4)
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8455 || ((HIWORD(ver->dwFileVersionMS) == 4
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8456 && LOWORD(ver->dwFileVersionMS) >= 70)))
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8457 {
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8458 vim_free(data);
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8459 multiline_tip = TRUE;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8460 return multiline_tip;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8461 }
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8462 vim_free(data);
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8463 }
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8464 }
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8465 }
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8466 multiline_tip = FALSE;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8467 return multiline_tip;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8468 }
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8469
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8470 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8471 make_tooltip(BalloonEval *beval, char *text, POINT pt)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8472 {
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8473 TOOLINFO *pti;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8474 int ToolInfoSize;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8475
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8476 if (multiline_balloon_available() == TRUE)
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8477 ToolInfoSize = sizeof(TOOLINFO_NEW);
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8478 else
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8479 ToolInfoSize = sizeof(TOOLINFO);
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8480
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8481 pti = (TOOLINFO *)alloc(ToolInfoSize);
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8482 if (pti == NULL)
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8483 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8484
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8485 beval->balloon = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8486 NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8487 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8488 beval->target, NULL, s_hinst, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8489
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8490 SetWindowPos(beval->balloon, HWND_TOPMOST, 0, 0, 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8491 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8492
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8493 pti->cbSize = ToolInfoSize;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8494 pti->uFlags = TTF_SUBCLASS;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8495 pti->hwnd = beval->target;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8496 pti->hinst = 0; /* Don't use string resources */
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8497 pti->uId = ID_BEVAL_TOOLTIP;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8498
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8499 if (multiline_balloon_available() == TRUE)
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8500 {
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8501 RECT rect;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8502 TOOLINFO_NEW *ptin = (TOOLINFO_NEW *)pti;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8503 pti->lpszText = LPSTR_TEXTCALLBACK;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8504 ptin->lParam = (LPARAM)text;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8505 if (GetClientRect(s_textArea, &rect)) /* switch multiline tooltips on */
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8506 SendMessage(beval->balloon, TTM_SETMAXTIPWIDTH, 0,
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8507 (LPARAM)rect.right);
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8508 }
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8509 else
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8510 pti->lpszText = text; /* do this old way */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8511
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8512 /* Limit ballooneval bounding rect to CursorPos neighbourhood */
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8513 pti->rect.left = pt.x - 3;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8514 pti->rect.top = pt.y - 3;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8515 pti->rect.right = pt.x + 3;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8516 pti->rect.bottom = pt.y + 3;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8517
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8518 SendMessage(beval->balloon, TTM_ADDTOOL, 0, (LPARAM)pti);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8519 /* Make tooltip appear sooner */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8520 SendMessage(beval->balloon, TTM_SETDELAYTIME, TTDT_INITIAL, 10);
1489
62716fd61fe9 updated for version 7.1-204
vimboss
parents: 1481
diff changeset
8521 /* I've performed some tests and it seems the longest possible life time
62716fd61fe9 updated for version 7.1-204
vimboss
parents: 1481
diff changeset
8522 * of tooltip is 30 seconds */
62716fd61fe9 updated for version 7.1-204
vimboss
parents: 1481
diff changeset
8523 SendMessage(beval->balloon, TTM_SETDELAYTIME, TTDT_AUTOPOP, 30000);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8524 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8525 * HACK: force tooltip to appear, because it'll not appear until
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8526 * first mouse move. D*mn M$
1489
62716fd61fe9 updated for version 7.1-204
vimboss
parents: 1481
diff changeset
8527 * Amazingly moving (2, 2) and then (-1, -1) the mouse doesn't move.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8528 */
1489
62716fd61fe9 updated for version 7.1-204
vimboss
parents: 1481
diff changeset
8529 mouse_event(MOUSEEVENTF_MOVE, 2, 2, 0, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8530 mouse_event(MOUSEEVENTF_MOVE, (DWORD)-1, (DWORD)-1, 0, 0);
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8531 vim_free(pti);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8532 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8533
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8534 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8535 delete_tooltip(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8536 {
7056
1ebd7608cfd9 commit https://github.com/vim/vim/commit/8e5f5b47c2198ffa4161c21a4140eaa9bed46f37
Christian Brabandt <cb@256bit.org>
parents: 7032
diff changeset
8537 PostMessage(beval->balloon, WM_CLOSE, 0, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8538 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8539
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8540 static VOID CALLBACK
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8541 BevalTimerProc(
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
8542 HWND hwnd UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
8543 UINT uMsg UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
8544 UINT_PTR idEvent UNUSED,
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
8545 DWORD dwTime)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8546 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8547 POINT pt;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8548 RECT rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8549
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8550 if (cur_beval == NULL || cur_beval->showState == ShS_SHOWING || !p_beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8551 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8552
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8553 GetCursorPos(&pt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8554 if (WindowFromPoint(pt) != s_textArea)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8555 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8556
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8557 ScreenToClient(s_textArea, &pt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8558 GetClientRect(s_textArea, &rect);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8559 if (!PtInRect(&rect, pt))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8560 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8561
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8562 if (LastActivity > 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8563 && (dwTime - LastActivity) >= (DWORD)p_bdlay
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8564 && (cur_beval->showState != ShS_PENDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8565 || abs(cur_beval->x - pt.x) > 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8566 || abs(cur_beval->y - pt.y) > 3))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8567 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8568 /* Pointer resting in one place long enough, it's time to show
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8569 * the tooltip. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8570 cur_beval->showState = ShS_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8571 cur_beval->x = pt.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8572 cur_beval->y = pt.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8573
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
8574 // TRACE0("BevalTimerProc: sending request");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8575
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8576 if (cur_beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8577 (*cur_beval->msgCB)(cur_beval, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8578 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8579 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8580
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8581 void
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
8582 gui_mch_disable_beval_area(BalloonEval *beval UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8583 {
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
8584 // TRACE0("gui_mch_disable_beval_area {{{");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8585 KillTimer(s_textArea, BevalTimerId);
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
8586 // TRACE0("gui_mch_disable_beval_area }}}");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8587 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8588
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8589 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8590 gui_mch_enable_beval_area(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8591 {
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
8592 // TRACE0("gui_mch_enable_beval_area |||");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8593 if (beval == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8594 return;
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
8595 // TRACE0("gui_mch_enable_beval_area {{{");
2224
a0cce15dd2a9 Fix definition of UINT_PTR for 64 bit systems.
Bram Moolenaar <bram@vim.org>
parents: 2217
diff changeset
8596 BevalTimerId = SetTimer(s_textArea, 0, (UINT)(p_bdlay / 2), BevalTimerProc);
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
8597 // TRACE0("gui_mch_enable_beval_area }}}");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8598 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8599
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8600 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8601 gui_mch_post_balloon(BalloonEval *beval, char_u *mesg)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8602 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8603 POINT pt;
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10783
diff changeset
8604
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
8605 // TRACE0("gui_mch_post_balloon {{{");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8606 if (beval->showState == ShS_SHOWING)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8607 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8608 GetCursorPos(&pt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8609 ScreenToClient(s_textArea, &pt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8610
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8611 if (abs(beval->x - pt.x) < 3 && abs(beval->y - pt.y) < 3)
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10783
diff changeset
8612 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8613 /* cursor is still here */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8614 gui_mch_disable_beval_area(cur_beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8615 beval->showState = ShS_SHOWING;
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8616 make_tooltip(beval, (char *)mesg, pt);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8617 }
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
8618 // TRACE0("gui_mch_post_balloon }}}");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8619 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8620
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8621 BalloonEval *
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8622 gui_mch_create_beval_area(
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8623 void *target, /* ignored, always use s_textArea */
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8624 char_u *mesg,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8625 void (*mesgCB)(BalloonEval *, int),
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8626 void *clientData)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8627 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8628 /* partially stolen from gui_beval.c */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8629 BalloonEval *beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8630
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8631 if (mesg != NULL && mesgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8632 {
10359
66f1b5bf3fa6 commit https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f
Christian Brabandt <cb@256bit.org>
parents: 10264
diff changeset
8633 IEMSG(_("E232: Cannot create BalloonEval with both message and callback"));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8634 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8635 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8636
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8637 beval = (BalloonEval *)alloc(sizeof(BalloonEval));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8638 if (beval != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8639 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8640 beval->target = s_textArea;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8641 beval->balloon = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8642
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8643 beval->showState = ShS_NEUTRAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8644 beval->x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8645 beval->y = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8646 beval->msg = mesg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8647 beval->msgCB = mesgCB;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8648 beval->clientData = clientData;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8649
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8650 InitCommonControls();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8651 cur_beval = beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8652
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8653 if (p_beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8654 gui_mch_enable_beval_area(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8655
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8656 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8657 return beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8658 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8659
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8660 static void
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
8661 Handle_WM_Notify(HWND hwnd UNUSED, LPNMHDR pnmh)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8662 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8663 if (pnmh->idFrom != ID_BEVAL_TOOLTIP) /* it is not our tooltip */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8664 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8665
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8666 if (cur_beval != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8667 {
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8668 switch (pnmh->code)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8669 {
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8670 case TTN_SHOW:
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
8671 // TRACE0("TTN_SHOW {{{");
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
8672 // TRACE0("TTN_SHOW }}}");
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8673 break;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8674 case TTN_POP: /* Before tooltip disappear */
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
8675 // TRACE0("TTN_POP {{{");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8676 delete_tooltip(cur_beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8677 gui_mch_enable_beval_area(cur_beval);
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
8678 // TRACE0("TTN_POP }}}");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8679
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8680 cur_beval->showState = ShS_NEUTRAL;
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8681 break;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8682 case TTN_GETDISPINFO:
1481
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
8683 {
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
8684 /* if you get there then we have new common controls */
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
8685 NMTTDISPINFO_NEW *info = (NMTTDISPINFO_NEW *)pnmh;
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
8686 info->lpszText = (LPSTR)info->lParam;
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
8687 info->uFlags |= TTF_DI_SETITEM;
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
8688 }
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8689 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8690 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8691 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8692 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8693
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8694 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8695 TrackUserActivity(UINT uMsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8696 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8697 if ((uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8698 || (uMsg >= WM_KEYFIRST && uMsg <= WM_KEYLAST))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8699 LastActivity = GetTickCount();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8700 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8701
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8702 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8703 gui_mch_destroy_beval_area(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8704 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8705 vim_free(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8706 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8707 #endif /* FEAT_BEVAL */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8708
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8709 #if defined(FEAT_NETBEANS_INTG) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8710 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8711 * We have multiple signs to draw at the same location. Draw the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8712 * multi-sign indicator (down-arrow) instead. This is the Win32 version.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8713 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8714 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8715 netbeans_draw_multisign_indicator(int row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8716 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8717 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8718 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8719 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8720
2210
8c6a66e2b3cc Add :nbstart and :nbclose.
Bram Moolenaar <bram@vim.org>
parents: 2078
diff changeset
8721 if (!netbeans_active())
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2224
diff changeset
8722 return;
2210
8c6a66e2b3cc Add :nbstart and :nbclose.
Bram Moolenaar <bram@vim.org>
parents: 2078
diff changeset
8723
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8724 x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8725 y = TEXT_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8726
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8727 for (i = 0; i < gui.char_height - 3; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8728 SetPixel(s_hdc, x+2, y++, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8729
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8730 SetPixel(s_hdc, x+0, y, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8731 SetPixel(s_hdc, x+2, y, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8732 SetPixel(s_hdc, x+4, y++, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8733 SetPixel(s_hdc, x+1, y, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8734 SetPixel(s_hdc, x+2, y, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8735 SetPixel(s_hdc, x+3, y++, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8736 SetPixel(s_hdc, x+2, y, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8737 }
7743
6069f43cea4e commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents: 7560
diff changeset
8738 #endif