annotate src/gui_w32.c @ 30523:5ab992f09df8 v9.0.0597

patch 9.0.0597: cannot close a tab page with the middle mouse button Commit: https://github.com/vim/vim/commit/3bdef10dc1c836e5e5a6fdcc1c21155cbd80d798 Author: regomne <fallingsunz@gmail.com> Date: Mon Sep 26 20:48:32 2022 +0100 patch 9.0.0597: cannot close a tab page with the middle mouse button Problem: Cannot close a tab page with the middle mouse button. Solution: Support closing a tab page with the middle mouse button, like many other programs. (closes #10746)
author Bram Moolenaar <Bram@vim.org>
date Mon, 26 Sep 2022 22:00:04 +0200
parents 499c766d0c14
children 101f08b49ed3
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
29491
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
32 // values for "dead_key"
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
33 #define DEAD_KEY_OFF 0 // no dead key
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
34 #define DEAD_KEY_SET_DEFAULT 1 // dead key pressed
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
35 #define DEAD_KEY_TRANSIENT_IN_ON_CHAR 2 // wait for next key press
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
36 #define DEAD_KEY_SKIP_ON_CHAR 3 // skip next _OnChar()
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
37
6359
9f9058aeba0d updated for version 7.4.512
Bram Moolenaar <bram@vim.org>
parents: 6260
diff changeset
38 #if defined(FEAT_DIRECTX)
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
39 static DWriteContext *s_dwc = NULL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
40 static int s_directx_enabled = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
41 static int s_directx_load_attempted = 0;
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12994
diff changeset
42 # define IS_ENABLE_DIRECTX() (s_directx_enabled && s_dwc != NULL && enc_utf8)
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
43 static int directx_enabled(void);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
44 static void directx_binddc(void);
6359
9f9058aeba0d updated for version 7.4.512
Bram Moolenaar <bram@vim.org>
parents: 6260
diff changeset
45 #endif
9f9058aeba0d updated for version 7.4.512
Bram Moolenaar <bram@vim.org>
parents: 6260
diff changeset
46
8138
f52504c10387 commit https://github.com/vim/vim/commit/065bbac8adfe29a09958570237d223457f235c6c
Christian Brabandt <cb@256bit.org>
parents: 8108
diff changeset
47 #ifdef FEAT_MENU
f52504c10387 commit https://github.com/vim/vim/commit/065bbac8adfe29a09958570237d223457f235c6c
Christian Brabandt <cb@256bit.org>
parents: 8108
diff changeset
48 static int gui_mswin_get_menu_height(int fix_window);
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
49 #else
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
50 # define gui_mswin_get_menu_height(fix_window) 0
8138
f52504c10387 commit https://github.com/vim/vim/commit/065bbac8adfe29a09958570237d223457f235c6c
Christian Brabandt <cb@256bit.org>
parents: 8108
diff changeset
51 #endif
f52504c10387 commit https://github.com/vim/vim/commit/065bbac8adfe29a09958570237d223457f235c6c
Christian Brabandt <cb@256bit.org>
parents: 8108
diff changeset
52
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
53 #if defined(FEAT_RENDER_OPTIONS) || defined(PROTO)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
54 int
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
55 gui_mch_set_rendering_options(char_u *s)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
56 {
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12994
diff changeset
57 # ifdef FEAT_DIRECTX
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
58 char_u *p, *q;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
59
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
60 int dx_enable = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
61 int dx_flags = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
62 float dx_gamma = 0.0f;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
63 float dx_contrast = 0.0f;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
64 float dx_level = 0.0f;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
65 int dx_geom = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
66 int dx_renmode = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
67 int dx_taamode = 0;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
68
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
69 // parse string as rendering options.
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
70 for (p = s; p != NULL && *p != NUL; )
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
71 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
72 char_u item[256];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
73 char_u name[128];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
74 char_u value[128];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
75
7009
286fd54c7ae3 patch 7.4.822
Bram Moolenaar <bram@vim.org>
parents: 6714
diff changeset
76 copy_option_part(&p, item, sizeof(item), ",");
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
77 if (p == NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
78 break;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
79 q = &item[0];
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
80 copy_option_part(&q, name, sizeof(name), ":");
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
81 if (q == NULL)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
82 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
83 copy_option_part(&q, value, sizeof(value), ":");
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
84
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
85 if (STRCMP(name, "type") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
86 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
87 if (STRCMP(value, "directx") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
88 dx_enable = 1;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
89 else
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
90 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
91 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
92 else if (STRCMP(name, "gamma") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
93 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
94 dx_flags |= 1 << 0;
8108
50515f2e81d1 commit https://github.com/vim/vim/commit/7f0608fb5219645d776fadfe13efb867c2460698
Christian Brabandt <cb@256bit.org>
parents: 8102
diff changeset
95 dx_gamma = (float)atof((char *)value);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
96 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
97 else if (STRCMP(name, "contrast") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
98 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
99 dx_flags |= 1 << 1;
8108
50515f2e81d1 commit https://github.com/vim/vim/commit/7f0608fb5219645d776fadfe13efb867c2460698
Christian Brabandt <cb@256bit.org>
parents: 8102
diff changeset
100 dx_contrast = (float)atof((char *)value);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
101 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
102 else if (STRCMP(name, "level") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
103 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
104 dx_flags |= 1 << 2;
8108
50515f2e81d1 commit https://github.com/vim/vim/commit/7f0608fb5219645d776fadfe13efb867c2460698
Christian Brabandt <cb@256bit.org>
parents: 8102
diff changeset
105 dx_level = (float)atof((char *)value);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
106 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
107 else if (STRCMP(name, "geom") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
108 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
109 dx_flags |= 1 << 3;
8108
50515f2e81d1 commit https://github.com/vim/vim/commit/7f0608fb5219645d776fadfe13efb867c2460698
Christian Brabandt <cb@256bit.org>
parents: 8102
diff changeset
110 dx_geom = atoi((char *)value);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
111 if (dx_geom < 0 || dx_geom > 2)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
112 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
113 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
114 else if (STRCMP(name, "renmode") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
115 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
116 dx_flags |= 1 << 4;
8108
50515f2e81d1 commit https://github.com/vim/vim/commit/7f0608fb5219645d776fadfe13efb867c2460698
Christian Brabandt <cb@256bit.org>
parents: 8102
diff changeset
117 dx_renmode = atoi((char *)value);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
118 if (dx_renmode < 0 || dx_renmode > 6)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
119 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
120 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
121 else if (STRCMP(name, "taamode") == 0)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
122 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
123 dx_flags |= 1 << 5;
8108
50515f2e81d1 commit https://github.com/vim/vim/commit/7f0608fb5219645d776fadfe13efb867c2460698
Christian Brabandt <cb@256bit.org>
parents: 8102
diff changeset
124 dx_taamode = atoi((char *)value);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
125 if (dx_taamode < 0 || dx_taamode > 3)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
126 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
127 }
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
128 else if (STRCMP(name, "scrlines") == 0)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
129 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
130 // Deprecated. Simply ignore it.
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
131 }
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
132 else
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
133 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
134 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
135
12994
8566eaa08788 patch 8.0.1373: no error when settting 'renderoptions' before starting GUI
Christian Brabandt <cb@256bit.org>
parents: 12986
diff changeset
136 if (!gui.in_use)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
137 return OK; // only checking the syntax of the value
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
138
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
139 // Enable DirectX/DirectWrite
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
140 if (dx_enable)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
141 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
142 if (!directx_enabled())
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
143 return FAIL;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
144 DWriteContext_SetRenderingParams(s_dwc, NULL);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
145 if (dx_flags)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
146 {
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
147 DWriteRenderingParams param;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
148 DWriteContext_GetRenderingParams(s_dwc, &param);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
149 if (dx_flags & (1 << 0))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
150 param.gamma = dx_gamma;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
151 if (dx_flags & (1 << 1))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
152 param.enhancedContrast = dx_contrast;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
153 if (dx_flags & (1 << 2))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
154 param.clearTypeLevel = dx_level;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
155 if (dx_flags & (1 << 3))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
156 param.pixelGeometry = dx_geom;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
157 if (dx_flags & (1 << 4))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
158 param.renderingMode = dx_renmode;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
159 if (dx_flags & (1 << 5))
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
160 param.textAntialiasMode = dx_taamode;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
161 DWriteContext_SetRenderingParams(s_dwc, &param);
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 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
164 s_directx_enabled = dx_enable;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
165
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
166 return OK;
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12994
diff changeset
167 # else
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
168 return FAIL;
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12994
diff changeset
169 # endif
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
170 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
171 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
172
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
173 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
174 * These are new in Windows ME/XP, only defined in recent compilers.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
175 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
176 #ifndef HANDLE_WM_XBUTTONUP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
177 # define HANDLE_WM_XBUTTONUP(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
178 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
179 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 #ifndef HANDLE_WM_XBUTTONDOWN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 # define HANDLE_WM_XBUTTONDOWN(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 #ifndef HANDLE_WM_XBUTTONDBLCLK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 # define HANDLE_WM_XBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
187 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
189
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
190 #include "version.h" // used by dialog box routine for default title
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
191 #ifdef DEBUG
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
192 # include <tchar.h>
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
193 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
194
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
195 // cproto fails on missing include files
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
196 #ifndef PROTO
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
197
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
198 # ifndef __MINGW32__
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
199 # include <shellapi.h>
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
200 # endif
30200
499c766d0c14 patch 9.0.0436: CI: running tests in parallel causes flakiness
Bram Moolenaar <Bram@vim.org>
parents: 30144
diff changeset
201 # include <commctrl.h>
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
202 # include <windowsx.h>
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
203
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
204 #endif // PROTO
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
205
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
206 #ifdef FEAT_MENU
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
207 # define MENUHINTS // show menu hints in command line
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
208 #endif
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
209
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
210 // Some parameters for dialog boxes. All in pixels.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
211 #define DLG_PADDING_X 10
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
212 #define DLG_PADDING_Y 10
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
213 #define DLG_VERT_PADDING_X 4 // For vertical buttons
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
214 #define DLG_VERT_PADDING_Y 4
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
215 #define DLG_ICON_WIDTH 34
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
216 #define DLG_ICON_HEIGHT 34
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
217 #define DLG_MIN_WIDTH 150
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
218 #define DLG_FONT_NAME "MS Shell Dlg"
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
219 #define DLG_FONT_POINT_SIZE 8
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
220 #define DLG_MIN_MAX_WIDTH 400
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
221 #define DLG_MIN_MAX_HEIGHT 400
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
222
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
223 #define DLG_NONBUTTON_CONTROL 5000 // First ID of non-button controls
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
224
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
225 #ifndef WM_DPICHANGED
28700
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
226 # define WM_DPICHANGED 0x02E0
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
227 #endif
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
228
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
229 #ifndef WM_MOUSEHWHEEL
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
230 # define WM_MOUSEHWHEEL 0x020E
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
231 #endif
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
232
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
233 #ifndef SPI_GETWHEELSCROLLCHARS
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
234 # define SPI_GETWHEELSCROLLCHARS 0x006C
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
235 #endif
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
236
28755
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
237 #ifndef SPI_SETWHEELSCROLLCHARS
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
238 # define SPI_SETWHEELSCROLLCHARS 0x006D
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
239 #endif
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
240
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
241 #ifdef PROTO
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
242 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
243 * 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
244 * 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
245 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
246 # define APIENTRY
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
247 # define CALLBACK
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
248 # define CONST
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
249 # define FAR
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
250 # define NEAR
21361
75514c95b948 patch 8.2.1231: MS-Windows: GUI code can be cleaned up
Bram Moolenaar <Bram@vim.org>
parents: 21355
diff changeset
251 # define WINAPI
9834
80ace3687eec commit https://github.com/vim/vim/commit/a6b7a08ae04a3cd4d9c45c906bb7a197e2135179
Christian Brabandt <cb@256bit.org>
parents: 9428
diff changeset
252 # undef _cdecl
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
253 # define _cdecl
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
254 typedef int BOOL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
255 typedef int BYTE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
256 typedef int DWORD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
257 typedef int WCHAR;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
258 typedef int ENUMLOGFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
259 typedef int FINDREPLACE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
260 typedef int HANDLE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
261 typedef int HBITMAP;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
262 typedef int HBRUSH;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
263 typedef int HDROP;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
264 typedef int INT;
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
265 typedef int LOGFONTW[];
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
266 typedef int LPARAM;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
267 typedef int LPCREATESTRUCT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
268 typedef int LPCSTR;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
269 typedef int LPCTSTR;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
270 typedef int LPRECT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
271 typedef int LPSTR;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
272 typedef int LPWINDOWPOS;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
273 typedef int LPWORD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
274 typedef int LRESULT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
275 typedef int HRESULT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
276 # undef MSG
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
277 typedef int MSG;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
278 typedef int NEWTEXTMETRIC;
29310
f103da6ba95f patch 8.2.5171: dependencies and proto files are outdated
Bram Moolenaar <Bram@vim.org>
parents: 29283
diff changeset
279 typedef int NMHDR;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
280 typedef int OSVERSIONINFO;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
281 typedef int PWORD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
282 typedef int RECT;
29310
f103da6ba95f patch 8.2.5171: dependencies and proto files are outdated
Bram Moolenaar <Bram@vim.org>
parents: 29283
diff changeset
283 typedef int SIZE;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
284 typedef int UINT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
285 typedef int WORD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
286 typedef int WPARAM;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
287 typedef int POINT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
288 typedef void *HINSTANCE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
289 typedef void *HMENU;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
290 typedef void *HWND;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
291 typedef void *HDC;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
292 typedef void VOID;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
293 typedef int LPNMHDR;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
294 typedef int LONG;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
295 typedef int WNDPROC;
9834
80ace3687eec commit https://github.com/vim/vim/commit/a6b7a08ae04a3cd4d9c45c906bb7a197e2135179
Christian Brabandt <cb@256bit.org>
parents: 9428
diff changeset
296 typedef int UINT_PTR;
13963
1174611ad715 Vim 8.1 release
Christian Brabandt <cb@256bit.org>
parents: 13766
diff changeset
297 typedef int COLORREF;
1174611ad715 Vim 8.1 release
Christian Brabandt <cb@256bit.org>
parents: 13766
diff changeset
298 typedef int HCURSOR;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
299 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
300
27281
f7d73708b391 patch 8.2.4169: MS-Windows: unnessary casts and other minor things
Bram Moolenaar <Bram@vim.org>
parents: 27261
diff changeset
301 static void _OnPaint(HWND hwnd);
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
302 static void fill_rect(const RECT *rcp, HBRUSH hbr, COLORREF color);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
303 static void clear_rect(RECT *rcp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
304
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
305 static WORD s_dlgfntheight; // height of the dialog font
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
306 static WORD s_dlgfntwidth; // width of the dialog font
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
307
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
308 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
309 static HMENU s_menuBar = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
310 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
311 #ifdef FEAT_TEAROFF
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
312 static void rebuild_tearoff(vimmenu_T *menu);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
313 static HBITMAP s_htearbitmap; // bitmap used to indicate tearoff
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
314 #endif
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
315
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
316 // Flag that is set while processing a message that must not be interrupted by
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
317 // processing another message.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
318 static int s_busy_processing = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
319
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
320 static int destroying = FALSE; // call DestroyWindow() ourselves
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
321
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
322 #ifdef MSWIN_FIND_REPLACE
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
323 static UINT s_findrep_msg = 0;
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
324 static FINDREPLACEW s_findrep_struct;
8140
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;
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
326 static int s_findrep_is_find; // TRUE for find dialog, FALSE
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
327 // for find/replace dialog
8140
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 HWND s_hwnd = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
331 static HDC s_hdc = NULL;
18617
5beda1754026 patch 8.1.2301: MS-Windows GUI: drawing error when background color changes
Bram Moolenaar <Bram@vim.org>
parents: 18526
diff changeset
332 static HBRUSH s_brush = NULL;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
333
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
334 #ifdef FEAT_TOOLBAR
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
335 static HWND s_toolbarhwnd = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
336 static WNDPROC s_toolbar_wndproc = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
337 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
338
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
339 #ifdef FEAT_GUI_TABLINE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
340 static HWND s_tabhwnd = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
341 static WNDPROC s_tabline_wndproc = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
342 static int showing_tabline = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
343 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
344
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
345 static WPARAM s_wParam = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
346 static LPARAM s_lParam = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
347
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
348 static HWND s_textArea = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
349 static UINT s_uMsg = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
350
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
351 static char_u *s_textfield; // Used by dialogs to pass back strings
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
352
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
353 static int s_need_activate = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
354
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
355 // This variable is set when waiting for an event, which is the only moment
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
356 // scrollbar dragging can be done directly. It's not allowed while commands
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
357 // are executed, because it may move the cursor and that may cause unexpected
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
358 // problems (e.g., while ":s" is working).
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
359 static int allow_scrollbar = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
360
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
361 #ifndef _DPI_AWARENESS_CONTEXTS_
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
362 typedef HANDLE DPI_AWARENESS_CONTEXT;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
363
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
364 typedef enum DPI_AWARENESS {
27229
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
365 DPI_AWARENESS_INVALID = -1,
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
366 DPI_AWARENESS_UNAWARE = 0,
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
367 DPI_AWARENESS_SYSTEM_AWARE = 1,
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
368 DPI_AWARENESS_PER_MONITOR_AWARE = 2
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
369 } DPI_AWARENESS;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
370
27229
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
371 # define DPI_AWARENESS_CONTEXT_UNAWARE ((DPI_AWARENESS_CONTEXT)-1)
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
372 # define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((DPI_AWARENESS_CONTEXT)-2)
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
373 # define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ((DPI_AWARENESS_CONTEXT)-3)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
374 # define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
375 # define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
376 #endif
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
377
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
378 #define DEFAULT_DPI 96
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
379 static int s_dpi = DEFAULT_DPI;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
380 static BOOL s_in_dpichanged = FALSE;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
381 static DPI_AWARENESS s_process_dpi_aware = DPI_AWARENESS_INVALID;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
382
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
383 static UINT (WINAPI *pGetDpiForSystem)(void) = NULL;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
384 static UINT (WINAPI *pGetDpiForWindow)(HWND hwnd) = NULL;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
385 static int (WINAPI *pGetSystemMetricsForDpi)(int, UINT) = NULL;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
386 //static INT (WINAPI *pGetWindowDpiAwarenessContext)(HWND hwnd) = NULL;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
387 static DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT dpiContext) = NULL;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
388 static DPI_AWARENESS (WINAPI *pGetAwarenessFromDpiAwarenessContext)(DPI_AWARENESS_CONTEXT) = NULL;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
389
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
390 static UINT WINAPI
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
391 stubGetDpiForSystem(void)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
392 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
393 HWND hwnd = GetDesktopWindow();
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
394 HDC hdc = GetWindowDC(hwnd);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
395 UINT dpi = GetDeviceCaps(hdc, LOGPIXELSY);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
396 ReleaseDC(hwnd, hdc);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
397 return dpi;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
398 }
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
399
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
400 static int WINAPI
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
401 stubGetSystemMetricsForDpi(int nIndex, UINT dpi UNUSED)
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
402 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
403 return GetSystemMetrics(nIndex);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
404 }
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
405
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
406 static int
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
407 adjust_fontsize_by_dpi(int size)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
408 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
409 return size * s_dpi / (int)pGetDpiForSystem();
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
410 }
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
411
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
412 static int
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
413 adjust_by_system_dpi(int size)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
414 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
415 return size * (int)pGetDpiForSystem() / DEFAULT_DPI;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
416 }
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
417
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
418 #if defined(FEAT_DIRECTX)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
419 static int
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
420 directx_enabled(void)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
421 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
422 if (s_dwc != NULL)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
423 return 1;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
424 else if (s_directx_load_attempted)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
425 return 0;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
426 // load DirectX
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
427 DWrite_Init();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
428 s_directx_load_attempted = 1;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
429 s_dwc = DWriteContext_Open();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
430 directx_binddc();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
431 return s_dwc != NULL ? 1 : 0;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
432 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
433
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
434 static void
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
435 directx_binddc(void)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
436 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
437 if (s_textArea != NULL)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
438 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
439 RECT rect;
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
440 GetClientRect(s_textArea, &rect);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
441 DWriteContext_BindDC(s_dwc, s_hdc, &rect);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
442 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
443 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
444 #endif
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
445
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
446 extern int current_font_height; // this is in os_mswin.c
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
447
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
448 static struct
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
449 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
450 UINT key_sym;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
451 char_u vim_code0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
452 char_u vim_code1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
453 } special_keys[] =
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
454 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
455 {VK_UP, 'k', 'u'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
456 {VK_DOWN, 'k', 'd'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
457 {VK_LEFT, 'k', 'l'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
458 {VK_RIGHT, 'k', 'r'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
459
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
460 {VK_F1, 'k', '1'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
461 {VK_F2, 'k', '2'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
462 {VK_F3, 'k', '3'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
463 {VK_F4, 'k', '4'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
464 {VK_F5, 'k', '5'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
465 {VK_F6, 'k', '6'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
466 {VK_F7, 'k', '7'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
467 {VK_F8, 'k', '8'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
468 {VK_F9, 'k', '9'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
469 {VK_F10, 'k', ';'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
470
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
471 {VK_F11, 'F', '1'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
472 {VK_F12, 'F', '2'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
473 {VK_F13, 'F', '3'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
474 {VK_F14, 'F', '4'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
475 {VK_F15, 'F', '5'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
476 {VK_F16, 'F', '6'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
477 {VK_F17, 'F', '7'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
478 {VK_F18, 'F', '8'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
479 {VK_F19, 'F', '9'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
480 {VK_F20, 'F', 'A'},
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 {VK_F21, 'F', 'B'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
483 #ifdef FEAT_NETBEANS_INTG
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
484 {VK_PAUSE, 'F', 'B'}, // Pause == F21 (see gui_gtk_x11.c)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
485 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
486 {VK_F22, 'F', 'C'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
487 {VK_F23, 'F', 'D'},
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
488 {VK_F24, 'F', 'E'}, // winuser.h defines up to F24
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
489
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
490 {VK_HELP, '%', '1'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
491 {VK_BACK, 'k', 'b'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
492 {VK_INSERT, 'k', 'I'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
493 {VK_DELETE, 'k', 'D'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
494 {VK_HOME, 'k', 'h'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
495 {VK_END, '@', '7'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
496 {VK_PRIOR, 'k', 'P'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
497 {VK_NEXT, 'k', 'N'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
498 {VK_PRINT, '%', '9'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
499 {VK_ADD, 'K', '6'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
500 {VK_SUBTRACT, 'K', '7'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
501 {VK_DIVIDE, 'K', '8'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
502 {VK_MULTIPLY, 'K', '9'},
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
503 {VK_SEPARATOR, 'K', 'A'}, // Keypad Enter
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
504 {VK_DECIMAL, 'K', 'B'},
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 {VK_NUMPAD0, 'K', 'C'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
507 {VK_NUMPAD1, 'K', 'D'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
508 {VK_NUMPAD2, 'K', 'E'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
509 {VK_NUMPAD3, 'K', 'F'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
510 {VK_NUMPAD4, 'K', 'G'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
511 {VK_NUMPAD5, 'K', 'H'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
512 {VK_NUMPAD6, 'K', 'I'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
513 {VK_NUMPAD7, 'K', 'J'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
514 {VK_NUMPAD8, 'K', 'K'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
515 {VK_NUMPAD9, 'K', 'L'},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
516
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
517 // Keys that we want to be able to use any modifier with:
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
518 {VK_SPACE, ' ', NUL},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
519 {VK_TAB, TAB, NUL},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
520 {VK_ESCAPE, ESC, NUL},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
521 {NL, NL, NUL},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
522 {CAR, CAR, NUL},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
523
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
524 // End of list marker:
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
525 {0, 0, 0}
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
526 };
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
527
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
528 // Local variables
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
529 static int s_button_pending = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
530
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
531 // s_getting_focus is set when we got focus but didn't see mouse-up event yet,
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
532 // so don't reset s_button_pending.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
533 static int s_getting_focus = FALSE;
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 s_x_pending;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
536 static int s_y_pending;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
537 static UINT s_kFlags_pending;
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
538 static UINT_PTR s_wait_timer = 0; // Timer for get char from user
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
539 static int s_timed_out = FALSE;
29491
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
540 static int dead_key = DEAD_KEY_OFF;
13766
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
541 static UINT surrogate_pending_ch = 0; // 0: no surrogate pending,
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
542 // else a high surrogate
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
543
12871
1a450ce6980c patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents: 12802
diff changeset
544 #ifdef FEAT_BEVAL_GUI
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
545 // balloon-eval WM_NOTIFY_HANDLER
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
546 static void Handle_WM_Notify(HWND hwnd, LPNMHDR pnmh);
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
547 static void track_user_activity(UINT uMsg);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
548 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
549
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
550 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
551 * For control IME.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
552 *
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
553 * These LOGFONTW used for IME.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
554 */
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
555 #ifdef FEAT_MBYTE_IME
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
556 // holds LOGFONTW for 'guifontwide' if available, otherwise 'guifont'
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
557 static LOGFONTW norm_logfont;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
558 // holds LOGFONTW for 'guifont' always.
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
559 static LOGFONTW sub_logfont;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
560 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
561
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
562 #ifdef FEAT_MBYTE_IME
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
563 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
564 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
565
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
566 #if defined(FEAT_BROWSE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
567 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
568 #endif
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 #ifdef DEBUG_PRINT_ERROR
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
571 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
572 * 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
573 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
574 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
575 print_windows_error(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
576 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
577 LPVOID lpMsgBuf;
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 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
580 NULL, GetLastError(),
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
581 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
582 (LPTSTR) &lpMsgBuf, 0, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
583 TRACE1("Error: %s\n", lpMsgBuf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
584 LocalFree(lpMsgBuf);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
585 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
586 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
587
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 * Cursor blink functions.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
590 *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
591 * This is a simple state machine:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
592 * BLINK_NONE not blinking at all
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
593 * 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
594 * BLINK_ON blinking, cursor is shown
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
597 #define BLINK_NONE 0
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
598 #define BLINK_OFF 1
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
599 #define BLINK_ON 2
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 static int blink_state = BLINK_NONE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
602 static long_u blink_waittime = 700;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
603 static long_u blink_ontime = 400;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
604 static long_u blink_offtime = 250;
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
605 static UINT_PTR blink_timer = 0;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
606
9213
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9181
diff changeset
607 int
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9181
diff changeset
608 gui_mch_is_blinking(void)
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9181
diff changeset
609 {
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9181
diff changeset
610 return blink_state != BLINK_NONE;
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9181
diff changeset
611 }
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9181
diff changeset
612
9428
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9252
diff changeset
613 int
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9252
diff changeset
614 gui_mch_is_blink_off(void)
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9252
diff changeset
615 {
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9252
diff changeset
616 return blink_state == BLINK_OFF;
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9252
diff changeset
617 }
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9252
diff changeset
618
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
619 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
620 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
621 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
622 blink_waittime = wait;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
623 blink_ontime = on;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
624 blink_offtime = off;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
625 }
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 static VOID CALLBACK
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
628 _OnBlinkTimer(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
629 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
630 UINT uMsg UNUSED,
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
631 UINT_PTR 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
632 DWORD dwTime UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
633 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
634 MSG msg;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
635
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
636 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
637 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
638 */
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 KillTimer(NULL, idEvent);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
641
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
642 // Eat spurious WM_TIMER messages
27283
b4d92a69035b patch 8.2.4170: MS-Windows: still using old message API calls
Bram Moolenaar <Bram@vim.org>
parents: 27281
diff changeset
643 while (PeekMessageW(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
8140
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 if (blink_state == BLINK_ON)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
647 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
648 gui_undraw_cursor();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
649 blink_state = BLINK_OFF;
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
650 blink_timer = SetTimer(NULL, 0, (UINT)blink_offtime, _OnBlinkTimer);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
651 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
652 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
653 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
654 gui_update_cursor(TRUE, FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
655 blink_state = BLINK_ON;
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
656 blink_timer = SetTimer(NULL, 0, (UINT)blink_ontime, _OnBlinkTimer);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
657 }
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
658 gui_mch_flush();
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
659 }
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 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
662 gui_mswin_rm_blink_timer(void)
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 MSG msg;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
665
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
666 if (blink_timer != 0)
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 KillTimer(NULL, blink_timer);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
669 // Eat spurious WM_TIMER messages
27283
b4d92a69035b patch 8.2.4170: MS-Windows: still using old message API calls
Bram Moolenaar <Bram@vim.org>
parents: 27281
diff changeset
670 while (PeekMessageW(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
671 ;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
672 blink_timer = 0;
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 }
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 * 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
678 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
679 void
13152
f4c3a7f410f4 patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
680 gui_mch_stop_blink(int may_call_gui_update_cursor)
8140
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 gui_mswin_rm_blink_timer();
13152
f4c3a7f410f4 patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
683 if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
684 {
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
685 gui_update_cursor(TRUE, FALSE);
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
686 gui_mch_flush();
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
687 }
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
688 blink_state = BLINK_NONE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
689 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
690
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
691 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
692 * 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
693 * waiting time and shows the cursor.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
694 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
695 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
696 gui_mch_start_blink(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
697 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
698 gui_mswin_rm_blink_timer();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
699
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
700 // Only switch blinking on if none of the times is zero
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
701 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
702 {
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
703 blink_timer = SetTimer(NULL, 0, (UINT)blink_waittime, _OnBlinkTimer);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
704 blink_state = BLINK_ON;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
705 gui_update_cursor(TRUE, FALSE);
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
706 gui_mch_flush();
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
707 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
708 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
709
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
710 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
711 * Call-back routines.
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 static VOID CALLBACK
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
715 _OnTimer(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
716 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
717 UINT uMsg UNUSED,
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
718 UINT_PTR 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
719 DWORD dwTime UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
720 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
721 MSG msg;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
722
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
723 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
724 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
725 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
726 KillTimer(NULL, idEvent);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
727 s_timed_out = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
728
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
729 // Eat spurious WM_TIMER messages
27283
b4d92a69035b patch 8.2.4170: MS-Windows: still using old message API calls
Bram Moolenaar <Bram@vim.org>
parents: 27281
diff changeset
730 while (PeekMessageW(&msg, hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
8140
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 if (idEvent == s_wait_timer)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
733 s_wait_timer = 0;
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 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
737 _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
738 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
739 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
740 int cRepeat UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
741 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
742 dead_key = 1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
743 }
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 * 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
747 * 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
748 * Return the length.
13766
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
749 * Because the Windows API uses UTF-16, we have to deal with surrogate
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
750 * pairs; this is where we choose to deal with them: if "ch" is a high
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
751 * surrogate, it will be stored, and the length returned will be zero; the next
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
752 * char_to_string call will then include the high surrogate, decoding the pair
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
753 * of UTF-16 code units to a single Unicode code point, presuming it is the
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
754 * matching low surrogate.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
755 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
756 static int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
757 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
758 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
759 int len;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
760 int i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
761 WCHAR wstring[2];
9252
c25898cc99c1 commit https://github.com/vim/vim/commit/945ec093cd4ddefab930239990564b12eb232153
Christian Brabandt <cb@256bit.org>
parents: 9236
diff changeset
762 char_u *ws = NULL;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
763
13766
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
764 if (surrogate_pending_ch != 0)
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
765 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
766 // We don't guarantee ch is a low surrogate to match the high surrogate
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
767 // we already have; it should be, but if it isn't, tough luck.
13766
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
768 wstring[0] = surrogate_pending_ch;
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
769 wstring[1] = ch;
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
770 surrogate_pending_ch = 0;
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
771 len = 2;
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
772 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
773 else if (ch >= 0xD800 && ch <= 0xDBFF) // high surrogate
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
774 {
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
775 // We don't have the entire code point yet, only the first UTF-16 code
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
776 // unit; so just remember it and use it in the next call.
13766
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
777 surrogate_pending_ch = ch;
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
778 return 0;
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
779 }
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
780 else
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
781 {
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
782 wstring[0] = ch;
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
783 len = 1;
74294f0fbf28 patch 8.0.1755: MS-Windows: high unicode char received as two utf-16 words
Christian Brabandt <cb@256bit.org>
parents: 13244
diff changeset
784 }
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
785
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
786 // "ch" is a UTF-16 character. Convert it to a string of bytes. When
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
787 // "enc_codepage" is non-zero use the standard Win32 function,
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
788 // otherwise use our own conversion function (e.g., for UTF-8).
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
789 if (enc_codepage > 0)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
790 {
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
791 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
792 (LPSTR)string, slen, 0, NULL);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
793 // If we had included the ALT key into the character but now the
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
794 // upper bit is no longer set, that probably means the conversion
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
795 // failed. Convert the original character and set the upper bit
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
796 // afterwards.
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
797 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
798 {
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
799 wstring[0] = ch & 0x7f;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
800 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
801 (LPSTR)string, slen, 0, NULL);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
802 if (len == 1) // safety check
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
803 string[0] |= 0x80;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
804 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
805 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
806 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
807 {
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
808 ws = utf16_to_enc(wstring, &len);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
809 if (ws == NULL)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
810 len = 0;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
811 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
812 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
813 if (len > slen) // just in case
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
814 len = slen;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
815 mch_memmove(string, ws, len);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
816 vim_free(ws);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
817 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
818 }
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 if (len == 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
821 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
822 string[0] = ch;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
823 len = 1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
824 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
825
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
826 for (i = 0; i < len; ++i)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
827 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
828 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
829 // Insert CSI as K_CSI.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
830 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
831 string[++i] = KS_EXTRA;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
832 string[++i] = (int)KE_CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
833 len += 2;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
834 }
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 return len;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
837 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
838
28586
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
839 static int
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
840 get_active_modifiers(void)
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
841 {
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
842 int modifiers = 0;
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
843
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
844 if (GetKeyState(VK_CONTROL) & 0x8000)
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
845 modifiers |= MOD_MASK_CTRL;
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
846 if (GetKeyState(VK_SHIFT) & 0x8000)
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
847 modifiers |= MOD_MASK_SHIFT;
28639
8ea5468f9b5a patch 8.2.4843: treating CTRL + ALT as AltGr is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 28586
diff changeset
848 // Windows handles Ctrl + Alt as AltGr and vice-versa. We can distinguish
8ea5468f9b5a patch 8.2.4843: treating CTRL + ALT as AltGr is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 28586
diff changeset
849 // the two cases by checking whether the left or the right Alt key is
28586
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
850 // pressed.
28639
8ea5468f9b5a patch 8.2.4843: treating CTRL + ALT as AltGr is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 28586
diff changeset
851 if (GetKeyState(VK_LMENU) & 0x8000)
8ea5468f9b5a patch 8.2.4843: treating CTRL + ALT as AltGr is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 28586
diff changeset
852 modifiers |= MOD_MASK_ALT;
8ea5468f9b5a patch 8.2.4843: treating CTRL + ALT as AltGr is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 28586
diff changeset
853 if ((modifiers & MOD_MASK_CTRL) && (GetKeyState(VK_RMENU) & 0x8000))
8ea5468f9b5a patch 8.2.4843: treating CTRL + ALT as AltGr is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 28586
diff changeset
854 modifiers &= ~MOD_MASK_CTRL;
28586
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
855
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
856 return modifiers;
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
857 }
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
858
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
859 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
860 * 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
861 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
862 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
863 _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
864 HWND hwnd UNUSED,
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
865 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
866 int cRepeat UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
867 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
868 char_u string[40];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
869 int len = 0;
28586
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
870 int modifiers;
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
871 int ch = cch; // special keys are negative
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
872
29491
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
873 if (dead_key == DEAD_KEY_SKIP_ON_CHAR)
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
874 return;
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
875
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
876 // keep DEAD_KEY_TRANSIENT_IN_ON_CHAR value for later handling in
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
877 // process_message()
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
878 if (dead_key != DEAD_KEY_TRANSIENT_IN_ON_CHAR)
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
879 dead_key = DEAD_KEY_OFF;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
880
28586
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
881 modifiers = get_active_modifiers();
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
882
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
883 ch = simplify_key(ch, &modifiers);
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
884 // remove the SHIFT modifier for keys where it's already included, e.g.,
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
885 // '(' and '*'
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
886 modifiers = may_remove_shift_modifier(modifiers, ch);
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
887
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
888 // Unify modifiers somewhat. No longer use ALT to set the 8th bit.
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
889 ch = extract_modifiers(ch, &modifiers, FALSE, NULL);
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
890 if (ch == CSI)
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
891 ch = K_CSI;
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
892
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
893 if (modifiers)
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
894 {
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
895 string[0] = CSI;
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
896 string[1] = KS_MODIFIER;
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
897 string[2] = modifiers;
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
898 add_to_input_buf(string, 3);
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
899 }
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
900
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
901 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
902 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
903 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
904 trash_input_buf();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
905 got_int = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
906 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
907
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
908 add_to_input_buf(string, len);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
909 }
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 * 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
913 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
914 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
915 _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
916 HWND hwnd UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
917 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
918 int cRepeat UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
919 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
920 char_u string[40]; // Enough for multibyte character
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
921 int len;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
922 int modifiers;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
923 int ch = cch; // special keys are negative
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
924
29491
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
925 dead_key = DEAD_KEY_OFF;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
926
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
927 // OK, we have a character key (given by ch) which was entered with the
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
928 // ALT key pressed. Eg, if the user presses Alt-A, then ch == 'A'. Note
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
929 // that the system distinguishes Alt-a and Alt-A (Alt-Shift-a unless
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
930 // CAPSLOCK is pressed) at this point.
28586
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
931 modifiers = get_active_modifiers();
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
932 ch = simplify_key(ch, &modifiers);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
933 // remove the SHIFT modifier for keys where it's already included, e.g.,
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
934 // '(' and '*'
22407
c19acd92ee83 patch 8.2.1752: GTK GUI: cannot map alt-? with <A-?>
Bram Moolenaar <Bram@vim.org>
parents: 21363
diff changeset
935 modifiers = may_remove_shift_modifier(modifiers, ch);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
936
20421
8590a462ad46 patch 8.2.0765: In the GUI can't use all the modifiers.
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
937 // Unify modifiers somewhat. No longer use ALT to set the 8th bit.
8590a462ad46 patch 8.2.0765: In the GUI can't use all the modifiers.
Bram Moolenaar <Bram@vim.org>
parents: 20007
diff changeset
938 ch = extract_modifiers(ch, &modifiers, FALSE, NULL);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
939 if (ch == CSI)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
940 ch = K_CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
941
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
942 len = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
943 if (modifiers)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
944 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
945 string[len++] = CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
946 string[len++] = KS_MODIFIER;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
947 string[len++] = modifiers;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
948 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
949
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
950 if (IS_SPECIAL((int)ch))
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 string[len++] = CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
953 string[len++] = K_SECOND((int)ch);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
954 string[len++] = K_THIRD((int)ch);
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 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
957 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
958 // Although the documentation isn't clear about it, we assume "ch" is
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
959 // a Unicode character.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
960 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
961 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
962
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
963 add_to_input_buf(string, len);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
964 }
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 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
967 _OnMouseEvent(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
968 int button,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
969 int x,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
970 int y,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
971 int repeated_click,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
972 UINT keyFlags)
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 int vim_modifiers = 0x0;
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 s_getting_focus = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
977
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
978 if (keyFlags & MK_SHIFT)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
979 vim_modifiers |= MOUSE_SHIFT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
980 if (keyFlags & MK_CONTROL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
981 vim_modifiers |= MOUSE_CTRL;
28639
8ea5468f9b5a patch 8.2.4843: treating CTRL + ALT as AltGr is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 28586
diff changeset
982 if (GetKeyState(VK_LMENU) & 0x8000)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
983 vim_modifiers |= MOUSE_ALT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
984
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
985 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
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 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
989 _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
990 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
991 BOOL fDoubleClick UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
992 int x,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
993 int y,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
994 UINT keyFlags)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
995 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
996 static LONG s_prevTime = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
997
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
998 LONG currentTime = GetMessageTime();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
999 int button = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1000 int repeated_click;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1001
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1002 // Give main window the focus: this is so the cursor isn't hollow.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1003 (void)SetFocus(s_hwnd);
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 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
1006 button = MOUSE_LEFT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1007 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
1008 button = MOUSE_MIDDLE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1009 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
1010 button = MOUSE_RIGHT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1011 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
1012 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1013 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
1014 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1015 else if (s_uMsg == WM_CAPTURECHANGED)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1016 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1017 // on W95/NT4, somehow you get in here with an odd Msg
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1018 // if you press one button while holding down the other..
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1019 if (s_button_pending == MOUSE_LEFT)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1020 button = MOUSE_RIGHT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1021 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1022 button = MOUSE_LEFT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1023 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1024 if (button >= 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1025 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1026 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
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 * 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
1030 * button.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1031 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1032 if (repeated_click
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1033 && ((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
1034 || (button == MOUSE_RIGHT
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1035 && s_button_pending == MOUSE_LEFT)))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1036 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1037 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1038 * 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
1039 * 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
1040 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1041 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
1042 button = MOUSE_MIDDLE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1043 repeated_click = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1044 s_button_pending = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1045 _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
1046 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1047 else if ((repeated_click)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1048 || (mouse_model_popup() && (button == MOUSE_RIGHT)))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1049 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1050 if (s_button_pending > -1)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1051 {
27281
f7d73708b391 patch 8.2.4169: MS-Windows: unnessary casts and other minor things
Bram Moolenaar <Bram@vim.org>
parents: 27261
diff changeset
1052 _OnMouseEvent(s_button_pending, x, y, FALSE, keyFlags);
f7d73708b391 patch 8.2.4169: MS-Windows: unnessary casts and other minor things
Bram Moolenaar <Bram@vim.org>
parents: 27261
diff changeset
1053 s_button_pending = -1;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1054 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1055 // TRACE("Button down at x %d, y %d\n", x, y);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1056 _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
1057 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1058 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1059 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1060 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1061 * 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
1062 * 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
1063 * i) button-up
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1064 * ii) mouse move
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1065 * iii) another button press
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1066 * before using it.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1067 * 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
1068 * 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
1069 * 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
1070 * 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
1071 * this is hardly a problem.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1072 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1073 s_button_pending = button;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1074 s_x_pending = x;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1075 s_y_pending = y;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1076 s_kFlags_pending = keyFlags;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1077 }
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 s_prevTime = currentTime;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1080 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1081 }
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 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1084 _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
1085 HWND hwnd UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1086 int x,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1087 int y,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1088 UINT keyFlags)
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 int button;
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 s_getting_focus = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1093 if (s_button_pending > -1)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1094 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1095 // Delayed action for mouse down event
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1096 _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
1097 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
1098 s_button_pending = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1099 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1100 if (s_uMsg == WM_MOUSEMOVE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1101 {
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 * 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
1104 * down.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1105 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1106 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
1107 | MK_XBUTTON1 | MK_XBUTTON2)))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1108 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1109 gui_mouse_moved(x, y);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1110 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1111 }
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1114 * 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
1115 * the mouse goes outside the window
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1116 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1117 SetCapture(s_textArea);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1118 button = MOUSE_DRAG;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1119 // TRACE(" move at x %d, y %d\n", x, y);
8140
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 else
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 ReleaseCapture();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1124 button = MOUSE_RELEASE;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1125 // TRACE(" up at x %d, y %d\n", x, y);
8140
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1128 _OnMouseEvent(button, x, y, FALSE, keyFlags);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1129 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1130
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1131 static void
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1132 _OnSizeTextArea(
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1133 HWND hwnd UNUSED,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1134 UINT state UNUSED,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1135 int cx UNUSED,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1136 int cy UNUSED)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1137 {
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1138 #if defined(FEAT_DIRECTX)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1139 if (IS_ENABLE_DIRECTX())
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1140 directx_binddc();
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1141 #endif
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1142 }
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1143
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1144 #ifdef FEAT_MENU
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 * 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
1147 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1148 static vimmenu_T *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1149 gui_mswin_find_menu(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1150 vimmenu_T *pMenu,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1151 int id)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1152 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1153 vimmenu_T *pChildMenu;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1154
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1155 while (pMenu)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1156 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1157 if (pMenu->id == (UINT)id)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1158 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1159 if (pMenu->children != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1160 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1161 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
1162 if (pChildMenu)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1163 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1164 pMenu = pChildMenu;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1165 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1166 }
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 pMenu = pMenu->next;
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 return pMenu;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1171 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1172
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1173 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1174 _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
1175 HWND hwnd UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1176 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
1177 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
1178 UINT codeNotify UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1179 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1180 vimmenu_T *pMenu;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1181
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1182 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
1183 if (pMenu)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1184 gui_menu_cb(pMenu);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1185 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1186 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1187
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1188 #ifdef MSWIN_FIND_REPLACE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1189 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1190 * Handle a Find/Replace window message.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1191 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1192 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1193 _OnFindRepl(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1194 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1195 int flags = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1196 int down;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1197
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1198 if (s_findrep_struct.Flags & FR_DIALOGTERM)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1199 // Give main window the focus back.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1200 (void)SetFocus(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1201
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1202 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
1203 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1204 flags = FRD_FINDNEXT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1205
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1206 // Give main window the focus back: this is so the cursor isn't
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1207 // hollow.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1208 (void)SetFocus(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1209 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1210 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
1211 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1212 flags = FRD_REPLACE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1213
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1214 // Give main window the focus back: this is so the cursor isn't
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1215 // hollow.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1216 (void)SetFocus(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1217 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1218 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
1219 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1220 flags = FRD_REPLACEALL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1221 }
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 if (flags != 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1224 {
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1225 char_u *p, *q;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1226
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1227 // Call the generic GUI function to do the actual work.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1228 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
1229 flags |= FRD_WHOLE_WORD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1230 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
1231 flags |= FRD_MATCH_CASE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1232 down = (s_findrep_struct.Flags & FR_DOWN) != 0;
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1233 p = utf16_to_enc(s_findrep_struct.lpstrFindWhat, NULL);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1234 q = utf16_to_enc(s_findrep_struct.lpstrReplaceWith, NULL);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1235 if (p != NULL && q != NULL)
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1236 gui_do_findrepl(flags, p, q, down);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1237 vim_free(p);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1238 vim_free(q);
8140
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 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1241 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1242
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1243 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1244 HandleMouseHide(UINT uMsg, LPARAM lParam)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1245 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1246 static LPARAM last_lParam = 0L;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1247
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1248 // We sometimes get a mousemove when the mouse didn't move...
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1249 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
1250 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1251 if (lParam == last_lParam)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1252 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1253 last_lParam = lParam;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1254 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1255
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1256 // Handle specially, to centralise coding. We need to be sure we catch all
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1257 // possible events which should cause us to restore the cursor (as it is a
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1258 // shared resource, we take full responsibility for it).
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1259 switch (uMsg)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1260 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1261 case WM_KEYUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1262 case WM_CHAR:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1263 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1264 * blank out the pointer if necessary
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1265 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1266 if (p_mh)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1267 gui_mch_mousehide(TRUE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1268 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1269
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1270 case WM_SYSKEYUP: // show the pointer when a system-key is pressed
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1271 case WM_SYSCHAR:
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1272 case WM_MOUSEMOVE: // show the pointer on any mouse action
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1273 case WM_LBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1274 case WM_LBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1275 case WM_MBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1276 case WM_MBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1277 case WM_RBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1278 case WM_RBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1279 case WM_XBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1280 case WM_XBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1281 case WM_NCMOUSEMOVE:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1282 case WM_NCLBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1283 case WM_NCLBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1284 case WM_NCMBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1285 case WM_NCMBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1286 case WM_NCRBUTTONDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1287 case WM_NCRBUTTONUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1288 case WM_KILLFOCUS:
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 * 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
1291 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1292 gui_mch_mousehide(FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1293 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1294 }
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1297 static LRESULT CALLBACK
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1298 _TextAreaWndProc(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1299 HWND hwnd,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1300 UINT uMsg,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1301 WPARAM wParam,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1302 LPARAM lParam)
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1305 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
1306 hwnd, uMsg, wParam, lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1307 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1308
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1309 HandleMouseHide(uMsg, lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1310
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1311 s_uMsg = uMsg;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1312 s_wParam = wParam;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1313 s_lParam = lParam;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1314
12871
1a450ce6980c patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents: 12802
diff changeset
1315 #ifdef FEAT_BEVAL_GUI
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
1316 track_user_activity(uMsg);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1317 #endif
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 switch (uMsg)
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 HANDLE_MSG(hwnd, WM_LBUTTONDBLCLK,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1322 HANDLE_MSG(hwnd, WM_LBUTTONDOWN,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1323 HANDLE_MSG(hwnd, WM_LBUTTONUP, _OnMouseMoveOrRelease);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1324 HANDLE_MSG(hwnd, WM_MBUTTONDBLCLK,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1325 HANDLE_MSG(hwnd, WM_MBUTTONDOWN,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1326 HANDLE_MSG(hwnd, WM_MBUTTONUP, _OnMouseMoveOrRelease);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1327 HANDLE_MSG(hwnd, WM_MOUSEMOVE, _OnMouseMoveOrRelease);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1328 HANDLE_MSG(hwnd, WM_PAINT, _OnPaint);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1329 HANDLE_MSG(hwnd, WM_RBUTTONDBLCLK,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1330 HANDLE_MSG(hwnd, WM_RBUTTONDOWN,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1331 HANDLE_MSG(hwnd, WM_RBUTTONUP, _OnMouseMoveOrRelease);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1332 HANDLE_MSG(hwnd, WM_XBUTTONDBLCLK,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1333 HANDLE_MSG(hwnd, WM_XBUTTONDOWN,_OnMouseButtonDown);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1334 HANDLE_MSG(hwnd, WM_XBUTTONUP, _OnMouseMoveOrRelease);
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1335 HANDLE_MSG(hwnd, WM_SIZE, _OnSizeTextArea);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1336
12871
1a450ce6980c patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents: 12802
diff changeset
1337 #ifdef FEAT_BEVAL_GUI
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1338 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
1339 return TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1340 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1341 default:
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
1342 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
1343 }
8140
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1346 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1347 * 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
1348 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1349 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1350 gui_mch_new_colors(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1351 {
18617
5beda1754026 patch 8.1.2301: MS-Windows GUI: drawing error when background color changes
Bram Moolenaar <Bram@vim.org>
parents: 18526
diff changeset
1352 HBRUSH prevBrush;
5beda1754026 patch 8.1.2301: MS-Windows GUI: drawing error when background color changes
Bram Moolenaar <Bram@vim.org>
parents: 18526
diff changeset
1353
5beda1754026 patch 8.1.2301: MS-Windows GUI: drawing error when background color changes
Bram Moolenaar <Bram@vim.org>
parents: 18526
diff changeset
1354 s_brush = CreateSolidBrush(gui.back_pixel);
5beda1754026 patch 8.1.2301: MS-Windows GUI: drawing error when background color changes
Bram Moolenaar <Bram@vim.org>
parents: 18526
diff changeset
1355 prevBrush = (HBRUSH)SetClassLongPtr(
5beda1754026 patch 8.1.2301: MS-Windows GUI: drawing error when background color changes
Bram Moolenaar <Bram@vim.org>
parents: 18526
diff changeset
1356 s_hwnd, GCLP_HBRBACKGROUND, (LONG_PTR)s_brush);
5beda1754026 patch 8.1.2301: MS-Windows GUI: drawing error when background color changes
Bram Moolenaar <Bram@vim.org>
parents: 18526
diff changeset
1357 InvalidateRect(s_hwnd, NULL, TRUE);
5beda1754026 patch 8.1.2301: MS-Windows GUI: drawing error when background color changes
Bram Moolenaar <Bram@vim.org>
parents: 18526
diff changeset
1358 DeleteObject(prevBrush);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1359 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1360
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1361 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1362 * 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
1363 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1364 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1365 gui_mch_def_colors(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1366 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1367 gui.norm_pixel = GetSysColor(COLOR_WINDOWTEXT);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1368 gui.back_pixel = GetSysColor(COLOR_WINDOW);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1369 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
1370 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
1371 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1372
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 * 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
1375 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1376 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1377 gui_mch_open(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1378 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1379 // Actually open the window, if not already visible
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1380 // (may be done already in gui_mch_set_shellsize)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1381 if (!IsWindowVisible(s_hwnd))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1382 ShowWindow(s_hwnd, SW_SHOWDEFAULT);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1383
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1384 #ifdef MSWIN_FIND_REPLACE
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1385 // Init replace string here, so that we keep it when re-opening the
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1386 // dialog.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1387 s_findrep_struct.lpstrReplaceWith[0] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1388 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1389
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1390 return OK;
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1394 * 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
1395 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1396 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1397 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
1398 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1399 RECT rect;
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 GetWindowRect(s_hwnd, &rect);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1402 *x = rect.left;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1403 *y = rect.top;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1404 return OK;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1405 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1406
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1407 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1408 * 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
1409 * coordinates.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1410 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1411 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1412 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
1413 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1414 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
1415 SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1416 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1417 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1418 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
1419 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1420 static int oldx = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1421 static int oldy = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1422
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1423 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
1424
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1425 #ifdef FEAT_TOOLBAR
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1426 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
1427 SendMessage(s_toolbarhwnd, WM_SIZE,
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1428 (WPARAM)0, MAKELPARAM(w, gui.toolbar_height));
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1429 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1430 #if defined(FEAT_GUI_TABLINE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1431 if (showing_tabline)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1432 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1433 int top = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1434 RECT rect;
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 # ifdef FEAT_TOOLBAR
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1437 if (vim_strchr(p_go, GO_TOOLBAR) != NULL)
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1438 top = gui.toolbar_height;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1439 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1440 GetClientRect(s_hwnd, &rect);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1441 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
1442 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1443 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1444
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1445 // When side scroll bar is unshown, the size of window will change.
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1446 // then, the text area move left or right. thus client rect should be
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1447 // forcedly redrawn. (Yasuhiro Matsumoto)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1448 if (oldx != x || oldy != y)
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 InvalidateRect(s_hwnd, NULL, FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1451 oldx = x;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1452 oldy = y;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1453 }
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
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1458 * Scrollbar stuff:
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 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1462 gui_mch_enable_scrollbar(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1463 scrollbar_T *sb,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1464 int flag)
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 ShowScrollBar(sb->id, SB_CTL, flag);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1467
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1468 // TODO: When the window is maximized, the size of the window stays the
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1469 // same, thus the size of the text area changes. On Win98 it's OK, on Win
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1470 // NT 4.0 it's not...
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1471 }
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 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1474 gui_mch_set_scrollbar_pos(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1475 scrollbar_T *sb,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1476 int x,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1477 int y,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1478 int w,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1479 int h)
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 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
1482 SWP_NOZORDER | SWP_NOACTIVATE | SWP_SHOWWINDOW);
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
21355
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1485 int
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1486 gui_mch_get_scrollbar_xpadding(void)
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1487 {
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1488 RECT rcTxt, rcWnd;
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1489 int xpad;
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1490
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1491 GetWindowRect(s_textArea, &rcTxt);
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1492 GetWindowRect(s_hwnd, &rcWnd);
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1493 xpad = rcWnd.right - rcTxt.right - gui.scrollbar_width
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1494 - pGetSystemMetricsForDpi(SM_CXFRAME, s_dpi)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1495 - pGetSystemMetricsForDpi(SM_CXPADDEDBORDER, s_dpi);
21355
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1496 return (xpad < 0) ? 0 : xpad;
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1497 }
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1498
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1499 int
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1500 gui_mch_get_scrollbar_ypadding(void)
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1501 {
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1502 RECT rcTxt, rcWnd;
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1503 int ypad;
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1504
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1505 GetWindowRect(s_textArea, &rcTxt);
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1506 GetWindowRect(s_hwnd, &rcWnd);
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1507 ypad = rcWnd.bottom - rcTxt.bottom - gui.scrollbar_height
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1508 - pGetSystemMetricsForDpi(SM_CYFRAME, s_dpi)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1509 - pGetSystemMetricsForDpi(SM_CXPADDEDBORDER, s_dpi);
21355
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1510 return (ypad < 0) ? 0 : ypad;
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1511 }
fcccc29bd386 patch 8.2.1228: scrollbars not flush against the window edges when maximised
Bram Moolenaar <Bram@vim.org>
parents: 21351
diff changeset
1512
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1513 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1514 gui_mch_create_scrollbar(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1515 scrollbar_T *sb,
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1516 int orient) // SBAR_VERT or SBAR_HORIZ
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1517 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1518 sb->id = CreateWindow(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1519 "SCROLLBAR", "Scrollbar",
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1520 WS_CHILD | ((orient == SBAR_VERT) ? SBS_VERT : SBS_HORZ), 0, 0,
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1521 10, // Any value will do for now
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1522 10, // Any value will do for now
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1523 s_hwnd, NULL,
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
1524 g_hinst, NULL);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1525 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1526
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1527 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1528 * 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
1529 */
21351
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
1530 static scrollbar_T *
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1531 gui_mswin_find_scrollbar(HWND hwnd)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1532 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1533 win_T *wp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1534
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1535 if (gui.bottom_sbar.id == hwnd)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1536 return &gui.bottom_sbar;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1537 FOR_ALL_WINDOWS(wp)
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 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
1540 return &wp->w_scrollbars[SBAR_LEFT];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1541 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
1542 return &wp->w_scrollbars[SBAR_RIGHT];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1543 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1544 return NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1545 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1546
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1547 static void
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1548 update_scrollbar_size(void)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1549 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1550 gui.scrollbar_width = pGetSystemMetricsForDpi(SM_CXVSCROLL, s_dpi);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1551 gui.scrollbar_height = pGetSystemMetricsForDpi(SM_CYHSCROLL, s_dpi);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1552 }
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1553
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1554 /*
27332
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1555 * Get the average character size of a font.
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1556 */
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1557 static void
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1558 GetAverageFontSize(HDC hdc, SIZE *size)
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1559 {
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1560 // GetTextMetrics() may not return the right value in tmAveCharWidth
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1561 // for some fonts. Do our own average computation.
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1562 GetTextExtentPoint(hdc,
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1563 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1564 52, size);
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1565 size->cx = (size->cx / 26 + 1) / 2;
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1566 }
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1567
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1568 /*
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1569 * 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
1570 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1571 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1572 GetFontSize(GuiFont font)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1573 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1574 HWND hwnd = GetDesktopWindow();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1575 HDC hdc = GetWindowDC(hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1576 HFONT hfntOld = SelectFont(hdc, (HFONT)font);
16582
9a7d98e11954 patch 8.1.1294: MS-Windows: Some fonts return wrong average char width
Bram Moolenaar <Bram@vim.org>
parents: 16468
diff changeset
1577 SIZE size;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1578 TEXTMETRIC tm;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1579
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1580 GetTextMetrics(hdc, &tm);
27332
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1581 GetAverageFontSize(hdc, &size);
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1582
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
1583 gui.char_width = size.cx + tm.tmOverhang;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1584 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
1585
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1586 SelectFont(hdc, hfntOld);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1587
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1588 ReleaseDC(hwnd, hdc);
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1592 * 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
1593 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1594 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1595 gui_mch_adjust_charheight(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1596 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1597 GetFontSize(gui.norm_font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1598 return OK;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1599 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1600
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1601 static GuiFont
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
1602 get_font_handle(LOGFONTW *lf)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1603 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1604 HFONT font = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1605
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1606 // Load the font
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
1607 font = CreateFontIndirectW(lf);
8140
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 if (font == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1610 return NOFONT;
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 return (GuiFont)font;
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1615 static int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1616 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
1617 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1618 int points;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1619 HWND hwnd;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1620 HDC hdc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1621
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1622 hwnd = GetDesktopWindow();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1623 hdc = GetWindowDC(hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1624
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1625 points = MulDiv(pixels, 72,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1626 GetDeviceCaps(hdc, vertical ? LOGPIXELSY : LOGPIXELSX));
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1627
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1628 ReleaseDC(hwnd, hdc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1629
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1630 return points;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1631 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1632
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1633 GuiFont
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1634 gui_mch_get_font(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1635 char_u *name,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1636 int giveErrorIfMissing)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1637 {
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
1638 LOGFONTW lf;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1639 GuiFont font = NOFONT;
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 if (get_logfont(&lf, name, NULL, giveErrorIfMissing) == OK)
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1642 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1643 lf.lfHeight = adjust_fontsize_by_dpi(lf.lfHeight);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1644 font = get_font_handle(&lf);
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
1645 }
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1646 if (font == NOFONT && giveErrorIfMissing)
26865
bce848ec8b1b patch 8.2.3961: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26771
diff changeset
1647 semsg(_(e_unknown_font_str), name);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1648 return font;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1649 }
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 #if defined(FEAT_EVAL) || defined(PROTO)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1652 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1653 * 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
1654 * 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
1655 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1656 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
1657 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
1658 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1659 if (name == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1660 return NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1661 return vim_strsave(name);
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 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1664
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1665 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1666 gui_mch_free_font(GuiFont font)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1667 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1668 if (font)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1669 DeleteObject((HFONT)font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1670 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1671
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1672 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1673 * 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
1674 * Return INVALCOLOR for error.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1675 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1676 guicolor_T
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1677 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
1678 {
9017
7b1200ea03a1 commit https://github.com/vim/vim/commit/c285fe7c3ffdb3ec4eff20a1d1d5accfc80f1a86
Christian Brabandt <cb@256bit.org>
parents: 9013
diff changeset
1679 int i;
8140
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 typedef struct SysColorTable
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1682 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1683 char *name;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1684 int color;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1685 } SysColorTable;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1686
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1687 static SysColorTable sys_table[] =
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1688 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1689 {"SYS_3DDKSHADOW", COLOR_3DDKSHADOW},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1690 {"SYS_3DHILIGHT", COLOR_3DHILIGHT},
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1691 #ifdef COLOR_3DHIGHLIGHT
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1692 {"SYS_3DHIGHLIGHT", COLOR_3DHIGHLIGHT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1693 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1694 {"SYS_BTNHILIGHT", COLOR_BTNHILIGHT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1695 {"SYS_BTNHIGHLIGHT", COLOR_BTNHIGHLIGHT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1696 {"SYS_3DLIGHT", COLOR_3DLIGHT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1697 {"SYS_3DSHADOW", COLOR_3DSHADOW},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1698 {"SYS_DESKTOP", COLOR_DESKTOP},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1699 {"SYS_INFOBK", COLOR_INFOBK},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1700 {"SYS_INFOTEXT", COLOR_INFOTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1701 {"SYS_3DFACE", COLOR_3DFACE},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1702 {"SYS_BTNFACE", COLOR_BTNFACE},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1703 {"SYS_BTNSHADOW", COLOR_BTNSHADOW},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1704 {"SYS_ACTIVEBORDER", COLOR_ACTIVEBORDER},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1705 {"SYS_ACTIVECAPTION", COLOR_ACTIVECAPTION},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1706 {"SYS_APPWORKSPACE", COLOR_APPWORKSPACE},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1707 {"SYS_BACKGROUND", COLOR_BACKGROUND},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1708 {"SYS_BTNTEXT", COLOR_BTNTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1709 {"SYS_CAPTIONTEXT", COLOR_CAPTIONTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1710 {"SYS_GRAYTEXT", COLOR_GRAYTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1711 {"SYS_HIGHLIGHT", COLOR_HIGHLIGHT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1712 {"SYS_HIGHLIGHTTEXT", COLOR_HIGHLIGHTTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1713 {"SYS_INACTIVEBORDER", COLOR_INACTIVEBORDER},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1714 {"SYS_INACTIVECAPTION", COLOR_INACTIVECAPTION},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1715 {"SYS_INACTIVECAPTIONTEXT", COLOR_INACTIVECAPTIONTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1716 {"SYS_MENU", COLOR_MENU},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1717 {"SYS_MENUTEXT", COLOR_MENUTEXT},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1718 {"SYS_SCROLLBAR", COLOR_SCROLLBAR},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1719 {"SYS_WINDOW", COLOR_WINDOW},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1720 {"SYS_WINDOWFRAME", COLOR_WINDOWFRAME},
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1721 {"SYS_WINDOWTEXT", COLOR_WINDOWTEXT}
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1722 };
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1725 * 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
1726 */
29113
495d55210aac patch 8.2.5077: various warnings from clang on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 29105
diff changeset
1727 for (i = 0; i < (int)ARRAY_LENGTH(sys_table); i++)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1728 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
1729 return GetSysColor(sys_table[i].color);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1730
9013
22c29a515b53 commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents: 8835
diff changeset
1731 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
1732 }
9017
7b1200ea03a1 commit https://github.com/vim/vim/commit/c285fe7c3ffdb3ec4eff20a1d1d5accfc80f1a86
Christian Brabandt <cb@256bit.org>
parents: 9013
diff changeset
1733
11745
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11410
diff changeset
1734 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
1735 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
1736 {
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11410
diff changeset
1737 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
1738 }
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 11410
diff changeset
1739
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1740 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1741 * 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
1742 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1743 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1744 gui_mch_haskey(char_u *name)
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 int i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1747
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1748 for (i = 0; special_keys[i].vim_code1 != NUL; i++)
28639
8ea5468f9b5a patch 8.2.4843: treating CTRL + ALT as AltGr is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 28586
diff changeset
1749 if (name[0] == special_keys[i].vim_code0
8ea5468f9b5a patch 8.2.4843: treating CTRL + ALT as AltGr is not backwards compatible
Bram Moolenaar <Bram@vim.org>
parents: 28586
diff changeset
1750 && name[1] == special_keys[i].vim_code1)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1751 return OK;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1752 return FAIL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1753 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1754
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1755 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1756 gui_mch_beep(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1757 {
28439
16bd027b039e patch 8.2.4744: a terminal window can't use the bell
Bram Moolenaar <Bram@vim.org>
parents: 28411
diff changeset
1758 MessageBeep((UINT)-1);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1759 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1760 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1761 * 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
1762 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1763 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1764 gui_mch_invert_rectangle(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1765 int r,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1766 int c,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1767 int nr,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1768 int nc)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1769 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1770 RECT rc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1771
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1772 #if defined(FEAT_DIRECTX)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1773 if (IS_ENABLE_DIRECTX())
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1774 DWriteContext_Flush(s_dwc);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1775 #endif
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1776
8140
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 * 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
1779 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1780 rc.left = FILL_X(c);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1781 rc.top = FILL_Y(r);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1782 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
1783 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
1784 InvertRect(s_hdc, &rc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1785 }
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 * Iconify the GUI window.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1789 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1790 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1791 gui_mch_iconify(void)
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 ShowWindow(s_hwnd, SW_MINIMIZE);
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1797 * Draw a cursor without focus.
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 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1800 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
1801 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1802 HBRUSH hbr;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1803 RECT rc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1804
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1805 #if defined(FEAT_DIRECTX)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1806 if (IS_ENABLE_DIRECTX())
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1807 DWriteContext_Flush(s_dwc);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1808 #endif
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1809
8140
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 * 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
1812 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1813 rc.left = FILL_X(gui.col);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1814 rc.top = FILL_Y(gui.row);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1815 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
1816 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
1817 rc.right += gui.char_width;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1818 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
1819 hbr = CreateSolidBrush(color);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1820 FrameRect(s_hdc, &rc, hbr);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1821 DeleteBrush(hbr);
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1824 * 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
1825 * color "color".
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1826 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1827 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1828 gui_mch_draw_part_cursor(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1829 int w,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1830 int h,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1831 guicolor_T color)
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 RECT rc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1834
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 * 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
1837 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1838 rc.left =
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1839 #ifdef FEAT_RIGHTLEFT
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1840 // vertical line should be on the right of current point
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1841 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
1842 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1843 FILL_X(gui.col);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1844 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
1845 rc.right = rc.left + w;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1846 rc.bottom = rc.top + h;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
1847
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
1848 fill_rect(&rc, NULL, color);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1849 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1850
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1851
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 * 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
1854 * 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
1855 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1856 static void
29491
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1857 outputDeadKey_rePost_Ex(MSG originalMsg, int dead_key2set)
8140
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 static MSG deadCharExpel;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1860
29491
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1861 if (dead_key == DEAD_KEY_OFF)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1862 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1863
29491
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1864 dead_key = dead_key2set;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1865
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1866 // Make Windows generate the dead key's character
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1867 deadCharExpel.message = originalMsg.message;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1868 deadCharExpel.hwnd = originalMsg.hwnd;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1869 deadCharExpel.wParam = VK_SPACE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1870
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
1871 TranslateMessage(&deadCharExpel);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1872
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1873 // re-generate the current character free of the dead char influence
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1874 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
1875 originalMsg.lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1876 }
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 /*
29491
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1879 * Wrapper for outputDeadKey_rePost_Ex which always reset dead_key value.
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1880 */
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1881 static void
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1882 outputDeadKey_rePost(MSG originalMsg)
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1883 {
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1884 outputDeadKey_rePost_Ex(originalMsg, DEAD_KEY_OFF);
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1885 }
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1886
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1887 /*
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1888 * Process a single Windows message.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1889 * 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
1890 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1891 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1892 process_message(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1893 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1894 MSG msg;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1895 UINT vk = 0; // Virtual key
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1896 char_u string[40];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1897 int i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1898 int modifiers = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1899 int key;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1900 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1901 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
1902 #endif
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
1903 BYTE keyboard_state[256];
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1904
27283
b4d92a69035b patch 8.2.4170: MS-Windows: still using old message API calls
Bram Moolenaar <Bram@vim.org>
parents: 27281
diff changeset
1905 GetMessageW(&msg, NULL, 0, 0);
8140
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 #ifdef FEAT_OLE
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1908 // Look after OLE Automation commands
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1909 if (msg.message == WM_OLE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1910 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1911 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
1912 if (str == NULL || *str == NUL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1913 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1914 // Message can't be ours, forward it. Fixes problem with Ultramon
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1915 // 3.0.4
27283
b4d92a69035b patch 8.2.4170: MS-Windows: still using old message API calls
Bram Moolenaar <Bram@vim.org>
parents: 27281
diff changeset
1916 DispatchMessageW(&msg);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1917 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1918 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1919 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1920 add_to_input_buf(str, (int)STRLEN(str));
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1921 vim_free(str); // was allocated in CVim::SendKeys()
8140
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 return;
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 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1926
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1927 #ifdef MSWIN_FIND_REPLACE
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
1928 // Don't process messages used by the dialog
27283
b4d92a69035b patch 8.2.4170: MS-Windows: still using old message API calls
Bram Moolenaar <Bram@vim.org>
parents: 27281
diff changeset
1929 if (s_findrep_hwnd != NULL && IsDialogMessageW(s_findrep_hwnd, &msg))
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1930 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1931 HandleMouseHide(msg.message, msg.lParam);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1932 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1933 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1934 #endif
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1937 * 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
1938 * TranslateMessage().
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1939 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1940 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
1941 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1942 vk = (int) msg.wParam;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1943
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 * 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
1946 * handle them and do not interfere.
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 * 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
1949 * - 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
1950 * 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
1951 * dead character on its own)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1952 *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1953 * - 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
1954 * expel the dead character as this could trigger an infinite loop if
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
1955 * for some reason TranslateMessage() do not trigger a call
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1956 * immediately to _OnChar() (or _OnSysChar()).
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1957 */
29491
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1958
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1959 /*
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1960 * We are at the moment after WM_CHAR with DEAD_KEY_SKIP_ON_CHAR event
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1961 * was handled by _WndProc, this keypress we want to process normally
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1962 */
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1963 if (dead_key == DEAD_KEY_SKIP_ON_CHAR)
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1964 dead_key = DEAD_KEY_OFF;
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1965
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1966 if (dead_key != DEAD_KEY_OFF)
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1967 {
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1968 /*
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1969 * Expell the dead key pressed with Ctrl in a special way.
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1970 *
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1971 * After dead key was pressed with Ctrl in some cases, ESC was
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1972 * artificially injected and handled by _OnChar(), now we are
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1973 * dealing with completely new key press from the user. If we don't
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1974 * do anything, ToUnicode() call will interpret this vk+scan_code
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1975 * under influence of "dead-modifier". To prevent this we translate
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1976 * this message replacing current char from user with VK_SPACE,
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1977 * which will cause WM_CHAR with dead_key's character itself. Using
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1978 * DEAD_KEY_SKIP_ON_CHAR value of dead_char we force _OnChar() to
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1979 * ignore this one WM_CHAR event completely. Afterwards (due to
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1980 * usage of PostMessage), this procedure is scheduled to be called
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1981 * again with user char and on next entry we will clean
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1982 * DEAD_KEY_SKIP_ON_CHAR. We cannot use original
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1983 * outputDeadKey_rePost() since we do not wish to reset dead_key
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1984 * value.
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1985 */
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1986 if (dead_key == DEAD_KEY_TRANSIENT_IN_ON_CHAR)
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1987 {
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1988 outputDeadKey_rePost_Ex(msg,
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1989 /*dead_key2set=*/DEAD_KEY_SKIP_ON_CHAR);
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1990 return;
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1991 }
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1992
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1993 if (dead_key != DEAD_KEY_SET_DEFAULT)
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1994 {
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1995 // should never happen - is there a way to make ASSERT here?
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1996 return;
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1997 }
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
1998
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
1999 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2000 * 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
2001 * 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
2002 * 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
2003 * handle it.
28586
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
2004 *
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
2005 * Note that VK_SPACE combines with the dead_key's character and
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
2006 * only one WM_CHAR will be generated by TranslateMessage(), in
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
2007 * the two other cases two WM_CHAR will be generated: the dead
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
2008 * char and VK_BACK or VK_ESCAPE. That is most likely what the
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
2009 * user expects.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2010 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2011 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
2012 {
29491
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2013 dead_key = DEAD_KEY_OFF;
28586
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
2014 TranslateMessage(&msg);
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
2015 return;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2016 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2017 // In modes where we are not typing, dead keys should behave
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2018 // normally
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 28755
diff changeset
2019 else if ((get_real_state()
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 28755
diff changeset
2020 & (MODE_INSERT | MODE_CMDLINE | MODE_SELECT)) == 0)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2021 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2022 outputDeadKey_rePost(msg);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2023 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2024 }
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
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2027 // Check for CTRL-BREAK
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2028 if (vk == VK_CANCEL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2029 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2030 trash_input_buf();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2031 got_int = TRUE;
12066
8ad282dee649 patch 8.0.0913: MS-Windows: CTRL-C kills shell in terminal window
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
2032 ctrl_break_was_pressed = TRUE;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2033 string[0] = Ctrl_C;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2034 add_to_input_buf(string, 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2035 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2036
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2037 // This is an IME event or a synthetic keystroke, let Windows handle it.
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2038 if (vk == VK_PROCESSKEY || vk == VK_PACKET)
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2039 {
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2040 TranslateMessage(&msg);
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2041 return;
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2042 }
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2043
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2044 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
2045 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2046 // ignore VK_SPACE when ALT key pressed: system menu
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2047 if (special_keys[i].key_sym == vk
29558
b14fe28768c0 patch 9.0.0120: MS-Windows GUI: cannot use AltGr + Space
Bram Moolenaar <Bram@vim.org>
parents: 29491
diff changeset
2048 && (vk != VK_SPACE || !(GetKeyState(VK_MENU) & 0x8000)))
8140
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 /*
9252
c25898cc99c1 commit https://github.com/vim/vim/commit/945ec093cd4ddefab930239990564b12eb232153
Christian Brabandt <cb@256bit.org>
parents: 9236
diff changeset
2051 * 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
2052 * 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
2053 * 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
2054 * the TAB key, etc...).
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2055 */
29558
b14fe28768c0 patch 9.0.0120: MS-Windows GUI: cannot use AltGr + Space
Bram Moolenaar <Bram@vim.org>
parents: 29491
diff changeset
2056 if (dead_key == DEAD_KEY_SET_DEFAULT
b14fe28768c0 patch 9.0.0120: MS-Windows GUI: cannot use AltGr + Space
Bram Moolenaar <Bram@vim.org>
parents: 29491
diff changeset
2057 && (special_keys[i].vim_code0 == 'K'
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2058 || vk == VK_TAB || vk == CAR))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2059 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2060 outputDeadKey_rePost(msg);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2061 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2062 }
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 #ifdef FEAT_MENU
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2065 // Check for <F10>: Windows selects the menu. When <F10> is
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2066 // mapped we want to use the mapping instead.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2067 if (vk == VK_F10
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2068 && gui.menu_is_active
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2069 && 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
2070 NULL, NULL) == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2071 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2072 #endif
28586
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
2073 modifiers = get_active_modifiers();
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2074
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2075 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
2076 key = special_keys[i].vim_code0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2077 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2078 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
2079 special_keys[i].vim_code1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2080 key = simplify_key(key, &modifiers);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2081 if (key == CSI)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2082 key = K_CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2083
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2084 if (modifiers)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2085 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2086 string[0] = CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2087 string[1] = KS_MODIFIER;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2088 string[2] = modifiers;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2089 add_to_input_buf(string, 3);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2090 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2091
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2092 if (IS_SPECIAL(key))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2093 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2094 string[0] = CSI;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2095 string[1] = K_SECOND(key);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2096 string[2] = K_THIRD(key);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2097 add_to_input_buf(string, 3);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2098 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2099 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2100 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2101 int len;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2102
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2103 // Handle "key" as a Unicode character.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2104 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
2105 add_to_input_buf(string, len);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2106 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2107 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2108 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2109 }
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2110
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2111 // Not a special key.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2112 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
2113 {
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2114 WCHAR ch[8];
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2115 int len;
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2116 int i;
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2117 UINT scan_code;
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2118
29283
fed16adfe353 patch 8.2.5159: fix for CTRL-key combinations causes problems
Bram Moolenaar <Bram@vim.org>
parents: 29279
diff changeset
2119 // Construct the state table with only a few modifiers, we don't
fed16adfe353 patch 8.2.5159: fix for CTRL-key combinations causes problems
Bram Moolenaar <Bram@vim.org>
parents: 29279
diff changeset
2120 // really care about the presence of Ctrl/Alt as those modifiers are
fed16adfe353 patch 8.2.5159: fix for CTRL-key combinations causes problems
Bram Moolenaar <Bram@vim.org>
parents: 29279
diff changeset
2121 // handled by Vim separately.
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2122 memset(keyboard_state, 0, 256);
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2123 if (GetKeyState(VK_SHIFT) & 0x8000)
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2124 keyboard_state[VK_SHIFT] = 0x80;
28574
7c96d7924ea5 patch 8.2.4811: Win32 GUI: caps lock doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 28566
diff changeset
2125 if (GetKeyState(VK_CAPITAL) & 0x0001)
7c96d7924ea5 patch 8.2.4811: Win32 GUI: caps lock doesn't work
Bram Moolenaar <Bram@vim.org>
parents: 28566
diff changeset
2126 keyboard_state[VK_CAPITAL] = 0x01;
29283
fed16adfe353 patch 8.2.5159: fix for CTRL-key combinations causes problems
Bram Moolenaar <Bram@vim.org>
parents: 29279
diff changeset
2127 // Alt-Gr is synthesized as Alt + Ctrl.
fed16adfe353 patch 8.2.5159: fix for CTRL-key combinations causes problems
Bram Moolenaar <Bram@vim.org>
parents: 29279
diff changeset
2128 if ((GetKeyState(VK_RMENU) & 0x8000)
fed16adfe353 patch 8.2.5159: fix for CTRL-key combinations causes problems
Bram Moolenaar <Bram@vim.org>
parents: 29279
diff changeset
2129 && (GetKeyState(VK_CONTROL) & 0x8000))
fed16adfe353 patch 8.2.5159: fix for CTRL-key combinations causes problems
Bram Moolenaar <Bram@vim.org>
parents: 29279
diff changeset
2130 {
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2131 keyboard_state[VK_MENU] = 0x80;
29283
fed16adfe353 patch 8.2.5159: fix for CTRL-key combinations causes problems
Bram Moolenaar <Bram@vim.org>
parents: 29279
diff changeset
2132 keyboard_state[VK_CONTROL] = 0x80;
fed16adfe353 patch 8.2.5159: fix for CTRL-key combinations causes problems
Bram Moolenaar <Bram@vim.org>
parents: 29279
diff changeset
2133 }
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2134
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2135 // Translate the virtual key according to the current keyboard
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2136 // layout.
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2137 scan_code = MapVirtualKey(vk, MAPVK_VK_TO_VSC);
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2138 // Convert the scan-code into a sequence of zero or more unicode
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2139 // codepoints.
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2140 // If this is a dead key ToUnicode returns a negative value.
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2141 len = ToUnicode(vk, scan_code, keyboard_state, ch, ARRAY_LENGTH(ch),
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2142 0);
29491
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2143 if (len < 0)
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2144 dead_key = DEAD_KEY_SET_DEFAULT;
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2145
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2146 if (len <= 0)
29491
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2147 {
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2148 if ( dead_key == DEAD_KEY_SET_DEFAULT
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2149 && (GetKeyState(VK_CONTROL) & 0x8000)
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2150 && ( (vk == 221 && scan_code == 26) // AZERTY CTRL+dead_circumflex
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2151 || (vk == 220 && scan_code == 41) // QWERTZ CTRL+dead_circumflex
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2152 )
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2153 )
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2154 {
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2155 // post WM_CHAR='[' - which will be interpreted with CTRL
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2156 // stil hold as ESC
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2157 PostMessageW(msg.hwnd, WM_CHAR, '[', msg.lParam);
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2158 // ask _OnChar() to not touch this state, wait for next key
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2159 // press and maintain knowledge that we are "poisoned" with
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2160 // "dead state"
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2161 dead_key = DEAD_KEY_TRANSIENT_IN_ON_CHAR;
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2162 }
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2163 return;
29491
aeaeb92c2764 patch 9.0.0087: MS-Windows: CTRL-[ on Belgian keyboard does not work like Esc
Bram Moolenaar <Bram@vim.org>
parents: 29442
diff changeset
2164 }
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2165
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2166 // Post the message as TranslateMessage would do.
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2167 if (msg.message == WM_KEYDOWN)
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2168 {
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2169 for (i = 0; i < len; i++)
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2170 PostMessageW(msg.hwnd, WM_CHAR, ch[i], msg.lParam);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2171 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2172 else
28566
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2173 {
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2174 for (i = 0; i < len; i++)
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2175 PostMessageW(msg.hwnd, WM_SYSCHAR, ch[i], msg.lParam);
893251eed714 patch 8.2.4807: processing key eveints in Win32 GUI is not ideal
Bram Moolenaar <Bram@vim.org>
parents: 28439
diff changeset
2176 }
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2177 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2178 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2179 #ifdef FEAT_MBYTE_IME
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2180 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
2181 _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
2182 else if (msg.message == WM_KEYUP && im_get_status())
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2183 // added for non-MS IME (Yasuhiro Matsumoto)
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
2184 TranslateMessage(&msg);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2185 #endif
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 #ifdef FEAT_MENU
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2188 // Check for <F10>: Default effect is to select the menu. When <F10> is
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2189 // mapped we need to stop it here to avoid strange effects (e.g., for the
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2190 // key-up event)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2191 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
2192 NULL, NULL) == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2193 #endif
27283
b4d92a69035b patch 8.2.4170: MS-Windows: still using old message API calls
Bram Moolenaar <Bram@vim.org>
parents: 27281
diff changeset
2194 DispatchMessageW(&msg);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2195 }
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 * 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
2199 * 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
2200 * 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
2201 * immediately.
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 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2204 gui_mch_update(void)
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 MSG msg;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2207
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2208 if (!s_busy_processing)
27283
b4d92a69035b patch 8.2.4170: MS-Windows: still using old message API calls
Bram Moolenaar <Bram@vim.org>
parents: 27281
diff changeset
2209 while (PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2210 && !vim_is_input_buf_full())
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2211 process_message();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2212 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2213
9179
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2214 static void
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2215 remove_any_timer(void)
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2216 {
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2217 MSG msg;
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2218
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2219 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
2220 {
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2221 KillTimer(NULL, s_wait_timer);
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2222
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2223 // Eat spurious WM_TIMER messages
27283
b4d92a69035b patch 8.2.4170: MS-Windows: still using old message API calls
Bram Moolenaar <Bram@vim.org>
parents: 27281
diff changeset
2224 while (PeekMessageW(&msg, s_hwnd, WM_TIMER, WM_TIMER, PM_REMOVE))
9179
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2225 ;
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2226 s_wait_timer = 0;
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2227 }
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2228 }
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2229
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2230 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2231 * 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
2232 * from the keyboard.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2233 * wtime == -1 Wait forever.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2234 * wtime == 0 This should never happen.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2235 * 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
2236 * 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
2237 * or FAIL otherwise.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2238 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2239 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2240 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
2241 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2242 int focus;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2243
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2244 s_timed_out = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2245
15665
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15601
diff changeset
2246 if (wtime >= 0)
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15601
diff changeset
2247 {
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15601
diff changeset
2248 // Don't do anything while processing a (scroll) message.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2249 if (s_busy_processing)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2250 return FAIL;
15665
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15601
diff changeset
2251
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15601
diff changeset
2252 // When called with "wtime" zero, just want one msec.
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
2253 s_wait_timer = SetTimer(NULL, 0, (UINT)(wtime == 0 ? 1 : wtime),
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
2254 _OnTimer);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2255 }
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 allow_scrollbar = TRUE;
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 focus = gui.in_focus;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2260 while (!s_timed_out)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2261 {
17958
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2262 // Stop or start blinking when focus changes
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2263 if (gui.in_focus != focus)
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 if (gui.in_focus)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2266 gui_mch_start_blink();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2267 else
13152
f4c3a7f410f4 patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Christian Brabandt <cb@256bit.org>
parents: 13150
diff changeset
2268 gui_mch_stop_blink(TRUE);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2269 focus = gui.in_focus;
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2272 if (s_need_activate)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2273 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2274 (void)SetForegroundWindow(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2275 s_need_activate = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2276 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2277
9179
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2278 #ifdef FEAT_TIMERS
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2279 did_add_timer = FALSE;
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2280 #endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2281 #ifdef MESSAGE_QUEUE
17958
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2282 // Check channel I/O while waiting for a message.
8222
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2283 for (;;)
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2284 {
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2285 MSG msg;
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2286
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2287 parse_queued_messages();
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2288 # ifdef FEAT_TIMERS
17958
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2289 if (did_add_timer)
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2290 break;
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2291 # endif
27283
b4d92a69035b patch 8.2.4170: MS-Windows: still using old message API calls
Bram Moolenaar <Bram@vim.org>
parents: 27281
diff changeset
2292 if (PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE))
12090
c4caf49c8bf4 patch 8.0.0925: MS-Windows GUI: channel I/O not handled right away
Christian Brabandt <cb@256bit.org>
parents: 12066
diff changeset
2293 {
c4caf49c8bf4 patch 8.0.0925: MS-Windows GUI: channel I/O not handled right away
Christian Brabandt <cb@256bit.org>
parents: 12066
diff changeset
2294 process_message();
8222
4f0677020a43 commit https://github.com/vim/vim/commit/9186a276222ea8a7c88f4092ac5b4201381f4e20
Christian Brabandt <cb@256bit.org>
parents: 8172
diff changeset
2295 break;
12090
c4caf49c8bf4 patch 8.0.0925: MS-Windows GUI: channel I/O not handled right away
Christian Brabandt <cb@256bit.org>
parents: 12066
diff changeset
2296 }
17958
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2297 else if (input_available()
22922
5d8990ad211e patch 8.2.2008: MS-Windows GUI: handling channel messages lags
Bram Moolenaar <Bram@vim.org>
parents: 22748
diff changeset
2298 // TODO: The 10 msec is a compromise between laggy response
5d8990ad211e patch 8.2.2008: MS-Windows GUI: handling channel messages lags
Bram Moolenaar <Bram@vim.org>
parents: 22748
diff changeset
2299 // and consuming more CPU time. Better would be to handle
5d8990ad211e patch 8.2.2008: MS-Windows GUI: handling channel messages lags
Bram Moolenaar <Bram@vim.org>
parents: 22748
diff changeset
2300 // channel messages when they arrive.
5d8990ad211e patch 8.2.2008: MS-Windows GUI: handling channel messages lags
Bram Moolenaar <Bram@vim.org>
parents: 22748
diff changeset
2301 || MsgWaitForMultipleObjects(0, NULL, FALSE, 10,
17958
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2302 QS_ALLINPUT) != WAIT_TIMEOUT)
12090
c4caf49c8bf4 patch 8.0.0925: MS-Windows GUI: channel I/O not handled right away
Christian Brabandt <cb@256bit.org>
parents: 12066
diff changeset
2303 break;
c4caf49c8bf4 patch 8.0.0925: MS-Windows GUI: channel I/O not handled right away
Christian Brabandt <cb@256bit.org>
parents: 12066
diff changeset
2304 }
c4caf49c8bf4 patch 8.0.0925: MS-Windows GUI: channel I/O not handled right away
Christian Brabandt <cb@256bit.org>
parents: 12066
diff changeset
2305 #else
17958
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2306 // Don't use gui_mch_update() because then we will spin-lock until a
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2307 // char arrives, instead we use GetMessage() to hang until an
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2308 // event arrives. No need to check for input_buf_full because we are
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2309 // returning as soon as it contains a single char -- webb
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2310 process_message();
12090
c4caf49c8bf4 patch 8.0.0925: MS-Windows GUI: channel I/O not handled right away
Christian Brabandt <cb@256bit.org>
parents: 12066
diff changeset
2311 #endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2312
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2313 if (input_available())
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2314 {
9179
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2315 remove_any_timer();
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2316 allow_scrollbar = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2317
17958
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2318 // Clear pending mouse button, the release event may have been
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2319 // taken by the dialog window. But don't do this when getting
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2320 // focus, we need the mouse-up event then.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2321 if (!s_getting_focus)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2322 s_button_pending = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2323
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2324 return OK;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2325 }
9179
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2326
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2327 #ifdef FEAT_TIMERS
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2328 if (did_add_timer)
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2329 {
17958
1d69e11db360 patch 8.1.1975: MS-Windows GUI responds slowly to timer
Bram Moolenaar <Bram@vim.org>
parents: 16827
diff changeset
2330 // Need to recompute the waiting time.
9179
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2331 remove_any_timer();
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2332 break;
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2333 }
5e18efdad322 commit https://github.com/vim/vim/commit/4231da403e3c879dd6ac261e51f4ca60813935e3
Christian Brabandt <cb@256bit.org>
parents: 9017
diff changeset
2334 #endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2335 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2336 allow_scrollbar = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2337 return FAIL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2338 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2339
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2340 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2341 * 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
2342 * (row2, col2) inclusive.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2343 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2344 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2345 gui_mch_clear_block(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2346 int row1,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2347 int col1,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2348 int row2,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2349 int col2)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2350 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2351 RECT rc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2352
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2353 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2354 * 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
2355 * spilled over to the window border.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2356 * 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
2357 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2358 rc.left = FILL_X(col1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2359 rc.top = FILL_Y(row1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2360 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
2361 rc.bottom = FILL_Y(row2 + 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2362 clear_rect(&rc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2363 }
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 * Clear the whole text window.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2367 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2368 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2369 gui_mch_clear_all(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2370 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2371 RECT rc;
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 rc.left = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2374 rc.top = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2375 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
2376 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
2377 clear_rect(&rc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2378 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2379 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2380 * Menu stuff.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2381 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2382
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2383 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2384 gui_mch_enable_menu(int flag)
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 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2387 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
2388 #endif
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2391 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2392 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
2393 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
2394 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
2395 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
2396 int h UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2397 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2398 // It will be in the right place anyway
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2399 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2400
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2401 #if defined(FEAT_MENU) || defined(PROTO)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2402 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2403 * 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
2404 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2405 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2406 gui_mch_menu_hidden(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2407 vimmenu_T *menu,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2408 int hidden)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2409 {
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 * 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
2412 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2413 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2414 if (hidden)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2415 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
2416 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2417 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
2418 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2419 gui_mch_menu_grey(menu, hidden);
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2423 * 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
2424 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2425 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2426 gui_mch_draw_menubar(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2427 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2428 DrawMenuBar(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2429 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2430 #endif // FEAT_MENU
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2431
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2432 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2433 * 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
2434 */
9939
ccb6461b82df commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents: 9834
diff changeset
2435 guicolor_T
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2436 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
2437 {
9939
ccb6461b82df commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents: 9834
diff changeset
2438 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
2439 + GetBValue(pixel));
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2440 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2441
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2442 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2443 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2444 * Convert pixels in X to dialog units
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2445 */
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2446 static WORD
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2447 PixelToDialogX(int numPixels)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2448 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2449 return (WORD)((numPixels * 4) / s_dlgfntwidth);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2450 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2451
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2452 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2453 * Convert pixels in Y to dialog units
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2454 */
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2455 static WORD
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2456 PixelToDialogY(int numPixels)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2457 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2458 return (WORD)((numPixels * 8) / s_dlgfntheight);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2459 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2460
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2461 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2462 * Return the width in pixels of the given text in the given DC.
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2463 */
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2464 static int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2465 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
2466 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2467 SIZE size;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2468
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2469 GetTextExtentPoint(hdc, (LPCSTR)str, len, &size);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2470 return size.cx;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2471 }
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2474 * 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
2475 * of 'encoding' to active codepage conversion.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2476 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2477 static int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2478 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
2479 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2480 SIZE size;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2481 WCHAR *wstr;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2482 int n;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2483 int wlen = len;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2484
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2485 wstr = enc_to_utf16(str, &wlen);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2486 if (wstr == NULL)
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2487 return 0;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2488
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2489 n = GetTextExtentPointW(hdc, wstr, wlen, &size);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2490 vim_free(wstr);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2491 if (n)
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2492 return size.cx;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2493 return 0;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2494 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2495
10438
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2496 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
2497
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2498 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2499 * 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
2500 * 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
2501 * monitors.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2502 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2503 static BOOL
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2504 CenterWindow(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2505 HWND hwndChild,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2506 HWND hwndParent)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2507 {
10438
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2508 HMONITOR mon;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2509 MONITORINFO moninfo;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2510 RECT rChild, rParent, rScreen;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2511 int wChild, hChild, wParent, hParent;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2512 int xNew, yNew;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2513 HDC hdc;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2514
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2515 GetWindowRect(hwndChild, &rChild);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2516 wChild = rChild.right - rChild.left;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2517 hChild = rChild.bottom - rChild.top;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2518
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2519 // If Vim is minimized put the window in the middle of the screen.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2520 if (hwndParent == NULL || IsMinimized(hwndParent))
10438
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2521 get_work_area(&rParent);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2522 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2523 GetWindowRect(hwndParent, &rParent);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2524 wParent = rParent.right - rParent.left;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2525 hParent = rParent.bottom - rParent.top;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2526
10438
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2527 moninfo.cbSize = sizeof(MONITORINFO);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2528 mon = MonitorFromWindow(hwndChild, MONITOR_DEFAULTTOPRIMARY);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2529 if (mon != NULL && GetMonitorInfo(mon, &moninfo))
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2530 {
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2531 rScreen = moninfo.rcWork;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2532 }
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2533 else
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2534 {
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2535 hdc = GetDC(hwndChild);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2536 rScreen.left = 0;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2537 rScreen.top = 0;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2538 rScreen.right = GetDeviceCaps(hdc, HORZRES);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2539 rScreen.bottom = GetDeviceCaps(hdc, VERTRES);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2540 ReleaseDC(hwndChild, hdc);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2541 }
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2542
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2543 xNew = rParent.left + ((wParent - wChild) / 2);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2544 if (xNew < rScreen.left)
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2545 xNew = rScreen.left;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2546 else if ((xNew + wChild) > rScreen.right)
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2547 xNew = rScreen.right - wChild;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2548
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2549 yNew = rParent.top + ((hParent - hChild) / 2);
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2550 if (yNew < rScreen.top)
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2551 yNew = rScreen.top;
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2552 else if ((yNew + hChild) > rScreen.bottom)
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
2553 yNew = rScreen.bottom - hChild;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2554
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2555 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
2556 SWP_NOSIZE | SWP_NOZORDER);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2557 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2558 #endif // FEAT_GUI_DIALOG
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2559
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2560 #if defined(FEAT_TOOLBAR) || defined(PROTO)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2561 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2562 gui_mch_show_toolbar(int showit)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2563 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2564 if (s_toolbarhwnd == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2565 return;
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 if (showit)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2568 {
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2569 // Enable unicode support
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2570 SendMessage(s_toolbarhwnd, TB_SETUNICODEFORMAT, (WPARAM)TRUE,
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2571 (LPARAM)0);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2572 ShowWindow(s_toolbarhwnd, SW_SHOW);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2573 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2574 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2575 ShowWindow(s_toolbarhwnd, SW_HIDE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2576 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2577
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2578 // The number of bitmaps is fixed. Exit is missing!
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
2579 # define TOOLBAR_BITMAP_COUNT 31
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2580
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2581 #endif
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 #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
2584 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2585 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
2586 {
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2587 WCHAR *wn;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2588 MENUITEMINFOW infow;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2589
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2590 wn = enc_to_utf16(item_text, NULL);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2591 if (wn == NULL)
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2592 return;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2593
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2594 infow.cbSize = sizeof(infow);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2595 infow.fMask = MIIM_TYPE | MIIM_ID;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2596 infow.wID = item_id;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2597 infow.fType = MFT_STRING;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2598 infow.dwTypeData = wn;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2599 infow.cch = (UINT)wcslen(wn);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2600 InsertMenuItemW(pmenu, item_id, FALSE, &infow);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2601 vim_free(wn);
8140
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2604 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2605 show_tabline_popup_menu(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2606 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2607 HMENU tab_pmenu;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2608 long rval;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2609 POINT pt;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2610
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2611 // When ignoring events don't show the menu.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2612 if (hold_gui_events
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2613 # ifdef FEAT_CMDWIN
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2614 || cmdwin_type != 0
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2615 # endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2616 )
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2617 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2618
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2619 tab_pmenu = CreatePopupMenu();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2620 if (tab_pmenu == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2621 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2622
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2623 if (first_tabpage->tp_next != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2624 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
2625 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
2626 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
2627 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
2628 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
2629 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
2630
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2631 GetCursorPos(&pt);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2632 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
2633 NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2634
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2635 DestroyMenu(tab_pmenu);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2636
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2637 // Add the string cmd into input buffer
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2638 if (rval > 0)
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 TCHITTESTINFO htinfo;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2641 int idx;
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 (ScreenToClient(s_tabhwnd, &pt) == 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2644 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2645
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2646 htinfo.pt.x = pt.x;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2647 htinfo.pt.y = pt.y;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2648 idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2649 if (idx == -1)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2650 idx = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2651 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2652 idx += 1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2653
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2654 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
2655 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2656 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2657
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2658 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2659 * Show or hide the tabline.
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 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2662 gui_mch_show_tabline(int showit)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2663 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2664 if (s_tabhwnd == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2665 return;
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 if (!showit != !showing_tabline)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2668 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2669 if (showit)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2670 ShowWindow(s_tabhwnd, SW_SHOW);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2671 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2672 ShowWindow(s_tabhwnd, SW_HIDE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2673 showing_tabline = showit;
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 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2676
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 * Return TRUE when tabline is displayed.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2679 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2680 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2681 gui_mch_showing_tabline(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2682 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2683 return s_tabhwnd != NULL && showing_tabline;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2684 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2685
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2686 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2687 * Update the labels of the tabline.
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 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2690 gui_mch_update_tabline(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2691 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2692 tabpage_T *tp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2693 TCITEM tie;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2694 int nr = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2695 int curtabidx = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2696 int tabadded = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2697 WCHAR *wstr = NULL;
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 if (s_tabhwnd == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2700 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2701
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2702 // Enable unicode support
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2703 SendMessage(s_tabhwnd, CCM_SETUNICODEFORMAT, (WPARAM)TRUE, (LPARAM)0);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2704
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2705 tie.mask = TCIF_TEXT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2706 tie.iImage = -1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2707
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2708 // Disable redraw for tab updates to eliminate O(N^2) draws.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2709 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
2710
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2711 // Add a label for each tab page. They all contain the same text area.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2712 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
2713 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2714 if (tp == curtab)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2715 curtabidx = nr;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2716
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2717 if (nr >= TabCtrl_GetItemCount(s_tabhwnd))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2718 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2719 // Add the tab
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2720 tie.pszText = "-Empty-";
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2721 TabCtrl_InsertItem(s_tabhwnd, nr, &tie);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2722 tabadded = 1;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2723 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2724
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2725 get_tabline_label(tp, FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2726 tie.pszText = (LPSTR)NameBuff;
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2727
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2728 wstr = enc_to_utf16(NameBuff, NULL);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2729 if (wstr != NULL)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2730 {
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2731 TCITEMW tiw;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2732
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2733 tiw.mask = TCIF_TEXT;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2734 tiw.iImage = -1;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2735 tiw.pszText = wstr;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2736 SendMessage(s_tabhwnd, TCM_SETITEMW, (WPARAM)nr, (LPARAM)&tiw);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2737 vim_free(wstr);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2738 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2739 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2740
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2741 // Remove any old labels.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2742 while (nr < TabCtrl_GetItemCount(s_tabhwnd))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2743 TabCtrl_DeleteItem(s_tabhwnd, nr);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2744
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2745 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
2746 TabCtrl_SetCurSel(s_tabhwnd, curtabidx);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2747
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2748 // Re-enable redraw and redraw.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2749 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
2750 RedrawWindow(s_tabhwnd, NULL, NULL,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2751 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
2752
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2753 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
2754 TabCtrl_SetCurSel(s_tabhwnd, curtabidx);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2755 }
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2758 * 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
2759 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2760 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2761 gui_mch_set_curtab(int nr)
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 if (s_tabhwnd == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2764 return;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2765
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2766 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
2767 TabCtrl_SetCurSel(s_tabhwnd, nr - 1);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2768 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2769
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2770 #endif
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 * ":simalt" command.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2774 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2775 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2776 ex_simalt(exarg_T *eap)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2777 {
11386
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2778 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
2779 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
2780 char_u key_name[4];
8140
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 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
2783 while (*keys)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2784 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2785 if (*keys == '~')
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2786 *keys = ' '; // for showing system menu
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2787 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
2788 keys++;
11386
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2789 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
2790 }
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2791 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
2792 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2793 // Put a NOP in the typeahead buffer so that the message will get
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2794 // processed.
11386
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2795 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
2796 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
2797 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
2798 key_name[3] = NUL;
18416
59b3d19511d0 patch 8.1.2202: MS-Windows: build failure with GUI and small features
Bram Moolenaar <Bram@vim.org>
parents: 18301
diff changeset
2799 #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL)
11386
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2800 typebuf_was_filled = TRUE;
18416
59b3d19511d0 patch 8.1.2202: MS-Windows: build failure with GUI and small features
Bram Moolenaar <Bram@vim.org>
parents: 18301
diff changeset
2801 #endif
11386
e2b34123c7dc patch 8.0.0578: :simalt on MS-Windows does not work properly
Christian Brabandt <cb@256bit.org>
parents: 11129
diff changeset
2802 (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
2803 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2804 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2805
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2806 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2807 * Create the find & replace dialogs.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2808 * 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
2809 * 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
2810 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2811 #ifdef MSWIN_FIND_REPLACE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2812 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2813 initialise_findrep(char_u *initial_string)
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 int wword = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2816 int mcase = !p_ic;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2817 char_u *entry_text;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2818
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2819 // Get the search string to use.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2820 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
2821
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2822 s_findrep_struct.hwndOwner = s_hwnd;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2823 s_findrep_struct.Flags = FR_DOWN;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2824 if (mcase)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2825 s_findrep_struct.Flags |= FR_MATCHCASE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2826 if (wword)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2827 s_findrep_struct.Flags |= FR_WHOLEWORD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2828 if (entry_text != NULL && *entry_text != NUL)
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2829 {
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2830 WCHAR *p = enc_to_utf16(entry_text, NULL);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2831 if (p != NULL)
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2832 {
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2833 int len = s_findrep_struct.wFindWhatLen - 1;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2834
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2835 wcsncpy(s_findrep_struct.lpstrFindWhat, p, len);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2836 s_findrep_struct.lpstrFindWhat[len] = NUL;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2837 vim_free(p);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2838 }
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2839 }
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2840 vim_free(entry_text);
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 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2843
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2844 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2845 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
2846 {
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2847 if (title != NULL)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2848 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2849 WCHAR *wbuf;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2850
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2851 // Convert the title from 'encoding' to UTF-16.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2852 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
2853 if (wbuf != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2854 {
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
2855 SetWindowTextW(hwnd, wbuf);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2856 vim_free(wbuf);
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
2857 }
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2858 }
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2859 else
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
2860 (void)SetWindowTextW(hwnd, NULL);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2861 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2862
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2863 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2864 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
2865 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2866 #ifdef MSWIN_FIND_REPLACE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2867 if (s_findrep_msg != 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2868 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2869 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
2870 DestroyWindow(s_findrep_hwnd);
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 if (!IsWindow(s_findrep_hwnd))
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 initialise_findrep(eap->arg);
27281
f7d73708b391 patch 8.2.4169: MS-Windows: unnessary casts and other minor things
Bram Moolenaar <Bram@vim.org>
parents: 27261
diff changeset
2875 s_findrep_hwnd = FindTextW(&s_findrep_struct);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2876 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2877
14364
d876b8588731 patch 8.1.0197: Windows GUI: title for search/replace is wrong
Christian Brabandt <cb@256bit.org>
parents: 14208
diff changeset
2878 set_window_title(s_findrep_hwnd, _("Find string"));
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2879 (void)SetFocus(s_findrep_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2880
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2881 s_findrep_is_find = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2882 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2883 #endif
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2886
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2887 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2888 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
2889 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2890 #ifdef MSWIN_FIND_REPLACE
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2891 if (s_findrep_msg != 0)
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 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
2894 DestroyWindow(s_findrep_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2895
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2896 if (!IsWindow(s_findrep_hwnd))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2897 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2898 initialise_findrep(eap->arg);
27281
f7d73708b391 patch 8.2.4169: MS-Windows: unnessary casts and other minor things
Bram Moolenaar <Bram@vim.org>
parents: 27261
diff changeset
2899 s_findrep_hwnd = ReplaceTextW(&s_findrep_struct);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2900 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2901
14364
d876b8588731 patch 8.1.0197: Windows GUI: title for search/replace is wrong
Christian Brabandt <cb@256bit.org>
parents: 14208
diff changeset
2902 set_window_title(s_findrep_hwnd, _("Find & Replace"));
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2903 (void)SetFocus(s_findrep_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2904
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2905 s_findrep_is_find = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2906 }
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2912 * Set visibility of the pointer.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2913 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2914 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2915 gui_mch_mousehide(int hide)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2916 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2917 if (hide != gui.pointer_hidden)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2918 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2919 ShowCursor(!hide);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2920 gui.pointer_hidden = hide;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2921 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2922 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2923
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2924 #ifdef FEAT_MENU
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2925 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2926 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
2927 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2928 // Unhide the mouse, we don't get move events here.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2929 gui_mch_mousehide(FALSE);
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 (void)TrackPopupMenu(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2932 (HMENU)menu->submenu_id,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2933 TPM_LEFTALIGN | TPM_LEFTBUTTON,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2934 x, y,
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2935 (int)0, //reserved param
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2936 s_hwnd,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2937 NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2938 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2939 * 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
2940 * 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
2941 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2942 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2943 #endif
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2946 * 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
2947 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2948 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2949 _OnEndSession(void)
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 getout_preserve_modified(1);
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2955 * 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
2956 * of a Windows95 window.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2957 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2958 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
2959 _OnClose(HWND hwnd UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2960 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2961 gui_shell_closed();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2962 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2963
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2964 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2965 * 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
2966 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2967 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
2968 _OnDestroy(HWND hwnd)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2969 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2970 if (!destroying)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2971 _OnClose(hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2972 }
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 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2975 _OnPaint(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2976 HWND hwnd)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2977 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2978 if (!IsMinimized(hwnd))
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 PAINTSTRUCT ps;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2981
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2982 out_flush(); // make sure all output has been processed
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2983 (void)BeginPaint(hwnd, &ps);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2984
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2985 // prevent multi-byte characters from misprinting on an invalid
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
2986 // rectangle
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2987 if (has_mbyte)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2988 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2989 RECT rect;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2990
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2991 GetClientRect(hwnd, &rect);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2992 ps.rcPaint.left = rect.left;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2993 ps.rcPaint.right = rect.right;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2994 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2995
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2996 if (!IsRectEmpty(&ps.rcPaint))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2997 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
2998 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
2999 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
3000 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
3001 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3002
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3003 EndPaint(hwnd, &ps);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3004 }
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 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3008 _OnSize(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3009 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
3010 UINT state UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3011 int cx,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3012 int cy)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3013 {
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3014 if (!IsMinimized(hwnd) && !s_in_dpichanged)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3015 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3016 gui_resize_shell(cx, cy);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3017
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3018 // Menu bar may wrap differently now
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3019 gui_mswin_get_menu_height(TRUE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3020 }
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3023 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3024 _OnSetFocus(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3025 HWND hwnd,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3026 HWND hwndOldFocus)
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 gui_focus_change(TRUE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3029 s_getting_focus = TRUE;
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
3030 (void)DefWindowProcW(hwnd, WM_SETFOCUS, (WPARAM)hwndOldFocus, 0);
8140
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3033 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3034 _OnKillFocus(
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 HWND hwndNewFocus)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3037 {
27871
2be33ea63428 patch 8.2.4461: MS-Windows: garbage characters on stdout with VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 27525
diff changeset
3038 if (destroying)
2be33ea63428 patch 8.2.4461: MS-Windows: garbage characters on stdout with VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 27525
diff changeset
3039 return;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3040 gui_focus_change(FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3041 s_getting_focus = FALSE;
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
3042 (void)DefWindowProcW(hwnd, WM_KILLFOCUS, (WPARAM)hwndNewFocus, 0);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3043 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3044
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 * 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
3047 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3048 static LRESULT
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3049 _OnActivateApp(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3050 HWND hwnd,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3051 BOOL fActivate,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3052 DWORD dwThreadId)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3053 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3054 // we call gui_focus_change() in _OnSetFocus()
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3055 // gui_focus_change((int)fActivate);
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
3056 return DefWindowProcW(hwnd, WM_ACTIVATEAPP, fActivate, (DWORD)dwThreadId);
8140
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3059 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3060 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
3061 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3062 DestroyWindow(sb->id);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3063 }
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3066 * 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
3067 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3068 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3069 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
3070 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3071 RECT rct;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3072 POINT mp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3073
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3074 (void)GetWindowRect(s_textArea, &rct);
27281
f7d73708b391 patch 8.2.4169: MS-Windows: unnessary casts and other minor things
Bram Moolenaar <Bram@vim.org>
parents: 27261
diff changeset
3075 (void)GetCursorPos(&mp);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3076 *x = (int)(mp.x - rct.left);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3077 *y = (int)(mp.y - rct.top);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3078 }
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3081 * 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
3082 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3083 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3084 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
3085 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3086 RECT rct;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3087
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3088 (void)GetWindowRect(s_textArea, &rct);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3089 (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
3090 y + gui.border_offset + rct.top);
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3093 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3094 gui_mswin_get_valid_dimensions(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3095 int w,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3096 int h,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3097 int *valid_w,
24804
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
3098 int *valid_h,
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
3099 int *cols,
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
3100 int *rows)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3101 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3102 int base_width, base_height;
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 base_width = gui_get_base_width()
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3105 + (pGetSystemMetricsForDpi(SM_CXFRAME, s_dpi) +
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3106 pGetSystemMetricsForDpi(SM_CXPADDEDBORDER, s_dpi)) * 2;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3107 base_height = gui_get_base_height()
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3108 + (pGetSystemMetricsForDpi(SM_CYFRAME, s_dpi) +
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3109 pGetSystemMetricsForDpi(SM_CXPADDEDBORDER, s_dpi)) * 2
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3110 + pGetSystemMetricsForDpi(SM_CYCAPTION, s_dpi)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3111 + gui_mswin_get_menu_height(FALSE);
24804
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
3112 *cols = (w - base_width) / gui.char_width;
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
3113 *rows = (h - base_height) / gui.char_height;
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
3114 *valid_w = base_width + *cols * gui.char_width;
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
3115 *valid_h = base_height + *rows * gui.char_height;
8140
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3118 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3119 gui_mch_flash(int msec)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3120 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3121 RECT rc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3122
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
3123 #if defined(FEAT_DIRECTX)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
3124 if (IS_ENABLE_DIRECTX())
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
3125 DWriteContext_Flush(s_dwc);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
3126 #endif
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
3127
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3128 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3129 * 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
3130 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3131 rc.left = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3132 rc.top = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3133 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
3134 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
3135 InvertRect(s_hdc, &rc);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3136 gui_mch_flush(); // make sure it's displayed
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3137
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3138 ui_delay((long)msec, TRUE); // wait for a few msec
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3139
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3140 InvertRect(s_hdc, &rc);
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3143 /*
22748
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3144 * Check if the specified point is on-screen. (multi-monitor aware)
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3145 */
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3146 static BOOL
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3147 is_point_onscreen(int x, int y)
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3148 {
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3149 POINT pt = {x, y};
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3150
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3151 return MonitorFromPoint(pt, MONITOR_DEFAULTTONULL) != NULL;
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3152 }
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3153
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3154 /*
27922
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3155 * Check if the whole client area of the specified window is on-screen.
22748
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3156 *
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3157 * Note about DirectX: Windows 10 1809 or above no longer maintains image of
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3158 * the window portion that is off-screen. Scrolling by DWriteContext_Scroll()
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3159 * only works when the whole window is on-screen.
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3160 */
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3161 static BOOL
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3162 is_window_onscreen(HWND hwnd)
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3163 {
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3164 RECT rc;
27922
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3165 POINT p1, p2;
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3166
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3167 GetClientRect(hwnd, &rc);
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3168 p1.x = rc.left;
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3169 p1.y = rc.top;
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3170 p2.x = rc.right - 1;
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3171 p2.y = rc.bottom - 1;
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3172 ClientToScreen(hwnd, &p1);
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3173 ClientToScreen(hwnd, &p2);
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3174
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3175 if (!is_point_onscreen(p1.x, p1.y))
22748
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3176 return FALSE;
27922
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3177 if (!is_point_onscreen(p1.x, p2.y))
22748
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3178 return FALSE;
27922
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3179 if (!is_point_onscreen(p2.x, p1.y))
22748
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3180 return FALSE;
27922
b4ef8f851be4 patch 8.2.4486: MS-Windows GUI: slow scrolling with maximized window
Bram Moolenaar <Bram@vim.org>
parents: 27871
diff changeset
3181 if (!is_point_onscreen(p2.x, p2.y))
22748
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3182 return FALSE;
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3183 return TRUE;
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3184 }
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3185
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3186 /*
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3187 * Return flags used for scrolling.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3188 * 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
3189 * 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
3190 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3191 static int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3192 get_scroll_flags(void)
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 HWND hwnd;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3195 RECT rcVim, rcOther, rcDest;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3196
22748
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3197 // Check if the window is (partly) off-screen.
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3198 if (!is_window_onscreen(s_hwnd))
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3199 return SW_INVALIDATE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3200
26771
fc859aea8cec patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents: 24804
diff changeset
3201 // Check if there is a window (partly) on top of us.
22748
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3202 GetWindowRect(s_hwnd, &rcVim);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3203 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
3204 if (IsWindowVisible(hwnd))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3205 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3206 GetWindowRect(hwnd, &rcOther);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3207 if (IntersectRect(&rcDest, &rcVim, &rcOther))
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3208 return SW_INVALIDATE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3209 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3210 return 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3211 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3212
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3213 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3214 * 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
3215 * may not be scrolled out properly.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3216 * 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
3217 * 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
3218 * 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
3219 * the region before ScrollWindowEx().
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3220 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3221 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3222 intel_gpu_workaround(void)
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 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
3225 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3226
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 * 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
3229 * 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
3230 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3231 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3232 gui_mch_delete_lines(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3233 int row,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3234 int num_lines)
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 RECT rc;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
3237
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3238 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
3239 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
3240 rc.top = FILL_Y(row);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3241 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
3242
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
3243 #if defined(FEAT_DIRECTX)
22748
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3244 if (IS_ENABLE_DIRECTX() && is_window_onscreen(s_hwnd))
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
3245 {
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
3246 DWriteContext_Scroll(s_dwc, 0, -num_lines * gui.char_height, &rc);
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
3247 }
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
3248 else
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
3249 #endif
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
3250 {
22748
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3251 #if defined(FEAT_DIRECTX)
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3252 if (IS_ENABLE_DIRECTX())
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3253 DWriteContext_Flush(s_dwc);
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3254 #endif
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
3255 intel_gpu_workaround();
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
3256 ScrollWindowEx(s_textArea, 0, -num_lines * gui.char_height,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3257 &rc, &rc, NULL, NULL, get_scroll_flags());
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12994
diff changeset
3258 UpdateWindow(s_textArea);
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12994
diff changeset
3259 }
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12994
diff changeset
3260
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3261 // This seems to be required to avoid the cursor disappearing when
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3262 // scrolling such that the cursor ends up in the top-left character on
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3263 // the screen... But why? (Webb)
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3264 // It's probably fixed by disabling drawing the cursor while scrolling.
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3265 // gui.cursor_is_valid = FALSE;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3266
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3267 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
3268 gui.scroll_region_left,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3269 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
3270 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3271
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3272 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3273 * 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
3274 * following text within the scroll region.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3275 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3276 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3277 gui_mch_insert_lines(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3278 int row,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3279 int num_lines)
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 RECT rc;
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
3282
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3283 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
3284 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
3285 rc.top = FILL_Y(row);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3286 rc.bottom = FILL_Y(gui.scroll_region_bot + 1);
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
3287
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
3288 #if defined(FEAT_DIRECTX)
22748
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3289 if (IS_ENABLE_DIRECTX() && is_window_onscreen(s_hwnd))
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
3290 {
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
3291 DWriteContext_Scroll(s_dwc, 0, num_lines * gui.char_height, &rc);
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
3292 }
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
3293 else
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
3294 #endif
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
3295 {
22748
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3296 #if defined(FEAT_DIRECTX)
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3297 if (IS_ENABLE_DIRECTX())
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3298 DWriteContext_Flush(s_dwc);
837983942264 patch 8.2.1922: Win32: scrolling problems when part of window is off-screen
Bram Moolenaar <Bram@vim.org>
parents: 22407
diff changeset
3299 #endif
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
3300 intel_gpu_workaround();
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3301 // The SW_INVALIDATE is required when part of the window is covered or
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3302 // off-screen. How do we avoid it when it's not needed?
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
3303 ScrollWindowEx(s_textArea, 0, num_lines * gui.char_height,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3304 &rc, &rc, NULL, NULL, get_scroll_flags());
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12994
diff changeset
3305 UpdateWindow(s_textArea);
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12994
diff changeset
3306 }
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3307
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3308 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
3309 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
3310 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3311
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3312
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3313 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
3314 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
3315 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3316 #if defined(FEAT_DIRECTX)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3317 DWriteContext_Close(s_dwc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3318 DWrite_Final();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3319 s_dwc = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3320 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3321
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3322 ReleaseDC(s_textArea, s_hdc);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3323 DeleteObject(s_brush);
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 #ifdef FEAT_TEAROFF
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3326 // Unload the tearoff bitmap
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3327 (void)DeleteObject((HGDIOBJ)s_htearbitmap);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3328 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3329
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3330 // Destroy our window (if we have one).
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3331 if (s_hwnd != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3332 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3333 destroying = TRUE; // ignore WM_DESTROY message now
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3334 DestroyWindow(s_hwnd);
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 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3337
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3338 static char_u *
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
3339 logfont2name(LOGFONTW lf)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3340 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3341 char *p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3342 char *res;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3343 char *charset_name;
8835
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3344 char *quality_name;
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
3345 char *font_name;
16439
9d20e26dc13c patch 8.1.1224: MS-Windows: cannot specify font weight
Bram Moolenaar <Bram@vim.org>
parents: 16425
diff changeset
3346 int points;
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
3347
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
3348 font_name = (char *)utf16_to_enc(lf.lfFaceName, NULL);
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
3349 if (font_name == NULL)
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
3350 return NULL;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3351 charset_name = charset_id2name((int)lf.lfCharSet);
8835
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3352 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
3353
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
3354 res = alloc(strlen(font_name) + 30
16425
e263ace0c9d0 patch 8.1.1217: MS-Windows: no space reserved for font quality name
Bram Moolenaar <Bram@vim.org>
parents: 16196
diff changeset
3355 + (charset_name == NULL ? 0 : strlen(charset_name) + 2)
16764
ef00b6bc186b patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 16606
diff changeset
3356 + (quality_name == NULL ? 0 : strlen(quality_name) + 2));
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3357 if (res != NULL)
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 p = res;
16439
9d20e26dc13c patch 8.1.1224: MS-Windows: cannot specify font weight
Bram Moolenaar <Bram@vim.org>
parents: 16425
diff changeset
3360 // make a normal font string out of the lf thing:
9d20e26dc13c patch 8.1.1224: MS-Windows: cannot specify font weight
Bram Moolenaar <Bram@vim.org>
parents: 16425
diff changeset
3361 points = pixels_to_points(
9d20e26dc13c patch 8.1.1224: MS-Windows: cannot specify font weight
Bram Moolenaar <Bram@vim.org>
parents: 16425
diff changeset
3362 lf.lfHeight < 0 ? -lf.lfHeight : lf.lfHeight, TRUE);
9d20e26dc13c patch 8.1.1224: MS-Windows: cannot specify font weight
Bram Moolenaar <Bram@vim.org>
parents: 16425
diff changeset
3363 if (lf.lfWeight == FW_NORMAL || lf.lfWeight == FW_BOLD)
9d20e26dc13c patch 8.1.1224: MS-Windows: cannot specify font weight
Bram Moolenaar <Bram@vim.org>
parents: 16425
diff changeset
3364 sprintf((char *)p, "%s:h%d", font_name, points);
9d20e26dc13c patch 8.1.1224: MS-Windows: cannot specify font weight
Bram Moolenaar <Bram@vim.org>
parents: 16425
diff changeset
3365 else
16468
045ab97fe320 patch 8.1.1238: MS-Windows: compiler warning for sprintf() format
Bram Moolenaar <Bram@vim.org>
parents: 16451
diff changeset
3366 sprintf((char *)p, "%s:h%d:W%ld", font_name, points, lf.lfWeight);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3367 while (*p)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3368 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3369 if (*p == ' ')
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3370 *p = '_';
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3371 ++p;
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 if (lf.lfItalic)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3374 STRCAT(p, ":i");
16439
9d20e26dc13c patch 8.1.1224: MS-Windows: cannot specify font weight
Bram Moolenaar <Bram@vim.org>
parents: 16425
diff changeset
3375 if (lf.lfWeight == FW_BOLD)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3376 STRCAT(p, ":b");
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3377 if (lf.lfUnderline)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3378 STRCAT(p, ":u");
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3379 if (lf.lfStrikeOut)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3380 STRCAT(p, ":s");
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3381 if (charset_name != NULL)
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 STRCAT(p, ":c");
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3384 STRCAT(p, charset_name);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3385 }
8835
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3386 if (quality_name != NULL)
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3387 {
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3388 STRCAT(p, ":q");
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3389 STRCAT(p, quality_name);
c1a5623cfc86 commit https://github.com/vim/vim/commit/7c1c6dbb6817640fd3956a0d5417da23fde336d8
Christian Brabandt <cb@256bit.org>
parents: 8813
diff changeset
3390 }
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3391 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3392
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
3393 vim_free(font_name);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3394 return (char_u *)res;
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3397
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3398 #ifdef FEAT_MBYTE_IME
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3399 /*
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
3400 * Set correct LOGFONTW to IME. Use 'guifontwide' if available, otherwise use
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3401 * 'guifont'.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3402 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3403 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3404 update_im_font(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3405 {
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3406 LOGFONTW lf_wide, lf;
8140
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 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
3409 && gui.wide_font != NOFONT
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
3410 && GetObjectW((HFONT)gui.wide_font, sizeof(lf_wide), &lf_wide))
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3411 norm_logfont = lf_wide;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3412 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3413 norm_logfont = sub_logfont;
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3414
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3415 lf = norm_logfont;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3416 if (s_process_dpi_aware == DPI_AWARENESS_UNAWARE)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3417 // Work around when PerMonitorV2 is not enabled in the process level.
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3418 lf.lfHeight = lf.lfHeight * DEFAULT_DPI / s_dpi;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3419 im_set_font(&lf);
8140
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 #endif
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3424 * 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
3425 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3426 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3427 gui_mch_wide_font_changed(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3428 {
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
3429 LOGFONTW lf;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3430
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
3431 #ifdef FEAT_MBYTE_IME
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3432 update_im_font();
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
3433 #endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3434
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3435 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
3436 gui.wide_ital_font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3437 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
3438 gui.wide_bold_font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3439 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
3440 gui.wide_boldital_font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3441
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3442 if (gui.wide_font
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
3443 && GetObjectW((HFONT)gui.wide_font, sizeof(lf), &lf))
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3444 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3445 if (!lf.lfItalic)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3446 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3447 lf.lfItalic = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3448 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
3449 lf.lfItalic = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3450 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3451 if (lf.lfWeight < FW_BOLD)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3452 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3453 lf.lfWeight = FW_BOLD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3454 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
3455 if (!lf.lfItalic)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3456 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3457 lf.lfItalic = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3458 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
3459 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3460 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3461 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3462 }
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3465 * 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
3466 * 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
3467 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3468 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
3469 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
3470 {
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3471 LOGFONTW lf, lfOrig;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3472 GuiFont font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3473 char_u *p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3474
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3475 // Load the font
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3476 if (get_logfont(&lf, font_name, NULL, TRUE) == OK)
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3477 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3478 lfOrig = lf;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3479 lf.lfHeight = adjust_fontsize_by_dpi(lf.lfHeight);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3480 font = get_font_handle(&lf);
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3481 }
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3482 if (font == NOFONT)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3483 return FAIL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3484
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3485 if (font_name == NULL)
27281
f7d73708b391 patch 8.2.4169: MS-Windows: unnessary casts and other minor things
Bram Moolenaar <Bram@vim.org>
parents: 27261
diff changeset
3486 font_name = (char_u *)"";
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
3487 #ifdef FEAT_MBYTE_IME
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3488 norm_logfont = lf;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3489 sub_logfont = lf;
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3490 if (!s_in_dpichanged)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3491 update_im_font();
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3492 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3493 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
3494 gui.norm_font = font;
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3495 current_font_height = lfOrig.lfHeight;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3496 GetFontSize(font);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3497
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3498 p = logfont2name(lfOrig);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3499 if (p != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3500 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3501 hl_set_font_name(p);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3502
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3503 // When setting 'guifont' to "*" replace it with the actual font name.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3504 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
3505 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3506 vim_free(p_guifont);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3507 p_guifont = p;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3508 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3509 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3510 vim_free(p);
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 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
3514 gui.ital_font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3515 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
3516 gui.bold_font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3517 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
3518 gui.boldital_font = NOFONT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3519
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3520 if (!lf.lfItalic)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3521 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3522 lf.lfItalic = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3523 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
3524 lf.lfItalic = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3525 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3526 if (lf.lfWeight < FW_BOLD)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3527 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3528 lf.lfWeight = FW_BOLD;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3529 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
3530 if (!lf.lfItalic)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3531 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3532 lf.lfItalic = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3533 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
3534 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3535 }
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 return OK;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3538 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3539
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 * Return TRUE if the GUI window is maximized, filling the whole screen.
21363
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3542 * Also return TRUE if the window is snapped.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3543 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3544 int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3545 gui_mch_maximized(void)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3546 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3547 WINDOWPLACEMENT wp;
21363
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3548 RECT rc;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3549
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3550 wp.length = sizeof(WINDOWPLACEMENT);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3551 if (GetWindowPlacement(s_hwnd, &wp))
21363
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3552 {
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3553 if (wp.showCmd == SW_SHOWMAXIMIZED
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3554 || (wp.showCmd == SW_SHOWMINIMIZED
21363
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3555 && wp.flags == WPF_RESTORETOMAXIMIZED))
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3556 return TRUE;
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3557 if (wp.showCmd == SW_SHOWMINIMIZED)
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3558 return FALSE;
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3559
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3560 // Assume the window is snapped when the sizes from two APIs differ.
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3561 GetWindowRect(s_hwnd, &rc);
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3562 if ((rc.right - rc.left !=
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3563 wp.rcNormalPosition.right - wp.rcNormalPosition.left)
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3564 || (rc.bottom - rc.top !=
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3565 wp.rcNormalPosition.bottom - wp.rcNormalPosition.top))
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3566 return TRUE;
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3567 }
ef2290a53dd0 patch 8.2.1232: MS-Windows GUI: Snap cancelled by split command
Bram Moolenaar <Bram@vim.org>
parents: 21361
diff changeset
3568 return FALSE;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3569 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3570
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3571 /*
12802
29a728529f92 patch 8.0.1278: GUI window always resizes when adding scrollbar
Christian Brabandt <cb@256bit.org>
parents: 12712
diff changeset
3572 * Called when the font changed while the window is maximized or GO_KEEPWINSIZE
29a728529f92 patch 8.0.1278: GUI window always resizes when adding scrollbar
Christian Brabandt <cb@256bit.org>
parents: 12712
diff changeset
3573 * is set. Compute the new Rows and Columns. This is like resizing the
29a728529f92 patch 8.0.1278: GUI window always resizes when adding scrollbar
Christian Brabandt <cb@256bit.org>
parents: 12712
diff changeset
3574 * window.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3575 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3576 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3577 gui_mch_newfont(void)
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 RECT rect;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3580
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3581 GetWindowRect(s_hwnd, &rect);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3582 if (win_socket_id == 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3583 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3584 gui_resize_shell(rect.right - rect.left
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3585 - (pGetSystemMetricsForDpi(SM_CXFRAME, s_dpi) +
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3586 pGetSystemMetricsForDpi(SM_CXPADDEDBORDER, s_dpi)) * 2,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3587 rect.bottom - rect.top
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3588 - (pGetSystemMetricsForDpi(SM_CYFRAME, s_dpi) +
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3589 pGetSystemMetricsForDpi(SM_CXPADDEDBORDER, s_dpi)) * 2
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3590 - pGetSystemMetricsForDpi(SM_CYCAPTION, s_dpi)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3591 - gui_mswin_get_menu_height(FALSE));
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3592 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3593 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3594 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3595 // Inside another window, don't use the frame and border.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3596 gui_resize_shell(rect.right - rect.left,
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
3597 rect.bottom - rect.top - gui_mswin_get_menu_height(FALSE));
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3598 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3599 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3600
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3601 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3602 * Set the window title
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3603 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3604 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3605 gui_mch_settitle(
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3606 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
3607 char_u *icon UNUSED)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3608 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3609 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
3610 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3611
9834
80ace3687eec commit https://github.com/vim/vim/commit/a6b7a08ae04a3cd4d9c45c906bb7a197e2135179
Christian Brabandt <cb@256bit.org>
parents: 9428
diff changeset
3612 #if defined(FEAT_MOUSESHAPE) || defined(PROTO)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3613 // Table for shape IDCs. Keep in sync with the mshape_names[] table in
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3614 // misc2.c!
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3615 static LPCSTR mshape_idcs[] =
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3616 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3617 IDC_ARROW, // arrow
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3618 MAKEINTRESOURCE(0), // blank
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3619 IDC_IBEAM, // beam
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3620 IDC_SIZENS, // updown
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3621 IDC_SIZENS, // udsizing
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3622 IDC_SIZEWE, // leftright
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3623 IDC_SIZEWE, // lrsizing
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3624 IDC_WAIT, // busy
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3625 IDC_NO, // no
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3626 IDC_ARROW, // crosshair
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3627 IDC_ARROW, // hand1
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3628 IDC_ARROW, // hand2
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3629 IDC_ARROW, // pencil
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3630 IDC_ARROW, // question
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3631 IDC_ARROW, // right-arrow
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3632 IDC_UPARROW, // up-arrow
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3633 IDC_ARROW // last one
8140
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 void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3637 mch_set_mouse_shape(int shape)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3638 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3639 LPCSTR idc;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3640
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3641 if (shape == MSHAPE_HIDE)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3642 ShowCursor(FALSE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3643 else
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 if (shape >= MSHAPE_NUMBERED)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3646 idc = IDC_ARROW;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3647 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3648 idc = mshape_idcs[shape];
18662
652ac5edf8d0 patch 8.1.2323: Old MSVC version no longer tested.
Bram Moolenaar <Bram@vim.org>
parents: 18652
diff changeset
3649 SetClassLongPtr(s_textArea, GCLP_HCURSOR, (LONG_PTR)LoadCursor(NULL, idc));
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3650 if (!p_mh)
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 POINT mp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3653
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3654 // Set the position to make it redrawn with the new shape.
27281
f7d73708b391 patch 8.2.4169: MS-Windows: unnessary casts and other minor things
Bram Moolenaar <Bram@vim.org>
parents: 27261
diff changeset
3655 (void)GetCursorPos(&mp);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3656 (void)SetCursorPos(mp.x, mp.y);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3657 ShowCursor(TRUE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3658 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3659 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3660 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3661 #endif
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3662
9834
80ace3687eec commit https://github.com/vim/vim/commit/a6b7a08ae04a3cd4d9c45c906bb7a197e2135179
Christian Brabandt <cb@256bit.org>
parents: 9428
diff changeset
3663 #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
3664 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3665 * Wide version of convert_filter().
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3666 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3667 static WCHAR *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3668 convert_filterW(char_u *s)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3669 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3670 char_u *tmp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3671 int len;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3672 WCHAR *res;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3673
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3674 tmp = convert_filter(s);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3675 if (tmp == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3676 return NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3677 len = (int)STRLEN(s) + 3;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3678 res = enc_to_utf16(tmp, &len);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3679 vim_free(tmp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3680 return res;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3681 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3682
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3683 /*
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
3684 * Pop open a file browser and return the file selected, in allocated memory,
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
3685 * or NULL if Cancel is hit.
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
3686 * saving - TRUE if the file will be saved to, FALSE if it will be opened.
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
3687 * title - Title message for the file browser dialog.
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
3688 * dflt - Default name of file.
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
3689 * ext - Default extension to be added to files without extensions.
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
3690 * initdir - directory in which to open the browser (NULL = current dir)
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
3691 * filter - Filter for matched files to choose from.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3692 */
15601
8ab9ad27fca4 patch 8.1.0808: MS-Windows: build error with GUI
Bram Moolenaar <Bram@vim.org>
parents: 15597
diff changeset
3693 char_u *
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
3694 gui_mch_browse(
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3695 int saving,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3696 char_u *title,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3697 char_u *dflt,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3698 char_u *ext,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3699 char_u *initdir,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3700 char_u *filter)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3701 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3702 // We always use the wide function. This means enc_to_utf16() must work,
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3703 // otherwise it fails miserably!
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3704 OPENFILENAMEW fileStruct;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3705 WCHAR fileBuf[MAXPATHL];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3706 WCHAR *wp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3707 int i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3708 WCHAR *titlep = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3709 WCHAR *extp = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3710 WCHAR *initdirp = NULL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3711 WCHAR *filterp;
14830
9d9e4a929357 patch 8.1.0427: MS-Windows GUI: using invalid encoded file name
Christian Brabandt <cb@256bit.org>
parents: 14364
diff changeset
3712 char_u *p, *q;
27259
59cdcd1e47b8 patch 8.2.4158: MS-Windows: memory leak in :browse
Bram Moolenaar <Bram@vim.org>
parents: 27249
diff changeset
3713 BOOL ret;
8140
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 if (dflt == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3716 fileBuf[0] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3717 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3718 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3719 wp = enc_to_utf16(dflt, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3720 if (wp == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3721 fileBuf[0] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3722 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3723 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3724 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
3725 fileBuf[i] = wp[i];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3726 fileBuf[i] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3727 vim_free(wp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3728 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3729 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3730
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3731 // Convert the filter to Windows format.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3732 filterp = convert_filterW(filter);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3733
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19934
diff changeset
3734 CLEAR_FIELD(fileStruct);
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3735 # ifdef OPENFILENAME_SIZE_VERSION_400W
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3736 // 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
3737 fileStruct.lStructSize = OPENFILENAME_SIZE_VERSION_400W;
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3738 # else
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3739 fileStruct.lStructSize = sizeof(fileStruct);
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3740 # endif
8140
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 if (title != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3743 titlep = enc_to_utf16(title, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3744 fileStruct.lpstrTitle = titlep;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3745
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3746 if (ext != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3747 extp = enc_to_utf16(ext, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3748 fileStruct.lpstrDefExt = extp;
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.lpstrFile = fileBuf;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3751 fileStruct.nMaxFile = MAXPATHL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3752 fileStruct.lpstrFilter = filterp;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3753 fileStruct.hwndOwner = s_hwnd; // main Vim window is owner
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3754 // has an initial dir been specified?
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3755 if (initdir != NULL && *initdir != NUL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3756 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3757 // Must have backslashes here, no matter what 'shellslash' says
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3758 initdirp = enc_to_utf16(initdir, NULL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3759 if (initdirp != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3760 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3761 for (wp = initdirp; *wp != NUL; ++wp)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3762 if (*wp == '/')
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3763 *wp = '\\';
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 fileStruct.lpstrInitialDir = initdirp;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3766 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3767
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 * 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
3770 * 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
3771 * 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
3772 * 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
3773 * OFN_PATHMUSTEXIST?
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3774 * 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
3775 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3776 fileStruct.Flags = (OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY);
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3777 # ifdef FEAT_SHORTCUT
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3778 if (curbuf->b_p_bin)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3779 fileStruct.Flags |= OFN_NODEREFERENCELINKS;
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
3780 # endif
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3781 if (saving)
27259
59cdcd1e47b8 patch 8.2.4158: MS-Windows: memory leak in :browse
Bram Moolenaar <Bram@vim.org>
parents: 27249
diff changeset
3782 ret = GetSaveFileNameW(&fileStruct);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3783 else
27259
59cdcd1e47b8 patch 8.2.4158: MS-Windows: memory leak in :browse
Bram Moolenaar <Bram@vim.org>
parents: 27249
diff changeset
3784 ret = GetOpenFileNameW(&fileStruct);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3785
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3786 vim_free(filterp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3787 vim_free(initdirp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3788 vim_free(titlep);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3789 vim_free(extp);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3790
27259
59cdcd1e47b8 patch 8.2.4158: MS-Windows: memory leak in :browse
Bram Moolenaar <Bram@vim.org>
parents: 27249
diff changeset
3791 if (!ret)
59cdcd1e47b8 patch 8.2.4158: MS-Windows: memory leak in :browse
Bram Moolenaar <Bram@vim.org>
parents: 27249
diff changeset
3792 return NULL;
59cdcd1e47b8 patch 8.2.4158: MS-Windows: memory leak in :browse
Bram Moolenaar <Bram@vim.org>
parents: 27249
diff changeset
3793
59cdcd1e47b8 patch 8.2.4158: MS-Windows: memory leak in :browse
Bram Moolenaar <Bram@vim.org>
parents: 27249
diff changeset
3794 // Convert from UTF-16 to 'encoding'.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3795 p = utf16_to_enc(fileBuf, NULL);
14830
9d9e4a929357 patch 8.1.0427: MS-Windows GUI: using invalid encoded file name
Christian Brabandt <cb@256bit.org>
parents: 14364
diff changeset
3796 if (p == NULL)
9d9e4a929357 patch 8.1.0427: MS-Windows GUI: using invalid encoded file name
Christian Brabandt <cb@256bit.org>
parents: 14364
diff changeset
3797 return NULL;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3798
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3799 // Give focus back to main window (when using MDI).
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3800 SetFocus(s_hwnd);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3801
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3802 // Shorten the file name if possible
14830
9d9e4a929357 patch 8.1.0427: MS-Windows GUI: using invalid encoded file name
Christian Brabandt <cb@256bit.org>
parents: 14364
diff changeset
3803 q = vim_strsave(shorten_fname1(p));
9d9e4a929357 patch 8.1.0427: MS-Windows GUI: using invalid encoded file name
Christian Brabandt <cb@256bit.org>
parents: 14364
diff changeset
3804 vim_free(p);
9d9e4a929357 patch 8.1.0427: MS-Windows GUI: using invalid encoded file name
Christian Brabandt <cb@256bit.org>
parents: 14364
diff changeset
3805 return q;
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3806 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3807
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3808
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3809 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3810 * 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
3811 * 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
3812 * 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
3813 *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3814 * 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
3815 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3816 static char_u *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3817 convert_filter(char_u *s)
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 char_u *res;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3820 unsigned s_len = (unsigned)STRLEN(s);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3821 unsigned i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3822
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3823 res = alloc(s_len + 3);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3824 if (res != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3825 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3826 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
3827 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
3828 res[i] = '\0';
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3829 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3830 res[i] = s[i];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3831 res[s_len] = NUL;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3832 // Add two extra NULs to make sure it's properly terminated.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3833 res[s_len + 1] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3834 res[s_len + 2] = NUL;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3835 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3836 return res;
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
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3839 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3840 * Select a directory.
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3841 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3842 char_u *
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3843 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
3844 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3845 // We fake this: Use a filter that doesn't select anything and a default
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3846 // file name that won't be used.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3847 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
3848 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
3849 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3850 #endif // FEAT_BROWSE
8140
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 static void
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3853 _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
3854 HWND hwnd UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3855 HDROP hDrop)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3856 {
12477
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12317
diff changeset
3857 #define BUFPATHLEN _MAX_PATH
68d7bc045dbe patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs
Christian Brabandt <cb@256bit.org>
parents: 12317
diff changeset
3858 #define DRAGQVAL 0xFFFFFFFF
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3859 WCHAR wszFile[BUFPATHLEN];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3860 char szFile[BUFPATHLEN];
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3861 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
3862 UINT i;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3863 char_u **fnames;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3864 POINT pt;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3865 int_u modifiers = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3866
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3867 // Obtain dropped position
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3868 DragQueryPoint(hDrop, &pt);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3869 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
3870
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3871 reset_VIsual();
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3872
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
3873 fnames = ALLOC_MULT(char_u *, cFiles);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3874
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3875 if (fnames != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3876 for (i = 0; i < cFiles; ++i)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3877 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3878 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
3879 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
3880 else
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3881 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3882 DragQueryFile(hDrop, i, szFile, BUFPATHLEN);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3883 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
3884 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3885 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3886
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3887 DragFinish(hDrop);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3888
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3889 if (fnames != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3890 {
28586
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
3891 int kbd_modifiers = get_active_modifiers();
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
3892
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
3893 if ((kbd_modifiers & MOD_MASK_SHIFT) != 0)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3894 modifiers |= MOUSE_SHIFT;
28586
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
3895 if ((kbd_modifiers & MOD_MASK_CTRL) != 0)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3896 modifiers |= MOUSE_CTRL;
28586
3fd992496509 patch 8.2.4817: Win32 GUI: modifiers are not always used
Bram Moolenaar <Bram@vim.org>
parents: 28574
diff changeset
3897 if ((kbd_modifiers & MOD_MASK_ALT) != 0)
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3898 modifiers |= MOUSE_ALT;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3899
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3900 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
3901
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3902 s_need_activate = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3903 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3904 }
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 static int
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3907 _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
3908 HWND hwnd UNUSED,
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3909 HWND hwndCtl,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3910 UINT code,
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3911 int pos)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3912 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3913 static UINT prev_code = 0; // code of previous call
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3914 scrollbar_T *sb, *sb_info;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3915 long val;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3916 int dragging = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3917 int dont_scroll_save = dont_scroll;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3918 SCROLLINFO si;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3919
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3920 si.cbSize = sizeof(si);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3921 si.fMask = SIF_POS;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3922
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3923 sb = gui_mswin_find_scrollbar(hwndCtl);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3924 if (sb == NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3925 return 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3926
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3927 if (sb->wp != NULL) // Left or right scrollbar
8140
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3930 * 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
3931 * 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
3932 * gui_drag_scrollbar().
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3933 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3934 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
3935 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3936 else // Bottom scrollbar
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3937 sb_info = sb;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3938 val = sb_info->value;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3939
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3940 switch (code)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3941 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3942 case SB_THUMBTRACK:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3943 val = pos;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3944 dragging = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3945 if (sb->scroll_shift > 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3946 val <<= sb->scroll_shift;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3947 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3948 case SB_LINEDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3949 val++;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3950 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3951 case SB_LINEUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3952 val--;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3953 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3954 case SB_PAGEDOWN:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3955 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
3956 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3957 case SB_PAGEUP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3958 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
3959 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3960 case SB_TOP:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3961 val = 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3962 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3963 case SB_BOTTOM:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3964 val = sb_info->max;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3965 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3966 case SB_ENDSCROLL:
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3967 if (prev_code == SB_THUMBTRACK)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3968 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3969 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3970 * "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
3971 * 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
3972 * 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
3973 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3974 val = GetScrollPos(hwndCtl, SB_CTL);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3975 if (sb->scroll_shift > 0)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3976 val <<= sb->scroll_shift;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3977 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3978 break;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3979
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3980 default:
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
3981 // TRACE("Unknown scrollbar event %d\n", code);
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3982 return 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3983 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3984 prev_code = code;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3985
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3986 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
3987 SetScrollInfo(hwndCtl, SB_CTL, &si, TRUE);
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 /*
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3990 * 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
3991 */
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3992 if (sb->wp != NULL)
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3993 {
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3994 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
3995 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
3996
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3997 SetScrollInfo(id, SB_CTL, &si, TRUE);
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3998 }
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
3999
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4000 // Don't let us be interrupted here by another message.
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4001 s_busy_processing = TRUE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4002
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4003 // When "allow_scrollbar" is FALSE still need to remember the new
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4004 // position, but don't actually scroll by setting "dont_scroll".
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4005 dont_scroll = !allow_scrollbar;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4006
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
4007 mch_disable_flush();
8140
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4008 gui_drag_scrollbar(sb, val, dragging);
13150
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
4009 mch_enable_flush();
808625d4b71b patch 8.0.1449: slow redrawing with DirectX
Christian Brabandt <cb@256bit.org>
parents: 13028
diff changeset
4010 gui_may_flush();
8140
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 s_busy_processing = FALSE;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4013 dont_scroll = dont_scroll_save;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4014
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4015 return 0;
563c923b1584 commit https://github.com/vim/vim/commit/cf7164a088664961e7d70dd100c5874dc5ceb293
Christian Brabandt <cb@256bit.org>
parents: 8138
diff changeset
4016 }
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
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4019 #ifdef FEAT_XPM_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4020 # include "xpm_w32.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4021 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4022
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4023
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4024 // Some parameters for tearoff menus. All in pixels.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4025 #define TEAROFF_PADDING_X 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4026 #define TEAROFF_BUTTON_PAD_X 8
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4027 #define TEAROFF_MIN_WIDTH 200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4028 #define TEAROFF_SUBMENU_LABEL ">>"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4029 #define TEAROFF_COLUMN_PADDING 3 // # spaces to pad column with.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4030
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4031
12871
1a450ce6980c patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents: 12802
diff changeset
4032 #ifdef FEAT_BEVAL_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4033 # define ID_BEVAL_TOOLTIP 200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4034 # define BEVAL_TEXT_LEN MAXPATHL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4035
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4036 static BalloonEval *cur_beval = NULL;
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
4037 static UINT_PTR beval_timer_id = 0;
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
4038 static DWORD last_user_activity = 0;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4039 #endif // defined(FEAT_BEVAL_GUI)
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
4040
842
a209672376fd updated for version 7.0f
vimboss
parents: 840
diff changeset
4041
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4042 // Local variables:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4043
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4044 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4045 static UINT s_menu_id = 100;
2614
56ecdb792c33 updated for version 7.3.036
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
4046 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4047
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4048 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4049 * Use the system font for dialogs and tear-off menus. Remove this line to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4050 * use DLG_FONT_NAME.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4051 */
2614
56ecdb792c33 updated for version 7.3.036
Bram Moolenaar <bram@vim.org>
parents: 2612
diff changeset
4052 #define USE_SYSMENU_FONT
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4053
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4054 #define VIM_NAME "vim"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4055 #define VIM_CLASSW L"Vim"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4056
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4057 // Initial size for the dialog template. For gui_mch_dialog() it's fixed,
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4058 // thus there should be room for every dialog. For tearoffs it's made bigger
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4059 // when needed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4060 #define DLG_ALLOC_SIZE 16 * 1024
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4061
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4062 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4063 * stuff for dialogs, menus, tearoffs etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4064 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4065 static PWORD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4066 add_dialog_element(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4067 PWORD p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4068 DWORD lStyle,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4069 WORD x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4070 WORD y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4071 WORD w,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4072 WORD h,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4073 WORD Id,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4074 WORD clss,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4075 const char *caption);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4076 static LPWORD lpwAlign(LPWORD);
12543
e9028055f6d6 patch 8.0.1150: MS-Windows GUI: dialog font size is incorrect
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
4077 static int nCopyAnsiToWideChar(LPWORD, LPSTR, BOOL);
8138
f52504c10387 commit https://github.com/vim/vim/commit/065bbac8adfe29a09958570237d223457f235c6c
Christian Brabandt <cb@256bit.org>
parents: 8108
diff changeset
4078 #if defined(FEAT_MENU) && defined(FEAT_TEAROFF)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4079 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
4080 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4081 static void get_dialog_font_metrics(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4082
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4083 static int dialog_default_button = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4084
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4085 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4086 static void initialise_toolbar(void);
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4087 static void update_toolbar_size(void);
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
4088 static LRESULT CALLBACK toolbar_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4089 static int get_toolbar_bitmap(vimmenu_T *menu);
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4090 #else
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4091 # define update_toolbar_size()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4092 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4093
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4094 #ifdef FEAT_GUI_TABLINE
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4095 static void initialise_tabline(void);
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
4096 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
4097 #endif
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4098
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4099 #ifdef FEAT_MBYTE_IME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4100 static LRESULT _OnImeComposition(HWND hwnd, WPARAM dbcs, LPARAM param);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4101 static char_u *GetResultStr(HWND hwnd, int GCS, int *lenp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4102 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4103 #if defined(FEAT_MBYTE_IME) && defined(DYNAMIC_IME)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4104 # ifdef NOIME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4105 typedef struct tagCOMPOSITIONFORM {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4106 DWORD dwStyle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4107 POINT ptCurrentPos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4108 RECT rcArea;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4109 } COMPOSITIONFORM, *PCOMPOSITIONFORM, NEAR *NPCOMPOSITIONFORM, FAR *LPCOMPOSITIONFORM;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4110 typedef HANDLE HIMC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4111 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4112
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4113 static HINSTANCE hLibImm = NULL;
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4114 static LONG (WINAPI *pImmGetCompositionStringW)(HIMC, DWORD, LPVOID, DWORD);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4115 static HIMC (WINAPI *pImmGetContext)(HWND);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4116 static HIMC (WINAPI *pImmAssociateContext)(HWND, HIMC);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4117 static BOOL (WINAPI *pImmReleaseContext)(HWND, HIMC);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4118 static BOOL (WINAPI *pImmGetOpenStatus)(HIMC);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4119 static BOOL (WINAPI *pImmSetOpenStatus)(HIMC, BOOL);
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
4120 static BOOL (WINAPI *pImmGetCompositionFontW)(HIMC, LPLOGFONTW);
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
4121 static BOOL (WINAPI *pImmSetCompositionFontW)(HIMC, LPLOGFONTW);
344
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4122 static BOOL (WINAPI *pImmSetCompositionWindow)(HIMC, LPCOMPOSITIONFORM);
7033303ea0c0 updated for version 7.0089
vimboss
parents: 336
diff changeset
4123 static BOOL (WINAPI *pImmGetConversionStatus)(HIMC, LPDWORD, LPDWORD);
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
4124 static BOOL (WINAPI *pImmSetConversionStatus)(HIMC, DWORD, DWORD);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4125 static void dyn_imm_load(void);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4126 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4127 # define pImmGetCompositionStringW ImmGetCompositionStringW
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4128 # define pImmGetContext ImmGetContext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4129 # define pImmAssociateContext ImmAssociateContext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4130 # define pImmReleaseContext ImmReleaseContext
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4131 # define pImmGetOpenStatus ImmGetOpenStatus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4132 # define pImmSetOpenStatus ImmSetOpenStatus
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
4133 # define pImmGetCompositionFontW ImmGetCompositionFontW
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
4134 # define pImmSetCompositionFontW ImmSetCompositionFontW
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4135 # define pImmSetCompositionWindow ImmSetCompositionWindow
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4136 # define pImmGetConversionStatus ImmGetConversionStatus
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
4137 # define pImmSetConversionStatus ImmSetConversionStatus
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4138 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4140 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4141 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4142 * Figure out how high the menu bar is at the moment.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4143 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4144 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4145 gui_mswin_get_menu_height(
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4146 int fix_window) // If TRUE, resize window if menu height changed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4147 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4148 static int old_menu_height = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4150 RECT rc1, rc2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4151 int num;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4152 int menu_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4153
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4154 if (gui.menu_is_active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4155 num = GetMenuItemCount(s_menuBar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4156 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4157 num = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4158
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4159 if (num == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4160 menu_height = 0;
6714
dc96dd80aef8 updated for version 7.4.681
Bram Moolenaar <bram@vim.org>
parents: 6359
diff changeset
4161 else if (IsMinimized(s_hwnd))
dc96dd80aef8 updated for version 7.4.681
Bram Moolenaar <bram@vim.org>
parents: 6359
diff changeset
4162 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4163 // The height of the menu cannot be determined while the window is
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4164 // minimized. Take the previous height if the menu is changed in that
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4165 // state, to avoid that Vim's vertical window size accidentally
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4166 // increases due to the unaccounted-for menu height.
6714
dc96dd80aef8 updated for version 7.4.681
Bram Moolenaar <bram@vim.org>
parents: 6359
diff changeset
4167 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
4168 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4169 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4170 {
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4171 /*
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4172 * 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
4173 * 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
4174 * 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
4175 * 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
4176 * 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
4177 */
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4178 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
4179 if (gui.starting)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4180 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
4181 else
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4182 {
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4183 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
4184 menu_height = rc2.bottom - rc1.top + 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4185 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4186 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4187
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4188 if (fix_window && menu_height != old_menu_height)
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4189 gui_set_shellsize(FALSE, FALSE, RESIZE_VERT);
6714
dc96dd80aef8 updated for version 7.4.681
Bram Moolenaar <bram@vim.org>
parents: 6359
diff changeset
4190 old_menu_height = menu_height;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4191
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4192 return menu_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4193 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4194 #endif // FEAT_MENU
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4195
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4196
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4197 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4198 * Setup for the Intellimouse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4199 */
28755
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4200 static long
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4201 mouse_vertical_scroll_step(void)
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4202 {
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4203 UINT val;
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4204 if (SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &val, 0))
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4205 return (val != WHEEL_PAGESCROLL) ? (long)val : -1;
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4206 return 3; // Safe default;
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4207 }
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4208
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4209 static long
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4210 mouse_horizontal_scroll_step(void)
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4211 {
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4212 UINT val;
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4213 if (SystemParametersInfo(SPI_GETWHEELSCROLLCHARS, 0, &val, 0))
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4214 return (long)val;
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4215 return 3; // Safe default;
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4216 }
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4217
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4218 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4219 init_mouse_wheel(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4220 {
28755
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4221 // Get the default values for the horizontal and vertical scroll steps from
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4222 // the system.
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4223 mouse_set_vert_scroll_step(mouse_vertical_scroll_step());
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4224 mouse_set_hor_scroll_step(mouse_horizontal_scroll_step());
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4225 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4226
18526
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4227 /*
28825
4c749f9b97fd patch 8.2.4936: MS-Windows: mouse coordinates for scroll event are wrong
Bram Moolenaar <Bram@vim.org>
parents: 28792
diff changeset
4228 * Mouse scroll event handler.
18526
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4229 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4230 static void
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
4231 _OnMouseWheel(HWND hwnd UNUSED, WPARAM wParam, LPARAM lParam, int horizontal)
28700
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4232 {
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4233 int button;
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4234 win_T *wp;
29096
d2ef7d649fcb patch 8.2.5069: various warnings from clang on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 28825
diff changeset
4235 int modifiers = 0;
d2ef7d649fcb patch 8.2.5069: various warnings from clang on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 28825
diff changeset
4236 int kbd_modifiers;
28825
4c749f9b97fd patch 8.2.4936: MS-Windows: mouse coordinates for scroll event are wrong
Bram Moolenaar <Bram@vim.org>
parents: 28792
diff changeset
4237 int zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
4c749f9b97fd patch 8.2.4936: MS-Windows: mouse coordinates for scroll event are wrong
Bram Moolenaar <Bram@vim.org>
parents: 28792
diff changeset
4238 POINT pt;
28700
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4239
18526
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4240 wp = gui_mouse_window(FIND_POPUP);
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4241
18763
49b78d6465e5 patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents: 18742
diff changeset
4242 #ifdef FEAT_PROP_POPUP
18526
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4243 if (wp != NULL && popup_is_popup(wp))
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4244 {
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4245 cmdarg_T cap;
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4246 oparg_T oa;
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4247
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4248 // Mouse hovers over popup window, scroll it if possible.
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4249 mouse_row = wp->w_winrow;
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4250 mouse_col = wp->w_wincol;
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19934
diff changeset
4251 CLEAR_FIELD(cap);
28700
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4252 if (horizontal)
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4253 {
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4254 cap.arg = zDelta < 0 ? MSCR_LEFT : MSCR_RIGHT;
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4255 cap.cmdchar = zDelta < 0 ? K_MOUSELEFT : K_MOUSERIGHT;
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4256 }
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4257 else
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4258 {
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4259 cap.arg = zDelta < 0 ? MSCR_UP : MSCR_DOWN;
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4260 cap.cmdchar = zDelta < 0 ? K_MOUSEUP : K_MOUSEDOWN;
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4261 }
18526
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4262 clear_oparg(&oa);
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4263 cap.oap = &oa;
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4264 nv_mousescroll(&cap);
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4265 update_screen(0);
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4266 setcursor();
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4267 out_flush();
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4268 return;
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4269 }
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4270 #endif
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4271
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4272 if (wp == NULL || !p_scf)
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4273 wp = curwin;
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4274
28700
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4275 // Translate the scroll event into an event that Vim can process so that
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4276 // the user has a chance to map the scrollwheel buttons.
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4277 if (horizontal)
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4278 button = zDelta >= 0 ? MOUSE_6 : MOUSE_7;
18526
334b1f897f3a patch 8.1.2257: MS-Windows GUI: scroll wheel always uses current window
Bram Moolenaar <Bram@vim.org>
parents: 18520
diff changeset
4279 else
28700
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4280 button = zDelta >= 0 ? MOUSE_4 : MOUSE_5;
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4281
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4282 kbd_modifiers = get_active_modifiers();
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4283
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4284 if ((kbd_modifiers & MOD_MASK_SHIFT) != 0)
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4285 modifiers |= MOUSE_SHIFT;
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4286 if ((kbd_modifiers & MOD_MASK_CTRL) != 0)
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4287 modifiers |= MOUSE_CTRL;
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4288 if ((kbd_modifiers & MOD_MASK_ALT) != 0)
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4289 modifiers |= MOUSE_ALT;
18520
6067fbb46625 patch 8.1.2254: MS-Windows: mouse scroll wheel doesn't work in popup
Bram Moolenaar <Bram@vim.org>
parents: 18416
diff changeset
4290
28825
4c749f9b97fd patch 8.2.4936: MS-Windows: mouse coordinates for scroll event are wrong
Bram Moolenaar <Bram@vim.org>
parents: 28792
diff changeset
4291 // The cursor position is relative to the upper-left corner of the screen.
4c749f9b97fd patch 8.2.4936: MS-Windows: mouse coordinates for scroll event are wrong
Bram Moolenaar <Bram@vim.org>
parents: 28792
diff changeset
4292 pt.x = GET_X_LPARAM(lParam);
4c749f9b97fd patch 8.2.4936: MS-Windows: mouse coordinates for scroll event are wrong
Bram Moolenaar <Bram@vim.org>
parents: 28792
diff changeset
4293 pt.y = GET_Y_LPARAM(lParam);
4c749f9b97fd patch 8.2.4936: MS-Windows: mouse coordinates for scroll event are wrong
Bram Moolenaar <Bram@vim.org>
parents: 28792
diff changeset
4294 ScreenToClient(s_textArea, &pt);
4c749f9b97fd patch 8.2.4936: MS-Windows: mouse coordinates for scroll event are wrong
Bram Moolenaar <Bram@vim.org>
parents: 28792
diff changeset
4295
29096
d2ef7d649fcb patch 8.2.5069: various warnings from clang on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 28825
diff changeset
4296 gui_send_mouse_event(button, pt.x, pt.y, FALSE, modifiers);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4297 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4298
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4299 #ifdef USE_SYSMENU_FONT
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4300 /*
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4301 * Get Menu Font.
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4302 * Return OK or FAIL.
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4303 */
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4304 static int
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
4305 gui_w32_get_menu_font(LOGFONTW *lf)
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
4306 {
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
4307 NONCLIENTMETRICSW nm;
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
4308
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
4309 nm.cbSize = sizeof(NONCLIENTMETRICSW);
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
4310 if (!SystemParametersInfoW(
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4311 SPI_GETNONCLIENTMETRICS,
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
4312 sizeof(NONCLIENTMETRICSW),
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4313 &nm,
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4314 0))
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4315 return FAIL;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4316 *lf = nm.lfMenuFont;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4317 return OK;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4318 }
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4319 #endif
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4320
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4321
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4322 #if defined(FEAT_GUI_TABLINE) && defined(USE_SYSMENU_FONT)
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4323 /*
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4324 * Set the GUI tabline font to the system menu font
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4325 */
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4326 static void
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4327 set_tabline_font(void)
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4328 {
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
4329 LOGFONTW lfSysmenu;
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4330 HFONT font;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4331 HWND hwnd;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4332 HDC hdc;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4333 HFONT hfntOld;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4334 TEXTMETRIC tm;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4335
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4336 if (gui_w32_get_menu_font(&lfSysmenu) != OK)
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4337 return;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4338
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4339 lfSysmenu.lfHeight = adjust_fontsize_by_dpi(lfSysmenu.lfHeight);
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
4340 font = CreateFontIndirectW(&lfSysmenu);
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4341
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4342 SendMessage(s_tabhwnd, WM_SETFONT, (WPARAM)font, TRUE);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4343
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4344 /*
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4345 * Compute the height of the font used for the tab text
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4346 */
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4347 hwnd = GetDesktopWindow();
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4348 hdc = GetWindowDC(hwnd);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4349 hfntOld = SelectFont(hdc, font);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4350
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4351 GetTextMetrics(hdc, &tm);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4352
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4353 SelectFont(hdc, hfntOld);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4354 ReleaseDC(hwnd, hdc);
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4355
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4356 /*
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4357 * 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
4358 * and the tab border is included as 7.
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4359 */
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4360 gui.tabline_height = tm.tmHeight + tm.tmInternalLeading + 7;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4361 }
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4362 #else
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4363 # define set_tabline_font()
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4364 #endif
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
4365
333
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4366 /*
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4367 * Invoked when a setting was changed.
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4368 */
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4369 static LRESULT CALLBACK
28700
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4370 _OnSettingChange(UINT param)
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4371 {
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4372 switch (param)
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4373 {
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4374 case SPI_SETWHEELSCROLLLINES:
28755
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4375 mouse_set_vert_scroll_step(mouse_vertical_scroll_step());
28700
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4376 break;
28755
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4377 case SPI_SETWHEELSCROLLCHARS:
26a2836923d6 patch 8.2.4902: mouse wheel scrolling is inconsistent
Bram Moolenaar <Bram@vim.org>
parents: 28700
diff changeset
4378 mouse_set_hor_scroll_step(mouse_horizontal_scroll_step());
28700
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4379 break;
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4380 case SPI_SETNONCLIENTMETRICS:
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4381 set_tabline_font();
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4382 break;
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4383 default:
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4384 break;
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4385 }
333
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4386 return 0;
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4387 }
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4388
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4389 #ifdef FEAT_NETBEANS_INTG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4390 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4391 _OnWindowPosChanged(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4392 HWND hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4393 const LPWINDOWPOS lpwpos)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4394 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4395 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
4396 extern int WSInitialized;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4397
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4398 if (WSInitialized && (lpwpos->x != x || lpwpos->y != y
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4399 || lpwpos->cx != cx || lpwpos->cy != cy))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4400 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4401 x = lpwpos->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4402 y = lpwpos->y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4403 cx = lpwpos->cx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4404 cy = lpwpos->cy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4405 netbeans_frame_moved(x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4406 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4407 // Allow to send WM_SIZE and WM_MOVE
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
4408 FORWARD_WM_WINDOWPOSCHANGED(hwnd, lpwpos, DefWindowProcW);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4409 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4410 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4411
24804
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4412
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4413 static HWND hwndTip = NULL;
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4414
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4415 static void
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4416 show_sizing_tip(int cols, int rows)
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4417 {
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
4418 TOOLINFOA ti;
24804
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4419 char buf[32];
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4420
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
4421 ti.cbSize = sizeof(ti);
24804
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4422 ti.hwnd = s_hwnd;
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4423 ti.uId = (UINT_PTR)s_hwnd;
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4424 ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4425 ti.lpszText = buf;
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4426 sprintf(buf, "%dx%d", cols, rows);
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4427 if (hwndTip == NULL)
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4428 {
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4429 hwndTip = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL,
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4430 WS_POPUP | TTS_ALWAYSTIP | TTS_NOPREFIX,
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4431 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4432 s_hwnd, NULL, GetModuleHandle(NULL), NULL);
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4433 SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4434 SendMessage(hwndTip, TTM_TRACKACTIVATE, TRUE, (LPARAM)&ti);
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4435 }
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4436 else
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4437 {
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4438 SendMessage(hwndTip, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4439 }
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4440 SendMessage(hwndTip, TTM_POPUP, 0, 0);
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4441 }
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4442
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4443 static void
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4444 destroy_sizing_tip(void)
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4445 {
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4446 if (hwndTip != NULL)
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4447 {
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4448 DestroyWindow(hwndTip);
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4449 hwndTip = NULL;
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4450 }
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4451 }
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4452
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4453 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4454 _DuringSizing(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4455 UINT fwSide,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4456 LPRECT lprc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4457 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4458 int w, h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4459 int valid_w, valid_h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4460 int w_offset, h_offset;
24804
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4461 int cols, rows;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4462
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4463 w = lprc->right - lprc->left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4464 h = lprc->bottom - lprc->top;
24804
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4465 gui_mswin_get_valid_dimensions(w, h, &valid_w, &valid_h, &cols, &rows);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4466 w_offset = w - valid_w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4467 h_offset = h - valid_h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4468
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4469 if (fwSide == WMSZ_LEFT || fwSide == WMSZ_TOPLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4470 || fwSide == WMSZ_BOTTOMLEFT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4471 lprc->left += w_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4472 else if (fwSide == WMSZ_RIGHT || fwSide == WMSZ_TOPRIGHT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4473 || fwSide == WMSZ_BOTTOMRIGHT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4474 lprc->right -= w_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4475
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4476 if (fwSide == WMSZ_TOP || fwSide == WMSZ_TOPLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4477 || fwSide == WMSZ_TOPRIGHT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4478 lprc->top += h_offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4479 else if (fwSide == WMSZ_BOTTOM || fwSide == WMSZ_BOTTOMLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4480 || fwSide == WMSZ_BOTTOMRIGHT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4481 lprc->bottom -= h_offset;
24804
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4482
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4483 show_sizing_tip(cols, rows);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4484 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4485 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4486
27261
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4487 #ifdef FEAT_GUI_TABLINE
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4488 static void
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4489 _OnRButtonUp(HWND hwnd, int x, int y, UINT keyFlags)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4490 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4491 if (gui_mch_showing_tabline())
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4492 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4493 POINT pt;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4494 RECT rect;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4495
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4496 /*
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4497 * If the cursor is on the tabline, display the tab menu
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4498 */
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4499 GetCursorPos(&pt);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4500 GetWindowRect(s_textArea, &rect);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4501 if (pt.y < rect.top)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4502 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4503 show_tabline_popup_menu();
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4504 return;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4505 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4506 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4507 FORWARD_WM_RBUTTONUP(hwnd, x, y, keyFlags, DefWindowProcW);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4508 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4509
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4510 static void
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4511 _OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4512 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4513 /*
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4514 * If the user double clicked the tabline, create a new tab
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4515 */
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4516 if (gui_mch_showing_tabline())
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4517 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4518 POINT pt;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4519 RECT rect;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4520
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4521 GetCursorPos(&pt);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4522 GetWindowRect(s_textArea, &rect);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4523 if (pt.y < rect.top)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4524 send_tabline_menu_event(0, TABLINE_MENU_NEW);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4525 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4526 FORWARD_WM_LBUTTONDOWN(hwnd, fDoubleClick, x, y, keyFlags, DefWindowProcW);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4527 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4528 #endif
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4529
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4530 static UINT
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4531 _OnNCHitTest(HWND hwnd, int xPos, int yPos)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4532 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4533 UINT result;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4534 int x, y;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4535
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4536 result = FORWARD_WM_NCHITTEST(hwnd, xPos, yPos, DefWindowProcW);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4537 if (result != HTCLIENT)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4538 return result;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4539
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4540 #ifdef FEAT_GUI_TABLINE
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4541 if (gui_mch_showing_tabline())
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4542 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4543 RECT rct;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4544
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4545 // If the cursor is on the GUI tabline, don't process this event
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4546 GetWindowRect(s_textArea, &rct);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4547 if (yPos < rct.top)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4548 return result;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4549 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4550 #endif
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4551 (void)gui_mch_get_winpos(&x, &y);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4552 xPos -= x;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4553
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4554 if (xPos < 48) // <VN> TODO should use system metric?
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4555 return HTBOTTOMLEFT;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4556 else
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4557 return HTBOTTOMRIGHT;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4558 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4559
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4560 #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4561 static LRESULT
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4562 _OnNotify(HWND hwnd, UINT id, NMHDR *hdr)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4563 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4564 switch (hdr->code)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4565 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4566 case TTN_GETDISPINFOW:
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4567 case TTN_GETDISPINFO:
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4568 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4569 char_u *str = NULL;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4570 static void *tt_text = NULL;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4571
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4572 VIM_CLEAR(tt_text);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4573
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4574 # ifdef FEAT_GUI_TABLINE
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4575 if (gui_mch_showing_tabline()
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4576 && hdr->hwndFrom == TabCtrl_GetToolTips(s_tabhwnd))
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4577 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4578 POINT pt;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4579 /*
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4580 * Mouse is over the GUI tabline. Display the
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4581 * tooltip for the tab under the cursor
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4582 *
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4583 * Get the cursor position within the tab control
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4584 */
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4585 GetCursorPos(&pt);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4586 if (ScreenToClient(s_tabhwnd, &pt) != 0)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4587 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4588 TCHITTESTINFO htinfo;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4589 int idx;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4590
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4591 /*
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4592 * Get the tab under the cursor
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4593 */
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4594 htinfo.pt.x = pt.x;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4595 htinfo.pt.y = pt.y;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4596 idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4597 if (idx != -1)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4598 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4599 tabpage_T *tp;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4600
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4601 tp = find_tabpage(idx + 1);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4602 if (tp != NULL)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4603 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4604 get_tabline_label(tp, TRUE);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4605 str = NameBuff;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4606 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4607 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4608 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4609 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4610 # endif
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4611 # ifdef FEAT_TOOLBAR
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4612 # ifdef FEAT_GUI_TABLINE
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4613 else
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4614 # endif
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4615 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4616 UINT idButton;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4617 vimmenu_T *pMenu;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4618
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4619 idButton = (UINT) hdr->idFrom;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4620 pMenu = gui_mswin_find_menu(root_menu, idButton);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4621 if (pMenu)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4622 str = pMenu->strings[MENU_INDEX_TIP];
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4623 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4624 # endif
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4625 if (str == NULL)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4626 break;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4627
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4628 // Set the maximum width, this also enables using \n for
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4629 // line break.
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4630 SendMessage(hdr->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 500);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4631
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4632 if (hdr->code == TTN_GETDISPINFOW)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4633 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4634 LPNMTTDISPINFOW lpdi = (LPNMTTDISPINFOW)hdr;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4635
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4636 tt_text = enc_to_utf16(str, NULL);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4637 lpdi->lpszText = tt_text;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4638 // can't show tooltip if failed
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4639 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4640 else
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4641 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4642 LPNMTTDISPINFO lpdi = (LPNMTTDISPINFO)hdr;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4643
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4644 if (STRLEN(str) < sizeof(lpdi->szText)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4645 || ((tt_text = vim_strsave(str)) == NULL))
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4646 vim_strncpy((char_u *)lpdi->szText, str,
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4647 sizeof(lpdi->szText) - 1);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4648 else
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4649 lpdi->lpszText = tt_text;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4650 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4651 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4652 break;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4653
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4654 # ifdef FEAT_GUI_TABLINE
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4655 case TCN_SELCHANGE:
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4656 if (gui_mch_showing_tabline() && (hdr->hwndFrom == s_tabhwnd))
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4657 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4658 send_tabline_event(TabCtrl_GetCurSel(s_tabhwnd) + 1);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4659 return 0L;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4660 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4661 break;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4662
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4663 case NM_RCLICK:
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4664 if (gui_mch_showing_tabline() && (hdr->hwndFrom == s_tabhwnd))
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4665 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4666 show_tabline_popup_menu();
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4667 return 0L;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4668 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4669 break;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4670 # endif
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4671
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4672 default:
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4673 break;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4674 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4675 return DefWindowProcW(hwnd, WM_NOTIFY, (WPARAM)id, (LPARAM)hdr);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4676 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4677 #endif
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4678
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4679 #if defined(MENUHINTS) && defined(FEAT_MENU)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4680 static LRESULT
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4681 _OnMenuSelect(HWND hwnd, WPARAM wParam, LPARAM lParam)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4682 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4683 if (((UINT) HIWORD(wParam)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4684 & (0xffff ^ (MF_MOUSESELECT + MF_BITMAP + MF_POPUP)))
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4685 == MF_HILITE
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 28755
diff changeset
4686 && (State & MODE_CMDLINE) == 0)
27261
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4687 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4688 UINT idButton;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4689 vimmenu_T *pMenu;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4690 static int did_menu_tip = FALSE;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4691
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4692 if (did_menu_tip)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4693 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4694 msg_clr_cmdline();
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4695 setcursor();
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4696 out_flush();
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4697 did_menu_tip = FALSE;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4698 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4699
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4700 idButton = (UINT)LOWORD(wParam);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4701 pMenu = gui_mswin_find_menu(root_menu, idButton);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4702 if (pMenu != NULL && pMenu->strings[MENU_INDEX_TIP] != 0
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4703 && GetMenuState(s_menuBar, pMenu->id, MF_BYCOMMAND) != -1)
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4704 {
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4705 ++msg_hist_off;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4706 msg((char *)pMenu->strings[MENU_INDEX_TIP]);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4707 --msg_hist_off;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4708 setcursor();
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4709 out_flush();
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4710 did_menu_tip = TRUE;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4711 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4712 return 0L;
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4713 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4714 return DefWindowProcW(hwnd, WM_MENUSELECT, wParam, lParam);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4715 }
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4716 #endif
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4717
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4718 static LRESULT
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
4719 _OnDpiChanged(HWND hwnd, UINT xdpi UNUSED, UINT ydpi, RECT *rc UNUSED)
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4720 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4721 s_dpi = ydpi;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4722 s_in_dpichanged = TRUE;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4723 //TRACE("DPI: %d", ydpi);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4724
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4725 update_scrollbar_size();
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4726 update_toolbar_size();
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4727 set_tabline_font();
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4728
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4729 gui_init_font(*p_guifont == NUL ? hl_get_font_name() : p_guifont, FALSE);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4730 gui_get_wide_font();
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4731 gui_mswin_get_menu_height(FALSE);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4732 #ifdef FEAT_MBYTE_IME
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4733 im_set_position(gui.row, gui.col);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4734 #endif
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4735 InvalidateRect(hwnd, NULL, TRUE);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4736
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4737 s_in_dpichanged = FALSE;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4738 return 0L;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4739 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4740
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4741
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4742 static LRESULT CALLBACK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4743 _WndProc(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4744 HWND hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4745 UINT uMsg,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4746 WPARAM wParam,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4747 LPARAM lParam)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4748 {
28825
4c749f9b97fd patch 8.2.4936: MS-Windows: mouse coordinates for scroll event are wrong
Bram Moolenaar <Bram@vim.org>
parents: 28792
diff changeset
4749 // ch_log(NULL, "WndProc: hwnd = %08x, msg = %x, wParam = %x, lParam = %x",
4c749f9b97fd patch 8.2.4936: MS-Windows: mouse coordinates for scroll event are wrong
Bram Moolenaar <Bram@vim.org>
parents: 28792
diff changeset
4750 // hwnd, uMsg, wParam, lParam);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4751
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4752 HandleMouseHide(uMsg, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4753
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4754 s_uMsg = uMsg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4755 s_wParam = wParam;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4756 s_lParam = lParam;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4757
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4758 switch (uMsg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4759 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4760 HANDLE_MSG(hwnd, WM_DEADCHAR, _OnDeadChar);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4761 HANDLE_MSG(hwnd, WM_SYSDEADCHAR, _OnDeadChar);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4762 // HANDLE_MSG(hwnd, WM_ACTIVATE, _OnActivate);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4763 HANDLE_MSG(hwnd, WM_CLOSE, _OnClose);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4764 // HANDLE_MSG(hwnd, WM_COMMAND, _OnCommand);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4765 HANDLE_MSG(hwnd, WM_DESTROY, _OnDestroy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4766 HANDLE_MSG(hwnd, WM_DROPFILES, _OnDropFiles);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4767 HANDLE_MSG(hwnd, WM_HSCROLL, _OnScroll);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4768 HANDLE_MSG(hwnd, WM_KILLFOCUS, _OnKillFocus);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4769 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4770 HANDLE_MSG(hwnd, WM_COMMAND, _OnMenu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4771 #endif
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4772 // HANDLE_MSG(hwnd, WM_MOVE, _OnMove);
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4773 // HANDLE_MSG(hwnd, WM_NCACTIVATE, _OnNCActivate);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4774 HANDLE_MSG(hwnd, WM_SETFOCUS, _OnSetFocus);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4775 HANDLE_MSG(hwnd, WM_SIZE, _OnSize);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4776 // HANDLE_MSG(hwnd, WM_SYSCOMMAND, _OnSysCommand);
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4777 // HANDLE_MSG(hwnd, WM_SYSKEYDOWN, _OnAltKey);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4778 HANDLE_MSG(hwnd, WM_VSCROLL, _OnScroll);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4779 // HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGING, _OnWindowPosChanging);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4780 HANDLE_MSG(hwnd, WM_ACTIVATEAPP, _OnActivateApp);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4781 #ifdef FEAT_NETBEANS_INTG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4782 HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGED, _OnWindowPosChanged);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4783 #endif
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4784 #ifdef FEAT_GUI_TABLINE
27261
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4785 HANDLE_MSG(hwnd, WM_RBUTTONUP, _OnRButtonUp);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4786 HANDLE_MSG(hwnd, WM_LBUTTONDBLCLK, _OnLButtonDown);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4787 #endif
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4788 HANDLE_MSG(hwnd, WM_NCHITTEST, _OnNCHitTest);
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
4789
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4790 case WM_QUERYENDSESSION: // System wants to go down.
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4791 gui_shell_closed(); // Will exit when no changed buffers.
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4792 return FALSE; // Do NOT allow system to go down.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4793
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4794 case WM_ENDSESSION:
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4795 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
4796 {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4797 _OnEndSession();
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4798 return 0L;
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4799 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4800 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4801
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4802 case WM_CHAR:
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4803 // Don't use HANDLE_MSG() for WM_CHAR, it truncates wParam to a single
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4804 // byte while we want the UTF-16 character value.
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 824
diff changeset
4805 _OnChar(hwnd, (UINT)wParam, (int)(short)LOWORD(lParam));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4806 return 0L;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4807
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4808 case WM_SYSCHAR:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4809 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4810 * if 'winaltkeys' is "no", or it's "menu" and it's not a menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4811 * shortcut key, handle like a typed ALT key, otherwise call Windows
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4812 * ALT key handling.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4813 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4814 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4815 if ( !gui.menu_is_active
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4816 || p_wak[0] == 'n'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4817 || (p_wak[0] == 'm' && !gui_is_menu_shortcut((int)wParam))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4818 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4819 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4820 {
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 824
diff changeset
4821 _OnSysChar(hwnd, (UINT)wParam, (int)(short)LOWORD(lParam));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4822 return 0L;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4823 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4824 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4825 else
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
4826 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4827 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4828
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4829 case WM_SYSKEYUP:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4830 #ifdef FEAT_MENU
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4831 // This used to be done only when menu is active: ALT key is used for
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4832 // that. But that caused problems when menu is disabled and using
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4833 // Alt-Tab-Esc: get into a strange state where no mouse-moved events
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4834 // are received, mouse pointer remains hidden.
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
4835 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4836 #else
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4837 return 0L;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4838 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4839
24804
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4840 case WM_EXITSIZEMOVE:
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4841 destroy_sizing_tip();
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4842 break;
324086c6f757 patch 8.2.2940: MS-Windows: cannot see the size when resizing
Bram Moolenaar <Bram@vim.org>
parents: 24768
diff changeset
4843
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4844 case WM_SIZING: // HANDLE_MSG doesn't seem to handle this one
323
03b3684919e3 updated for version 7.0084
vimboss
parents: 293
diff changeset
4845 return _DuringSizing((UINT)wParam, (LPRECT)lParam);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4846
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4847 case WM_MOUSEWHEEL:
28700
7fc67f9d84a7 patch 8.2.4874: Win32 GUI: horizontal scroll wheel not handled properly
Bram Moolenaar <Bram@vim.org>
parents: 28639
diff changeset
4848 case WM_MOUSEHWHEEL:
28825
4c749f9b97fd patch 8.2.4936: MS-Windows: mouse coordinates for scroll event are wrong
Bram Moolenaar <Bram@vim.org>
parents: 28792
diff changeset
4849 _OnMouseWheel(hwnd, wParam, lParam, uMsg == WM_MOUSEHWHEEL);
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4850 return 0L;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4851
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4852 // Notification for change in SystemParametersInfo()
333
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4853 case WM_SETTINGCHANGE:
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4854 return _OnSettingChange((UINT)wParam);
18f024844150 updated for version 7.0086
vimboss
parents: 323
diff changeset
4855
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
4856 #if defined(FEAT_TOOLBAR) || defined(FEAT_GUI_TABLINE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4857 case WM_NOTIFY:
27261
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4858 return _OnNotify(hwnd, (UINT)wParam, (NMHDR*)lParam);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4859 #endif
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4860
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4861 #if defined(MENUHINTS) && defined(FEAT_MENU)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4862 case WM_MENUSELECT:
27261
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4863 return _OnMenuSelect(hwnd, wParam, lParam);
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4864 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4865
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4866 #ifdef FEAT_MBYTE_IME
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4867 case WM_IME_NOTIFY:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4868 if (!_OnImeNotify(hwnd, (DWORD)wParam, (DWORD)lParam))
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
4869 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4870 return 1L;
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4871
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4872 case WM_IME_COMPOSITION:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4873 if (!_OnImeComposition(hwnd, wParam, lParam))
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
4874 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
3225
2260435283f2 updated for version 7.3.382
Bram Moolenaar <bram@vim.org>
parents: 3212
diff changeset
4875 return 1L;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4876 #endif
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4877 case WM_DPICHANGED:
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4878 return _OnDpiChanged(hwnd, (UINT)LOWORD(wParam), (UINT)HIWORD(wParam),
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
4879 (RECT*)lParam);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4880
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4881 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4882 #ifdef MSWIN_FIND_REPLACE
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
4883 if (uMsg == s_findrep_msg && s_findrep_msg != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4884 _OnFindRepl();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4885 #endif
27261
a63505f33894 patch 8.2.4159: MS-Windows: _WndProc() is very long
Bram Moolenaar <Bram@vim.org>
parents: 27259
diff changeset
4886 break;
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
4887 }
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
4888
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
4889 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4890 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4891
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4892 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4893 * End of call-back routines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4894 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4895
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4896 // parent window, if specified with -P
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4897 HWND vim_parent_hwnd = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4898
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4899 static BOOL CALLBACK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4900 FindWindowTitle(HWND hwnd, LPARAM lParam)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4901 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4902 char buf[2048];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4903 char *title = (char *)lParam;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4904
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4905 if (GetWindowText(hwnd, buf, sizeof(buf)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4906 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4907 if (strstr(buf, title) != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4908 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4909 // Found it. Store the window ref. and quit searching if MDI
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4910 // works.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4911 vim_parent_hwnd = FindWindowEx(hwnd, NULL, "MDIClient", NULL);
9
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4912 if (vim_parent_hwnd != NULL)
4102fb4ea781 updated for version 7.0002
vimboss
parents: 7
diff changeset
4913 return FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4914 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4915 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4916 return TRUE; // continue searching
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4917 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4918
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4919 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4920 * Invoked for '-P "title"' argument: search for parent application to open
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4921 * our window in.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4922 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4923 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4924 gui_mch_set_parent(char *title)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4925 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4926 EnumWindows(FindWindowTitle, (LPARAM)title);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4927 if (vim_parent_hwnd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4928 {
26952
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26893
diff changeset
4929 semsg(_(e_cannot_find_window_title_str), title);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4930 mch_exit(2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4931 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4932 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4933
323
03b3684919e3 updated for version 7.0084
vimboss
parents: 293
diff changeset
4934 #ifndef FEAT_OLE
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4935 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4936 ole_error(char *arg)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4937 {
1116
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
4938 char buf[IOSIZE];
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
4939
16596
2f86ca0c1e6b patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents: 16582
diff changeset
4940 # ifdef VIMDLL
2f86ca0c1e6b patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents: 16582
diff changeset
4941 gui.in_use = mch_is_gui_executable();
2f86ca0c1e6b patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents: 16582
diff changeset
4942 # endif
2f86ca0c1e6b patch 8.1.1301: when compiled with VIMDLL some messages are not shown
Bram Moolenaar <Bram@vim.org>
parents: 16582
diff changeset
4943
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
4944 // Can't use emsg() here, we have not finished initialisation yet.
1116
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
4945 vim_snprintf(buf, IOSIZE,
26893
79c76ca2c53c patch 8.2.3975: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26883
diff changeset
4946 _(e_argument_not_supported_str_use_ole_version), arg);
1116
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
4947 mch_errmsg(buf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4948 }
323
03b3684919e3 updated for version 7.0084
vimboss
parents: 293
diff changeset
4949 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4950
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4951 #if defined(GUI_MAY_SPAWN) || defined(PROTO)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4952 static char *
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4953 gvim_error(void)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4954 {
26966
ac75c145f0a9 patch 8.2.4012: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26952
diff changeset
4955 char *msg = _(e_gui_cannot_be_used_cannot_execute_gvim_exe);
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4956
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4957 if (starting)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4958 {
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4959 mch_errmsg(msg);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4960 mch_errmsg("\n");
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4961 mch_exit(2);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4962 }
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4963 return msg;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4964 }
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4965
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4966 char *
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4967 gui_mch_do_spawn(char_u *arg)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4968 {
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4969 int len;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4970 # if defined(FEAT_SESSION) && defined(EXPERIMENTAL_GUI_CMD)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4971 char_u *session = NULL;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4972 LPWSTR tofree1 = NULL;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4973 # endif
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4974 WCHAR name[MAX_PATH];
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4975 LPWSTR cmd, newcmd = NULL, p, warg, tofree2 = NULL;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4976 STARTUPINFOW si = {sizeof(si)};
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4977 PROCESS_INFORMATION pi;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4978
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4979 if (!GetModuleFileNameW(g_hinst, name, MAX_PATH))
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4980 goto error;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4981 p = wcsrchr(name, L'\\');
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4982 if (p == NULL)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4983 goto error;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4984 // Replace the executable name from vim(d).exe to gvim(d).exe.
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4985 # ifdef DEBUG
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4986 wcscpy(p + 1, L"gvimd.exe");
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4987 # else
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4988 wcscpy(p + 1, L"gvim.exe");
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4989 # endif
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4990
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4991 # if defined(FEAT_SESSION) && defined(EXPERIMENTAL_GUI_CMD)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4992 if (starting)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4993 # endif
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4994 {
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4995 // Pass the command line to the new process.
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4996 p = GetCommandLineW();
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4997 // Skip 1st argument.
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4998 while (*p && *p != L' ' && *p != L'\t')
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
4999 {
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5000 if (*p == L'"')
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5001 {
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5002 while (*p && *p != L'"')
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5003 ++p;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5004 if (*p)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5005 ++p;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5006 }
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5007 else
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5008 ++p;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5009 }
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5010 cmd = p;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5011 }
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5012 # if defined(FEAT_SESSION) && defined(EXPERIMENTAL_GUI_CMD)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5013 else
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5014 {
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5015 // Create a session file and pass it to the new process.
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5016 LPWSTR wsession;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5017 char_u *savebg;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5018 int ret;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5019
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5020 session = vim_tempname('s', FALSE);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5021 if (session == NULL)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5022 goto error;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5023 savebg = p_bg;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5024 p_bg = vim_strsave((char_u *)"light"); // Set 'bg' to "light".
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5025 ret = write_session_file(session);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5026 vim_free(p_bg);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5027 p_bg = savebg;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5028 if (!ret)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5029 goto error;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5030 wsession = enc_to_utf16(session, NULL);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5031 if (wsession == NULL)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5032 goto error;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5033 len = (int)wcslen(wsession) * 2 + 27 + 1;
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
5034 cmd = ALLOC_MULT(WCHAR, len);
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5035 if (cmd == NULL)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5036 {
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5037 vim_free(wsession);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5038 goto error;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5039 }
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5040 tofree1 = cmd;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5041 _snwprintf(cmd, len, L" -S \"%s\" -c \"call delete('%s')\"",
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5042 wsession, wsession);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5043 vim_free(wsession);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5044 }
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5045 # endif
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5046
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5047 // Check additional arguments to the `:gui` command.
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5048 if (arg != NULL)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5049 {
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5050 warg = enc_to_utf16(arg, NULL);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5051 if (warg == NULL)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5052 goto error;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5053 tofree2 = warg;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5054 }
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5055 else
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5056 warg = L"";
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5057
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5058 // Set up the new command line.
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5059 len = (int)wcslen(name) + (int)wcslen(cmd) + (int)wcslen(warg) + 4;
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
5060 newcmd = ALLOC_MULT(WCHAR, len);
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5061 if (newcmd == NULL)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5062 goto error;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5063 _snwprintf(newcmd, len, L"\"%s\"%s %s", name, cmd, warg);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5064
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5065 // Spawn a new GUI process.
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5066 if (!CreateProcessW(NULL, newcmd, NULL, NULL, TRUE, 0,
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5067 NULL, NULL, &si, &pi))
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5068 goto error;
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5069 CloseHandle(pi.hProcess);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5070 CloseHandle(pi.hThread);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5071 mch_exit(0);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5072
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5073 error:
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5074 # if defined(FEAT_SESSION) && defined(EXPERIMENTAL_GUI_CMD)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5075 if (session)
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5076 mch_remove(session);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5077 vim_free(session);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5078 vim_free(tofree1);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5079 # endif
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5080 vim_free(newcmd);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5081 vim_free(tofree2);
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5082 return gvim_error();
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5083 }
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5084 #endif
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5085
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5086 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5087 * Parse the GUI related command-line arguments. Any arguments used are
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5088 * deleted from argv, and *argc is decremented accordingly. This is called
24768
7334bf933510 patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents: 22922
diff changeset
5089 * when Vim is started, whether or not the GUI has been started.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5090 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5091 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5092 gui_mch_prepare(int *argc, char **argv)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5093 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5094 int silent = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5095 int idx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5096
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5097 // Check for special OLE command line parameters
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5098 if ((*argc == 2 || *argc == 3) && (argv[1][0] == '-' || argv[1][0] == '/'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5099 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5100 // Check for a "-silent" argument first.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5101 if (*argc == 3 && STRICMP(argv[1] + 1, "silent") == 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5102 && (argv[2][0] == '-' || argv[2][0] == '/'))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5103 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5104 silent = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5105 idx = 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5106 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5107 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5108 idx = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5109
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5110 // Register Vim as an OLE Automation server
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5111 if (STRICMP(argv[idx] + 1, "register") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5112 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5113 #ifdef FEAT_OLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5114 RegisterMe(silent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5115 mch_exit(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5116 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5117 if (!silent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5118 ole_error("register");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5119 mch_exit(2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5120 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5121 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5122
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5123 // Unregister Vim as an OLE Automation server
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5124 if (STRICMP(argv[idx] + 1, "unregister") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5125 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5126 #ifdef FEAT_OLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5127 UnregisterMe(!silent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5128 mch_exit(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5129 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5130 if (!silent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5131 ole_error("unregister");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5132 mch_exit(2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5133 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5134 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5135
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5136 // Ignore an -embedding argument. It is only relevant if the
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5137 // application wants to treat the case when it is started manually
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5138 // differently from the case where it is started via automation (and
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5139 // we don't).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5140 if (STRICMP(argv[idx] + 1, "embedding") == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5141 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5142 #ifdef FEAT_OLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5143 *argc = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5144 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5145 ole_error("embedding");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5146 mch_exit(2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5147 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5148 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5149 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5151 #ifdef FEAT_OLE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5152 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5153 int bDoRestart = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5154
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5155 InitOLE(&bDoRestart);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5156 // automatically exit after registering
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5157 if (bDoRestart)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5158 mch_exit(0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5159 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5160 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5161
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5162 #ifdef FEAT_NETBEANS_INTG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5163 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5164 // stolen from gui_x11.c
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5165 int arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5166
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5167 for (arg = 1; arg < *argc; arg++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5168 if (strncmp("-nb", argv[arg], 3) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5169 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5170 netbeansArg = argv[arg];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5171 mch_memmove(&argv[arg], &argv[arg + 1],
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5172 (--*argc - arg) * sizeof(char *));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5173 argv[*argc] = NULL;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5174 break; // enough?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5175 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5176 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5177 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5178 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5179
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5180 static void
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5181 load_dpi_func(void)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5182 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5183 HMODULE hUser32;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5184
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5185 hUser32 = GetModuleHandle("user32.dll");
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5186 if (hUser32 == NULL)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5187 goto fail;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5188
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
5189 pGetDpiForSystem = (UINT (WINAPI *)(void))GetProcAddress(hUser32, "GetDpiForSystem");
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
5190 pGetDpiForWindow = (UINT (WINAPI *)(HWND))GetProcAddress(hUser32, "GetDpiForWindow");
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
5191 pGetSystemMetricsForDpi = (int (WINAPI *)(int, UINT))GetProcAddress(hUser32, "GetSystemMetricsForDpi");
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5192 //pGetWindowDpiAwarenessContext = (void*)GetProcAddress(hUser32, "GetWindowDpiAwarenessContext");
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
5193 pSetThreadDpiAwarenessContext = (DPI_AWARENESS_CONTEXT (WINAPI *)(DPI_AWARENESS_CONTEXT))GetProcAddress(hUser32, "SetThreadDpiAwarenessContext");
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
5194 pGetAwarenessFromDpiAwarenessContext = (DPI_AWARENESS (WINAPI *)(DPI_AWARENESS_CONTEXT))GetProcAddress(hUser32, "GetAwarenessFromDpiAwarenessContext");
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5195
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5196 if (pSetThreadDpiAwarenessContext != NULL)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5197 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5198 DPI_AWARENESS_CONTEXT oldctx = pSetThreadDpiAwarenessContext(
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5199 DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5200 if (oldctx != NULL)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5201 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5202 TRACE("DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 enabled");
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5203 s_process_dpi_aware = pGetAwarenessFromDpiAwarenessContext(oldctx);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5204 #ifdef DEBUG
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5205 if (s_process_dpi_aware == DPI_AWARENESS_UNAWARE)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5206 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5207 TRACE("WARNING: PerMonitorV2 is not enabled in the process level for some reasons. IME window may not shown correctly.");
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5208 }
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5209 #endif
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5210 return;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5211 }
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5212 }
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5213
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5214 fail:
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5215 // Disable PerMonitorV2 APIs.
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5216 pGetDpiForSystem = stubGetDpiForSystem;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5217 pGetDpiForWindow = NULL;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5218 pGetSystemMetricsForDpi = stubGetSystemMetricsForDpi;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5219 pSetThreadDpiAwarenessContext = NULL;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5220 pGetAwarenessFromDpiAwarenessContext = NULL;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5221 }
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5222
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5223 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5224 * Initialise the GUI. Create all the windows, set up all the call-backs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5225 * etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5226 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5227 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5228 gui_mch_init(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5229 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5230 const WCHAR szVimWndClassW[] = VIM_CLASSW;
2078
d7ce3adb8dda updated for version 7.2.362
Bram Moolenaar <bram@zimbu.org>
parents: 2026
diff changeset
5231 const WCHAR szTextAreaClassW[] = L"VimTextArea";
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5232 WNDCLASSW wndclassw;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5233
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5234 // Return here if the window was already opened (happens when
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5235 // gui_mch_dialog() is called early).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5236 if (s_hwnd != NULL)
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
5237 goto theend;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5238
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5239 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5240 * Load the tearoff bitmap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5241 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5242 #ifdef FEAT_TEAROFF
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5243 s_htearbitmap = LoadBitmap(g_hinst, "IDB_TEAROFF");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5244 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5245
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5246 load_dpi_func();
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5247
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5248 s_dpi = pGetDpiForSystem();
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5249 update_scrollbar_size();
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5250
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5251 #ifdef FEAT_MENU
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5252 gui.menu_height = 0; // Windows takes care of this
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5253 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5254 gui.border_width = 0;
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5255 #ifdef FEAT_TOOLBAR
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5256 gui.toolbar_height = TOOLBAR_BUTTON_HEIGHT + TOOLBAR_BORDER_HEIGHT;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5257 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5258
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5259 s_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5260
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5261 // First try using the wide version, so that we can use any title.
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5262 // Otherwise only characters in the active codepage will work.
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5263 if (GetClassInfoW(g_hinst, szVimWndClassW, &wndclassw) == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5264 {
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
5265 wndclassw.style = CS_DBLCLKS;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5266 wndclassw.lpfnWndProc = _WndProc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5267 wndclassw.cbClsExtra = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5268 wndclassw.cbWndExtra = 0;
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5269 wndclassw.hInstance = g_hinst;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5270 wndclassw.hIcon = LoadIcon(wndclassw.hInstance, "IDR_VIM");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5271 wndclassw.hCursor = LoadCursor(NULL, IDC_ARROW);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5272 wndclassw.hbrBackground = s_brush;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5273 wndclassw.lpszMenuName = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5274 wndclassw.lpszClassName = szVimWndClassW;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5275
27249
d5570658f18d patch 8.2.4153: MS-Windows: Global IME is no longer supported
Bram Moolenaar <Bram@vim.org>
parents: 27229
diff changeset
5276 if (RegisterClassW(&wndclassw) == 0)
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5277 return FAIL;
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5278 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5280 if (vim_parent_hwnd != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5281 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5282 #ifdef HAVE_TRY_EXCEPT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5283 __try
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5284 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5285 #endif
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5286 // Open inside the specified parent window.
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5287 // TODO: last argument should point to a CLIENTCREATESTRUCT
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5288 // structure.
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5289 s_hwnd = CreateWindowExW(
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5290 WS_EX_MDICHILD,
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5291 szVimWndClassW, L"Vim MSWindows GUI",
3006
125c7bf52271 updated for version 7.3.275
Bram Moolenaar <bram@vim.org>
parents: 2943
diff changeset
5292 WS_OVERLAPPEDWINDOW | WS_CHILD
125c7bf52271 updated for version 7.3.275
Bram Moolenaar <bram@vim.org>
parents: 2943
diff changeset
5293 | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | 0xC000,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5294 gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5295 gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5296 100, // Any value will do
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5297 100, // Any value will do
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5298 vim_parent_hwnd, NULL,
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5299 g_hinst, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5300 #ifdef HAVE_TRY_EXCEPT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5301 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5302 __except(EXCEPTION_EXECUTE_HANDLER)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5303 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5304 // NOP
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5305 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5306 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5307 if (s_hwnd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5308 {
26952
b34ddbca305c patch 8.2.4005: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26893
diff changeset
5309 emsg(_(e_unable_to_open_window_inside_mdi_application));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5310 mch_exit(2);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5311 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5312 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5313 else
1376
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5314 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5315 // If the provided windowid is not valid reset it to zero, so that it
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5316 // is ignored and we open our own window.
1376
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5317 if (IsWindow((HWND)win_socket_id) <= 0)
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5318 win_socket_id = 0;
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5319
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5320 // Create a window. If win_socket_id is not zero without border and
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5321 // titlebar, it will be reparented below.
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5322 s_hwnd = CreateWindowW(
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5323 szVimWndClassW, L"Vim MSWindows GUI",
3006
125c7bf52271 updated for version 7.3.275
Bram Moolenaar <bram@vim.org>
parents: 2943
diff changeset
5324 (win_socket_id == 0 ? WS_OVERLAPPEDWINDOW : WS_POPUP)
125c7bf52271 updated for version 7.3.275
Bram Moolenaar <bram@vim.org>
parents: 2943
diff changeset
5325 | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
1376
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5326 gui_win_x == -1 ? CW_USEDEFAULT : gui_win_x,
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5327 gui_win_y == -1 ? CW_USEDEFAULT : gui_win_y,
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5328 100, // Any value will do
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5329 100, // Any value will do
1376
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5330 NULL, NULL,
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5331 g_hinst, NULL);
1376
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5332 if (s_hwnd != NULL && win_socket_id != 0)
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5333 {
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5334 SetParent(s_hwnd, (HWND)win_socket_id);
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5335 ShowWindow(s_hwnd, SW_SHOWMAXIMIZED);
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5336 }
53b2bedccfdf updated for version 7.1-091
vimboss
parents: 1356
diff changeset
5337 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5338
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5339 if (s_hwnd == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5340 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5341
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5342 if (pGetDpiForWindow != NULL)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5343 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5344 s_dpi = pGetDpiForWindow(s_hwnd);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5345 update_scrollbar_size();
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5346 //TRACE("System DPI: %d, DPI: %d", pGetDpiForSystem(), s_dpi);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5347 }
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5348
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5349 #if defined(FEAT_MBYTE_IME) && defined(DYNAMIC_IME)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5350 dyn_imm_load();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5351 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5352
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5353 // Create the text area window
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5354 if (GetClassInfoW(g_hinst, szTextAreaClassW, &wndclassw) == 0)
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5355 {
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5356 wndclassw.style = CS_OWNDC;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5357 wndclassw.lpfnWndProc = _TextAreaWndProc;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5358 wndclassw.cbClsExtra = 0;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5359 wndclassw.cbWndExtra = 0;
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5360 wndclassw.hInstance = g_hinst;
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5361 wndclassw.hIcon = NULL;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5362 wndclassw.hCursor = LoadCursor(NULL, IDC_ARROW);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5363 wndclassw.hbrBackground = NULL;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5364 wndclassw.lpszMenuName = NULL;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5365 wndclassw.lpszClassName = szTextAreaClassW;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5366
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5367 if (RegisterClassW(&wndclassw) == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5368 return FAIL;
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5369 }
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5370
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5371 s_textArea = CreateWindowExW(
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5372 0,
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5373 szTextAreaClassW, L"Vim text area",
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5374 WS_CHILD | WS_VISIBLE, 0, 0,
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5375 100, // Any value will do for now
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5376 100, // Any value will do for now
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
5377 s_hwnd, NULL,
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
5378 g_hinst, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5379
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5380 if (s_textArea == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5381 return FAIL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5382
8100
ae50910ce279 commit https://github.com/vim/vim/commit/203219048fa007b5042d9b893fd647aef44722a0
Christian Brabandt <cb@256bit.org>
parents: 8090
diff changeset
5383 #ifdef FEAT_LIBCALL
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5384 // Try loading an icon from $RUNTIMEPATH/bitmaps/vim.ico.
6249
7816c24ff890 updated for version 7.4.459
Bram Moolenaar <bram@vim.org>
parents: 6226
diff changeset
5385 {
7816c24ff890 updated for version 7.4.459
Bram Moolenaar <bram@vim.org>
parents: 6226
diff changeset
5386 HANDLE hIcon = NULL;
7816c24ff890 updated for version 7.4.459
Bram Moolenaar <bram@vim.org>
parents: 6226
diff changeset
5387
7816c24ff890 updated for version 7.4.459
Bram Moolenaar <bram@vim.org>
parents: 6226
diff changeset
5388 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
5389 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
5390 }
8100
ae50910ce279 commit https://github.com/vim/vim/commit/203219048fa007b5042d9b893fd647aef44722a0
Christian Brabandt <cb@256bit.org>
parents: 8090
diff changeset
5391 #endif
6249
7816c24ff890 updated for version 7.4.459
Bram Moolenaar <bram@vim.org>
parents: 6226
diff changeset
5392
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5393 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5394 s_menuBar = CreateMenu();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5395 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5396 s_hdc = GetDC(s_textArea);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5397
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5398 DragAcceptFiles(s_hwnd, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5399
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5400 // Do we need to bother with this?
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5401 // m_fMouseAvail = pGetSystemMetricsForDpi(SM_MOUSEPRESENT, s_dpi);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5402
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5403 // Get background/foreground colors from the system
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5404 gui_mch_def_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5405
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5406 // Get the colors from the "Normal" group (set in syntax.c or in a vimrc
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5407 // file)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5408 set_normal_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5409
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5410 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5411 * Check that none of the colors are the same as the background color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5412 * Then store the current values as the defaults.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5413 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5414 gui_check_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5415 gui.def_norm_pixel = gui.norm_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5416 gui.def_back_pixel = gui.back_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5417
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5418 // Get the colors for the highlight groups (gui_check_colors() might have
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5419 // changed them)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5420 highlight_gui_started();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5421
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5422 /*
7243
861a44fc5183 commit https://github.com/vim/vim/commit/97b0b0ec764d3a247ef600d809b965d5ab37155d
Christian Brabandt <cb@256bit.org>
parents: 7060
diff changeset
5423 * Start out by adding the configured border width into the border offset.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5424 */
7243
861a44fc5183 commit https://github.com/vim/vim/commit/97b0b0ec764d3a247ef600d809b965d5ab37155d
Christian Brabandt <cb@256bit.org>
parents: 7060
diff changeset
5425 gui.border_offset = gui.border_width;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5426
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5427 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5428 * Set up for Intellimouse processing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5429 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5430 init_mouse_wheel();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5431
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5432 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5433 * compute a couple of metrics used for the dialogs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5434 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5435 get_dialog_font_metrics();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5436 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5437 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5438 * Create the toolbar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5439 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5440 initialise_toolbar();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5441 #endif
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5442 #ifdef FEAT_GUI_TABLINE
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5443 /*
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5444 * Create the tabline
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5445 */
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5446 initialise_tabline();
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
5447 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5448 #ifdef MSWIN_FIND_REPLACE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5449 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5450 * Initialise the dialog box stuff
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5451 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5452 s_findrep_msg = RegisterWindowMessage(FINDMSGSTRING);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5453
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5454 // Initialise the struct
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5455 s_findrep_struct.lStructSize = sizeof(s_findrep_struct);
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
5456 s_findrep_struct.lpstrFindWhat = ALLOC_MULT(WCHAR, MSWIN_FR_BUFSIZE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5457 s_findrep_struct.lpstrFindWhat[0] = NUL;
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
5458 s_findrep_struct.lpstrReplaceWith = ALLOC_MULT(WCHAR, MSWIN_FR_BUFSIZE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5459 s_findrep_struct.lpstrReplaceWith[0] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5460 s_findrep_struct.wFindWhatLen = MSWIN_FR_BUFSIZE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5461 s_findrep_struct.wReplaceWithLen = MSWIN_FR_BUFSIZE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5462 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5463
2616
73d947c20291 updated for version 7.3.038
Bram Moolenaar <bram@vim.org>
parents: 2614
diff changeset
5464 #ifdef FEAT_EVAL
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5465 // set the v:windowid variable
2865
46544d3ae7ec updated for version 7.3.206
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
5466 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
5467 #endif
73d947c20291 updated for version 7.3.038
Bram Moolenaar <bram@vim.org>
parents: 2614
diff changeset
5468
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
5469 #ifdef FEAT_RENDER_OPTIONS
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
5470 if (p_rop)
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
5471 (void)gui_mch_set_rendering_options(p_rop);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
5472 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
5473
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
5474 theend:
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5475 // Display any pending error messages
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
5476 display_errors();
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
5477
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5478 return OK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5479 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5480
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5481 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5482 * Get the size of the screen, taking position on multiple monitors into
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5483 * account (if supported).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5484 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5485 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5486 get_work_area(RECT *spi_rect)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5487 {
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5488 HMONITOR mon;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5489 MONITORINFO moninfo;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5490
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5491 // work out which monitor the window is on, and get *its* work area
10438
935bdb919a50 commit https://github.com/vim/vim/commit/87f3d202a90bd2d08a7afd55b3486b10bef858bb
Christian Brabandt <cb@256bit.org>
parents: 10359
diff changeset
5492 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
5493 if (mon != NULL)
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5494 {
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5495 moninfo.cbSize = sizeof(MONITORINFO);
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5496 if (GetMonitorInfo(mon, &moninfo))
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5497 {
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5498 *spi_rect = moninfo.rcWork;
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5499 return;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5500 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5501 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5502 // this is the old method...
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5503 SystemParametersInfo(SPI_GETWORKAREA, 0, spi_rect, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5504 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5505
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5506 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5507 * Set the size of the window to the given width and height in pixels.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5508 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5509 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
5510 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
5511 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
5512 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
5513 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
5514 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
5515 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
5516 int base_height UNUSED,
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 810
diff changeset
5517 int direction)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5518 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5519 RECT workarea_rect;
21351
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5520 RECT window_rect;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5521 int win_width, win_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5522
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5523 // Try to keep window completely on screen.
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5524 // Get position of the screen work area. This is the part that is not
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5525 // used by the taskbar or appbars.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5526 get_work_area(&workarea_rect);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5527
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5528 // Resizing a maximized window looks very strange, unzoom it first.
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5529 // But don't do it when still starting up, it may have been requested in
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5530 // the shortcut.
21351
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5531 if (IsZoomed(s_hwnd) && starting == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5532 ShowWindow(s_hwnd, SW_SHOWNORMAL);
21351
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5533
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5534 GetWindowRect(s_hwnd, &window_rect);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5535
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5536 // compute the size of the outside of the window
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5537 win_width = width + (pGetSystemMetricsForDpi(SM_CXFRAME, s_dpi) +
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5538 pGetSystemMetricsForDpi(SM_CXPADDEDBORDER, s_dpi)) * 2;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5539 win_height = height + (pGetSystemMetricsForDpi(SM_CYFRAME, s_dpi) +
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5540 pGetSystemMetricsForDpi(SM_CXPADDEDBORDER, s_dpi)) * 2
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5541 + pGetSystemMetricsForDpi(SM_CYCAPTION, s_dpi)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5542 + gui_mswin_get_menu_height(FALSE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5543
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5544 // The following should take care of keeping Vim on the same monitor, no
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5545 // matter if the secondary monitor is left or right of the primary
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5546 // monitor.
21351
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5547 window_rect.right = window_rect.left + win_width;
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5548 window_rect.bottom = window_rect.top + win_height;
3248
e0248b732a5c updated for version 7.3.393
Bram Moolenaar <bram@vim.org>
parents: 3225
diff changeset
5549
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5550 // If the window is going off the screen, move it on to the screen.
21351
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5551 if ((direction & RESIZE_HOR) && window_rect.right > workarea_rect.right)
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5552 OffsetRect(&window_rect, workarea_rect.right - window_rect.right, 0);
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5553
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5554 if ((direction & RESIZE_HOR) && window_rect.left < workarea_rect.left)
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5555 OffsetRect(&window_rect, workarea_rect.left - window_rect.left, 0);
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5556
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5557 if ((direction & RESIZE_VERT) && window_rect.bottom > workarea_rect.bottom)
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5558 OffsetRect(&window_rect, 0, workarea_rect.bottom - window_rect.bottom);
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5559
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5560 if ((direction & RESIZE_VERT) && window_rect.top < workarea_rect.top)
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5561 OffsetRect(&window_rect, 0, workarea_rect.top - window_rect.top);
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5562
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5563 MoveWindow(s_hwnd, window_rect.left, window_rect.top,
a4f213630151 patch 8.2.1226: MS-Windows: windows positioning wrong depending on taskbar
Bram Moolenaar <Bram@vim.org>
parents: 20421
diff changeset
5564 win_width, win_height, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5565
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5566 SetActiveWindow(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5567 SetFocus(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5568
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5569 // Menu may wrap differently now
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5570 gui_mswin_get_menu_height(!gui.starting);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5571 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5572
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5573
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5574 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5575 gui_mch_set_scrollbar_thumb(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5576 scrollbar_T *sb,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5577 long val,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5578 long size,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5579 long max)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5580 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5581 SCROLLINFO info;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5582
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5583 sb->scroll_shift = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5584 while (max > 32767)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5585 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5586 max = (max + 1) >> 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5587 val >>= 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5588 size >>= 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5589 ++sb->scroll_shift;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5590 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5591
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5592 if (sb->scroll_shift > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5593 ++size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5594
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5595 info.cbSize = sizeof(info);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5596 info.fMask = SIF_POS | SIF_RANGE | SIF_PAGE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5597 info.nPos = val;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5598 info.nMin = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5599 info.nMax = max;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5600 info.nPage = size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5601 SetScrollInfo(sb->id, SB_CTL, &info, TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5602 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5603
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5604
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5605 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5606 * Set the current text font.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5607 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5608 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5609 gui_mch_set_font(GuiFont font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5610 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5611 gui.currFont = font;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5612 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5613
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5614
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5615 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5616 * Set the current text foreground color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5617 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5618 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5619 gui_mch_set_fg_color(guicolor_T color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5620 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5621 gui.currFgColor = color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5622 }
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 * Set the current text background color.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5626 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5627 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5628 gui_mch_set_bg_color(guicolor_T color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5629 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5630 gui.currBgColor = color;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5631 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5632
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5633 /*
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5634 * Set the current text special color.
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5635 */
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5636 void
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5637 gui_mch_set_sp_color(guicolor_T color)
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5638 {
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5639 gui.currSpColor = color;
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5640 }
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
5641
12950
e60b2aa04903 patch 8.0.1351: warning for unused variables building with MinGW
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
5642 #ifdef FEAT_MBYTE_IME
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5643 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5644 * Multi-byte handling, originally by Sung-Hoon Baek.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5645 * First static functions (no prototypes generated).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5646 */
12950
e60b2aa04903 patch 8.0.1351: warning for unused variables building with MinGW
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
5647 # ifdef _MSC_VER
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5648 # include <ime.h> // Apparently not needed for Cygwin or MinGW.
12950
e60b2aa04903 patch 8.0.1351: warning for unused variables building with MinGW
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
5649 # endif
e60b2aa04903 patch 8.0.1351: warning for unused variables building with MinGW
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
5650 # include <imm.h>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5651
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5652 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5653 * handle WM_IME_NOTIFY message
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5654 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5655 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
5656 _OnImeNotify(HWND hWnd, DWORD dwCommand, DWORD dwData UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5657 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5658 LRESULT lResult = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5659 HIMC hImc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5660
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5661 if (!pImmGetContext || (hImc = pImmGetContext(hWnd)) == (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5662 return lResult;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5663 switch (dwCommand)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5664 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5665 case IMN_SETOPENSTATUS:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5666 if (pImmGetOpenStatus(hImc))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5667 {
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5668 LOGFONTW lf = norm_logfont;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5669 if (s_process_dpi_aware == DPI_AWARENESS_UNAWARE)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5670 // Work around when PerMonitorV2 is not enabled in the process level.
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5671 lf.lfHeight = lf.lfHeight * DEFAULT_DPI / s_dpi;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5672 pImmSetCompositionFontW(hImc, &lf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5673 im_set_position(gui.row, gui.col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5674
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5675 // Disable langmap
28773
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 28755
diff changeset
5676 State &= ~MODE_LANGMAP;
d770568e6c98 patch 8.2.4911: the mode #defines are not clearly named
Bram Moolenaar <Bram@vim.org>
parents: 28755
diff changeset
5677 if (State & MODE_INSERT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5678 {
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5679 # if defined(FEAT_KEYMAP)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5680 // Unshown 'keymap' in status lines
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5681 if (curbuf->b_p_iminsert == B_IMODE_LMAP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5682 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5683 // Save cursor position
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5684 int old_row = gui.row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5685 int old_col = gui.col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5686
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5687 // This must be called here before
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5688 // status_redraw_curbuf(), otherwise the mode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5689 // message may appear in the wrong position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5690 showmode();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5691 status_redraw_curbuf();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5692 update_screen(0);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5693 // Restore cursor position
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5694 gui.row = old_row;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5695 gui.col = old_col;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5696 }
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
5697 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5698 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5699 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5700 gui_update_cursor(TRUE, FALSE);
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5701 gui_mch_flush();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5702 lResult = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5703 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5704 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5705 pImmReleaseContext(hWnd, hImc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5706 return lResult;
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 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
5710 _OnImeComposition(HWND hwnd, WPARAM dbcs UNUSED, LPARAM param)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5711 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5712 char_u *ret;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5713 int len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5714
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5715 if ((param & GCS_RESULTSTR) == 0) // Composition unfinished.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5716 return 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5717
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5718 ret = GetResultStr(hwnd, GCS_RESULTSTR, &len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5719 if (ret != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5720 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5721 add_to_input_buf_csi(ret, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5722 vim_free(ret);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5723 return 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5724 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5725 return 0;
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 * void GetResultStr()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5730 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5731 * This handles WM_IME_COMPOSITION with GCS_RESULTSTR flag on.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5732 * get complete composition string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5733 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5734 static char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5735 GetResultStr(HWND hwnd, int GCS, int *lenp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5736 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5737 HIMC hIMC; // Input context handle.
27229
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
5738 LONG ret;
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
5739 WCHAR *buf = NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5740 char_u *convbuf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5741
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5742 if (!pImmGetContext || (hIMC = pImmGetContext(hwnd)) == (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5743 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5744
27229
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
5745 // Get the length of the composition string.
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
5746 ret = pImmGetCompositionStringW(hIMC, GCS, NULL, 0);
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
5747 if (ret <= 0)
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
5748 return NULL;
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
5749
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
5750 // Allocate the requested buffer plus space for the NUL character.
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
5751 buf = alloc(ret + sizeof(WCHAR));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5752 if (buf == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5753 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5754
27229
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
5755 // Reads in the composition string.
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
5756 pImmGetCompositionStringW(hIMC, GCS, buf, ret);
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
5757 *lenp = ret / sizeof(WCHAR);
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
5758
1752
a8aae2e1d2ae updated for version 7.2-049
vimboss
parents: 1621
diff changeset
5759 convbuf = utf16_to_enc(buf, lenp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5760 pImmReleaseContext(hwnd, hIMC);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5761 vim_free(buf);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5762 return convbuf;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5763 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5764 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5765
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5766 // For global functions we need prototypes.
12950
e60b2aa04903 patch 8.0.1351: warning for unused variables building with MinGW
Christian Brabandt <cb@256bit.org>
parents: 12934
diff changeset
5767 #if defined(FEAT_MBYTE_IME) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5768
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5769 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5770 * set font to IM.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5771 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5772 void
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
5773 im_set_font(LOGFONTW *lf)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5774 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5775 HIMC hImc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5776
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5777 if (pImmGetContext && (hImc = pImmGetContext(s_hwnd)) != (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5778 {
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
5779 pImmSetCompositionFontW(hImc, lf);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5780 pImmReleaseContext(s_hwnd, hImc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5781 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5782 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5783
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5784 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5785 * Notify cursor position to IM.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5786 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5787 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5788 im_set_position(int row, int col)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5789 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5790 HIMC hImc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5791
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5792 if (pImmGetContext && (hImc = pImmGetContext(s_hwnd)) != (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5793 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5794 COMPOSITIONFORM cfs;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5795
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5796 cfs.dwStyle = CFS_POINT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5797 cfs.ptCurrentPos.x = FILL_X(col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5798 cfs.ptCurrentPos.y = FILL_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5799 MapWindowPoints(s_textArea, s_hwnd, &cfs.ptCurrentPos, 1);
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5800 if (s_process_dpi_aware == DPI_AWARENESS_UNAWARE)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5801 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5802 // Work around when PerMonitorV2 is not enabled in the process level.
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5803 cfs.ptCurrentPos.x = cfs.ptCurrentPos.x * DEFAULT_DPI / s_dpi;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5804 cfs.ptCurrentPos.y = cfs.ptCurrentPos.y * DEFAULT_DPI / s_dpi;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
5805 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5806 pImmSetCompositionWindow(hImc, &cfs);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5807
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5808 pImmReleaseContext(s_hwnd, hImc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5809 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5810 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5811
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5812 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5813 * Set IM status on ("active" is TRUE) or off ("active" is FALSE).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5814 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5815 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5816 im_set_active(int active)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5817 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5818 HIMC hImc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5819 static HIMC hImcOld = (HIMC)0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5820
18742
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18662
diff changeset
5821 # ifdef VIMDLL
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18662
diff changeset
5822 if (!gui.in_use && !gui.starting)
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18662
diff changeset
5823 {
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18662
diff changeset
5824 mbyte_im_set_active(active);
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18662
diff changeset
5825 return;
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18662
diff changeset
5826 }
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18662
diff changeset
5827 # endif
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18662
diff changeset
5828
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5829 if (pImmGetContext) // if NULL imm32.dll wasn't loaded (yet)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5830 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5831 if (p_imdisable)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5832 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5833 if (hImcOld == (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5834 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5835 hImcOld = pImmGetContext(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5836 if (hImcOld)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5837 pImmAssociateContext(s_hwnd, (HIMC)0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5838 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5839 active = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5840 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5841 else if (hImcOld != (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5842 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5843 pImmAssociateContext(s_hwnd, hImcOld);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5844 hImcOld = (HIMC)0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5845 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5846
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5847 hImc = pImmGetContext(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5848 if (hImc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5849 {
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5850 /*
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5851 * for Korean ime
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5852 */
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5853 HKL hKL = GetKeyboardLayout(0);
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5854
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5855 if (LOWORD(hKL) == MAKELANGID(LANG_KOREAN, SUBLANG_KOREAN))
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5856 {
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5857 static DWORD dwConversionSaved = 0, dwSentenceSaved = 0;
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5858 static BOOL bSaved = FALSE;
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5859
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5860 if (active)
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5861 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5862 // if we have a saved conversion status, restore it
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5863 if (bSaved)
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5864 pImmSetConversionStatus(hImc, dwConversionSaved,
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5865 dwSentenceSaved);
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5866 bSaved = FALSE;
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5867 }
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5868 else
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5869 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5870 // save conversion status and disable korean
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5871 if (pImmGetConversionStatus(hImc, &dwConversionSaved,
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5872 &dwSentenceSaved))
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5873 {
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5874 bSaved = TRUE;
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5875 pImmSetConversionStatus(hImc,
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5876 dwConversionSaved & ~(IME_CMODE_NATIVE
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5877 | IME_CMODE_FULLSHAPE),
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5878 dwSentenceSaved);
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5879 }
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5880 }
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5881 }
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5882
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5883 pImmSetOpenStatus(hImc, active);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5884 pImmReleaseContext(s_hwnd, hImc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5885 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5886 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5887 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5888
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5889 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5890 * Get IM status. When IM is on, return not 0. Else return 0.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5891 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5892 int
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
5893 im_get_status(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5894 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5895 int status = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5896 HIMC hImc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5897
18742
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18662
diff changeset
5898 # ifdef VIMDLL
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18662
diff changeset
5899 if (!gui.in_use && !gui.starting)
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18662
diff changeset
5900 return mbyte_im_get_status();
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18662
diff changeset
5901 # endif
e9b2ade1adbd patch 8.1.2361: MS-Windows: test failures related to VIMDLL
Bram Moolenaar <Bram@vim.org>
parents: 18662
diff changeset
5902
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5903 if (pImmGetContext && (hImc = pImmGetContext(s_hwnd)) != (HIMC)0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5904 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5905 status = pImmGetOpenStatus(hImc) ? 1 : 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5906 pImmReleaseContext(s_hwnd, hImc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5907 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5908 return status;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5909 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5910
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5911 #endif // FEAT_MBYTE_IME
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5912
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5913
26
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5914 /*
786
8f6a426bc1e0 updated for version 7.0229
vimboss
parents: 782
diff changeset
5915 * Convert latin9 text "text[len]" to ucs-2 in "unicodebuf".
26
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5916 */
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5917 static void
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5918 latin9_to_ucs(char_u *text, int len, WCHAR *unicodebuf)
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5919 {
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5920 int c;
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5921
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
5922 while (--len >= 0)
26
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5923 {
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5924 c = *text++;
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5925 switch (c)
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5926 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5927 case 0xa4: c = 0x20ac; break; // euro
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5928 case 0xa6: c = 0x0160; break; // S hat
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5929 case 0xa8: c = 0x0161; break; // S -hat
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5930 case 0xb4: c = 0x017d; break; // Z hat
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5931 case 0xb8: c = 0x017e; break; // Z -hat
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5932 case 0xbc: c = 0x0152; break; // OE
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5933 case 0xbd: c = 0x0153; break; // oe
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5934 case 0xbe: c = 0x0178; break; // Y
26
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5935 }
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5936 *unicodebuf++ = c;
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5937 }
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
5938 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5939
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5940 #ifdef FEAT_RIGHTLEFT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5941 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5942 * 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
5943 * 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
5944 * reverses the string sent to the TextOut... family. This sucks, because we
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5945 * 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
5946 * way to tell Windblows not to do this!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5947 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5948 * 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
5949 * one of the new, "improved" MS OSes, and only if you are running in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5950 * 'rightleft' mode. It makes display take *slightly* longer, but not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5951 * noticeably so.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5952 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5953 static void
27455
6045bf58926d patch 8.2.4256: MS-Windows: compiler warnings when compiled with /W4
Bram Moolenaar <Bram@vim.org>
parents: 27370
diff changeset
5954 RevOut( HDC hdc,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5955 int col,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5956 int row,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5957 UINT foptions,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5958 CONST RECT *pcliprect,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5959 LPCTSTR text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5960 UINT len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5961 CONST INT *padding)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5962 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5963 int ix;
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5964
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5965 for (ix = 0; ix < (int)len; ++ix)
27455
6045bf58926d patch 8.2.4256: MS-Windows: compiler warnings when compiled with /W4
Bram Moolenaar <Bram@vim.org>
parents: 27370
diff changeset
5966 ExtTextOut(hdc, col + TEXT_X(ix), row, foptions,
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
5967 pcliprect, text + ix, 1, padding);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5968 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5969 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5970
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5971 static void
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5972 draw_line(
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5973 int x1,
15277
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5974 int y1,
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5975 int x2,
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5976 int y2,
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5977 COLORREF color)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5978 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5979 #if defined(FEAT_DIRECTX)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5980 if (IS_ENABLE_DIRECTX())
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5981 DWriteContext_DrawLine(s_dwc, x1, y1, x2, y2, color);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5982 else
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5983 #endif
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5984 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5985 HPEN hpen = CreatePen(PS_SOLID, 1, color);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5986 HPEN old_pen = SelectObject(s_hdc, hpen);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5987 MoveToEx(s_hdc, x1, y1, NULL);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
5988 // Note: LineTo() excludes the last pixel in the line.
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5989 LineTo(s_hdc, x2, y2);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5990 DeleteObject(SelectObject(s_hdc, old_pen));
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5991 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5992 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5993
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5994 static void
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5995 set_pixel(
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5996 int x,
15277
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
5997 int y,
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5998 COLORREF color)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
5999 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6000 #if defined(FEAT_DIRECTX)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6001 if (IS_ENABLE_DIRECTX())
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6002 DWriteContext_SetPixel(s_dwc, x, y, color);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6003 else
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6004 #endif
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6005 SetPixel(s_hdc, x, y, color);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6006 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6007
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6008 static void
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6009 fill_rect(
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6010 const RECT *rcp,
15277
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
6011 HBRUSH hbr,
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6012 COLORREF color)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6013 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6014 #if defined(FEAT_DIRECTX)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6015 if (IS_ENABLE_DIRECTX())
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6016 DWriteContext_FillRect(s_dwc, rcp, color);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6017 else
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6018 #endif
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6019 {
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6020 HBRUSH hbr2;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6021
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6022 if (hbr == NULL)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6023 hbr2 = CreateSolidBrush(color);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6024 else
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6025 hbr2 = hbr;
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6026 FillRect(s_hdc, rcp, hbr2);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6027 if (hbr == NULL)
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6028 DeleteBrush(hbr2);
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6029 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6030 }
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6031
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6032 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6033 gui_mch_draw_string(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6034 int row,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6035 int col,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6036 char_u *text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6037 int len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6038 int flags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6039 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6040 static int *padding = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6041 static int pad_size = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6042 const RECT *pcliprect = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6043 UINT foptions = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6044 static WCHAR *unicodebuf = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6045 static int *unicodepdy = NULL;
236
4707450c2b33 updated for version 7.0066
vimboss
parents: 205
diff changeset
6046 static int unibuflen = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6047 int n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6048 int y;
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 * 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
6052 * (below where the bottom of the character should be). If we draw the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6053 * characters with a solid background, the top row of pixels in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6054 * character below will be overwritten. We can fix this by filling in the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6055 * background ourselves, to the correct character proportions, and then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6056 * writing the character in transparent mode. Still have a problem when
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6057 * the character is "_", which gets written on to the character below.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6058 * New fix: set gui.char_ascent to -1. This shifts all characters up one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6059 * pixel in their slots, which fixes the problem with the bottom row of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6060 * pixels. We still need this code because otherwise the top row of pixels
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6061 * becomes a problem. - webb.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6062 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6063 static HBRUSH hbr_cache[2] = {NULL, NULL};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6064 static guicolor_T brush_color[2] = {INVALCOLOR, INVALCOLOR};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6065 static int brush_lru = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6066 HBRUSH hbr;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6067 RECT rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6068
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6069 if (!(flags & DRAW_TRANSP))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6070 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6071 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6072 * Clear background first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6073 * Note: FillRect() excludes right and bottom of rectangle.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6074 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6075 rc.left = FILL_X(col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6076 rc.top = FILL_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6077 if (has_mbyte)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6078 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6079 // Compute the length in display cells.
2338
da6ec32d8d8f Added strwidth() and strchars() functions.
Bram Moolenaar <bram@vim.org>
parents: 2311
diff changeset
6080 rc.right = FILL_X(col + mb_string2cells(text, len));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6081 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6082 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6083 rc.right = FILL_X(col + len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6084 rc.bottom = FILL_Y(row + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6085
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6086 // Cache the created brush, that saves a lot of time. We need two:
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6087 // one for cursor background and one for the normal background.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6088 if (gui.currBgColor == brush_color[0])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6089 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6090 hbr = hbr_cache[0];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6091 brush_lru = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6092 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6093 else if (gui.currBgColor == brush_color[1])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6094 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6095 hbr = hbr_cache[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6096 brush_lru = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6097 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6098 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6099 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6100 if (hbr_cache[brush_lru] != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6101 DeleteBrush(hbr_cache[brush_lru]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6102 hbr_cache[brush_lru] = CreateSolidBrush(gui.currBgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6103 brush_color[brush_lru] = gui.currBgColor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6104 hbr = hbr_cache[brush_lru];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6105 brush_lru = !brush_lru;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6106 }
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
6107
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6108 fill_rect(&rc, hbr, gui.currBgColor);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6109
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6110 SetBkMode(s_hdc, TRANSPARENT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6112 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6113 * When drawing block cursor, prevent inverted character spilling
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6114 * over character cell (can happen with bold/italic)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6115 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6116 if (flags & DRAW_CURSOR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6117 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6118 pcliprect = &rc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6119 foptions = ETO_CLIPPED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6120 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6121 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6122 SetTextColor(s_hdc, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6123 SelectFont(s_hdc, gui.currFont);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6124
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6125 #ifdef FEAT_DIRECTX
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6126 if (IS_ENABLE_DIRECTX())
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
6127 DWriteContext_SetFont(s_dwc, (HFONT)gui.currFont);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6128 #endif
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6129
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6130 if (pad_size != Columns || padding == NULL || padding[0] != gui.char_width)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6131 {
27455
6045bf58926d patch 8.2.4256: MS-Windows: compiler warnings when compiled with /W4
Bram Moolenaar <Bram@vim.org>
parents: 27370
diff changeset
6132 int i;
6045bf58926d patch 8.2.4256: MS-Windows: compiler warnings when compiled with /W4
Bram Moolenaar <Bram@vim.org>
parents: 27370
diff changeset
6133
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6134 vim_free(padding);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6135 pad_size = Columns;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6136
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6137 // Don't give an out-of-memory message here, it would call us
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6138 // recursively.
16827
ce562b9f702e patch 8.1.1415: build error in MS-Windows GUI
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
6139 padding = LALLOC_MULT(int, pad_size);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6140 if (padding != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6141 for (i = 0; i < pad_size; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6142 padding[i] = gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6143 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6145 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6146 * We have to provide the padding argument because italic and bold versions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6147 * of fixed-width fonts are often one pixel or so wider than their normal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6148 * versions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6149 * No check for DRAW_BOLD, Windows will have done it already.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6150 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6151
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6152 // Check if there are any UTF-8 characters. If not, use normal text
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6153 // output to speed up output.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6154 if (enc_utf8)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6155 for (n = 0; n < len; ++n)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6156 if (text[n] >= 0x80)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6157 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6158
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
6159 #if defined(FEAT_DIRECTX)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6160 // Quick hack to enable DirectWrite. To use DirectWrite (antialias), it is
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6161 // required that unicode drawing routine, currently. So this forces it
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6162 // enabled.
13028
cfce9ac1d1e8 patch 8.0.1390: DirectX scrolling can be slow, vertical positioning is off
Christian Brabandt <cb@256bit.org>
parents: 12994
diff changeset
6163 if (IS_ENABLE_DIRECTX())
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6164 n = 0; // Keep n < len, to enter block for unicode.
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6165 #endif
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6166
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6167 // Check if the Unicode buffer exists and is big enough. Create it
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6168 // with the same length as the multi-byte string, the number of wide
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6169 // characters is always equal or smaller.
26
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6170 if ((enc_utf8
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6171 || (enc_codepage > 0 && (int)GetACP() != enc_codepage)
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6172 || enc_latin9)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6173 && (unicodebuf == NULL || len > unibuflen))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6174 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6175 vim_free(unicodebuf);
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
6176 unicodebuf = LALLOC_MULT(WCHAR, len);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6177
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6178 vim_free(unicodepdy);
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
6179 unicodepdy = LALLOC_MULT(int, len);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6181 unibuflen = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6182 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6184 if (enc_utf8 && n < len && unicodebuf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6185 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6186 // Output UTF-8 characters. Composing characters should be
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6187 // handled here.
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6188 int i;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6189 int wlen; // string length in words
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6190 int clen; // string length in characters
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6191 int cells; // cell width of string up to composing char
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6192 int cw; // width of current cell
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6193 int c;
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6194
782
d20041a02ee5 updated for version 7.0228
vimboss
parents: 777
diff changeset
6195 wlen = 0;
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6196 clen = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6197 cells = 0;
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6198 for (i = 0; i < len; )
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6199 {
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6200 c = utf_ptr2char(text + i);
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6201 if (c >= 0x10000)
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6202 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6203 // Turn into UTF-16 encoding.
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6204 unicodebuf[wlen++] = ((c - 0x10000) >> 10) + 0xD800;
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6205 unicodebuf[wlen++] = ((c - 0x10000) & 0x3ff) + 0xDC00;
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6206 }
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6207 else
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6208 {
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6209 unicodebuf[wlen++] = c;
714
0f9f4761ad9c updated for version 7.0216
vimboss
parents: 636
diff changeset
6210 }
12712
25f7d8ee04c7 patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents: 12668
diff changeset
6211
25f7d8ee04c7 patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents: 12668
diff changeset
6212 if (utf_iscomposing(c))
25f7d8ee04c7 patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents: 12668
diff changeset
6213 cw = 0;
25f7d8ee04c7 patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents: 12668
diff changeset
6214 else
25f7d8ee04c7 patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents: 12668
diff changeset
6215 {
25f7d8ee04c7 patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents: 12668
diff changeset
6216 cw = utf_char2cells(c);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6217 if (cw > 2) // don't use 4 for unprintable char
12712
25f7d8ee04c7 patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents: 12668
diff changeset
6218 cw = 1;
25f7d8ee04c7 patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents: 12668
diff changeset
6219 }
25f7d8ee04c7 patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents: 12668
diff changeset
6220
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6221 if (unicodepdy != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6222 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6223 // Use unicodepdy to make characters fit as we expect, even
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6224 // when the font uses different widths (e.g., bold character
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6225 // is wider).
8273
0c3210caefa6 commit https://github.com/vim/vim/commit/d804fdf4c25435284333258856bc265f1ff10b09
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
6226 if (c >= 0x10000)
0c3210caefa6 commit https://github.com/vim/vim/commit/d804fdf4c25435284333258856bc265f1ff10b09
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
6227 {
0c3210caefa6 commit https://github.com/vim/vim/commit/d804fdf4c25435284333258856bc265f1ff10b09
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
6228 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
6229 unicodepdy[wlen - 1] = 0;
0c3210caefa6 commit https://github.com/vim/vim/commit/d804fdf4c25435284333258856bc265f1ff10b09
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
6230 }
0c3210caefa6 commit https://github.com/vim/vim/commit/d804fdf4c25435284333258856bc265f1ff10b09
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
6231 else
0c3210caefa6 commit https://github.com/vim/vim/commit/d804fdf4c25435284333258856bc265f1ff10b09
Christian Brabandt <cb@256bit.org>
parents: 8222
diff changeset
6232 unicodepdy[wlen - 1] = cw * gui.char_width;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6233 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6234 cells += cw;
12712
25f7d8ee04c7 patch 8.0.1234: MS-Windows: composing chars are not shown properly
Christian Brabandt <cb@256bit.org>
parents: 12668
diff changeset
6235 i += utf_ptr2len_len(text + i, len - i);
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
6236 ++clen;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6237 }
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
6238 #if defined(FEAT_DIRECTX)
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
6239 if (IS_ENABLE_DIRECTX())
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6240 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6241 // Add one to "cells" for italics.
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
6242 DWriteContext_DrawText(s_dwc, unicodebuf, wlen,
16048
728bef04b0d4 patch 8.1.1029: DirectWrite doesn't take 'linespace' into account
Bram Moolenaar <Bram@vim.org>
parents: 15665
diff changeset
6243 TEXT_X(col), TEXT_Y(row),
728bef04b0d4 patch 8.1.1029: DirectWrite doesn't take 'linespace' into account
Bram Moolenaar <Bram@vim.org>
parents: 15665
diff changeset
6244 FILL_X(cells + 1), FILL_Y(1) - p_linespace,
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
6245 gui.char_width, gui.currFgColor,
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
6246 foptions, pcliprect, unicodepdy);
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6247 }
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6248 else
15597
536dd2bc5ac9 patch 8.1.0806: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15549
diff changeset
6249 #endif
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
6250 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
6251 foptions, pcliprect, unicodebuf, wlen, unicodepdy);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6252 len = cells; // used for underlining
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6253 }
26
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6254 else if ((enc_codepage > 0 && (int)GetACP() != enc_codepage) || enc_latin9)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6255 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6256 // If we want to display codepage data, and the current CP is not the
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6257 // ANSI one, we need to go via Unicode.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6258 if (unicodebuf != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6259 {
26
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6260 if (enc_latin9)
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6261 latin9_to_ucs(text, len, unicodebuf);
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6262 else
404aac550f35 updated for version 7.0017
vimboss
parents: 9
diff changeset
6263 len = MultiByteToWideChar(enc_codepage,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6264 MB_PRECOMPOSED,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6265 (char *)text, len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6266 (LPWSTR)unicodebuf, unibuflen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6267 if (len != 0)
179
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6268 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6269 // Use unicodepdy to make characters fit as we expect, even
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6270 // when the font uses different widths (e.g., bold character
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6271 // is wider).
179
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6272 if (unicodepdy != NULL)
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6273 {
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6274 int i;
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6275 int cw;
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6276
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6277 for (i = 0; i < len; ++i)
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6278 {
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6279 cw = utf_char2cells(unicodebuf[i]);
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6280 if (cw > 2)
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6281 cw = 1;
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6282 unicodepdy[i] = cw * gui.char_width;
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6283 }
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6284 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6285 ExtTextOutW(s_hdc, TEXT_X(col), TEXT_Y(row),
179
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6286 foptions, pcliprect, unicodebuf, len, unicodepdy);
7fd70926e2e1 updated for version 7.0055
vimboss
parents: 170
diff changeset
6287 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6288 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6289 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6290 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6291 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6292 #ifdef FEAT_RIGHTLEFT
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6293 // Windows will mess up RL text, so we have to draw it character by
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6294 // character. Only do this if RL is on, since it's slow.
6226
2fd96725b063 updated for version 7.4.448
Bram Moolenaar <bram@vim.org>
parents: 6112
diff changeset
6295 if (curwin->w_p_rl)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6296 RevOut(s_hdc, TEXT_X(col), TEXT_Y(row),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6297 foptions, pcliprect, (char *)text, len, padding);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6298 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6299 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6300 ExtTextOut(s_hdc, TEXT_X(col), TEXT_Y(row),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6301 foptions, pcliprect, (char *)text, len, padding);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6302 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6303
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6304 // Underline
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6305 if (flags & DRAW_UNDERL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6306 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6307 // When p_linespace is 0, overwrite the bottom row of pixels.
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6308 // Otherwise put the line just below the character.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6309 y = FILL_Y(row + 1) - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6310 if (p_linespace > 1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6311 y -= p_linespace - 1;
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6312 draw_line(FILL_X(col), y, FILL_X(col + len), y, gui.currFgColor);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6313 }
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6314
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6315 // Strikethrough
12317
2a8890b80923 patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents: 12090
diff changeset
6316 if (flags & DRAW_STRIKE)
2a8890b80923 patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents: 12090
diff changeset
6317 {
2a8890b80923 patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents: 12090
diff changeset
6318 y = FILL_Y(row + 1) - gui.char_height/2;
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6319 draw_line(FILL_X(col), y, FILL_X(col + len), y, gui.currSpColor);
12317
2a8890b80923 patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents: 12090
diff changeset
6320 }
2a8890b80923 patch 8.0.1038: strike-through text not supported
Christian Brabandt <cb@256bit.org>
parents: 12090
diff changeset
6321
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6322 // Undercurl
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6323 if (flags & DRAW_UNDERC)
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6324 {
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6325 int x;
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6326 int offset;
323
03b3684919e3 updated for version 7.0084
vimboss
parents: 293
diff changeset
6327 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
6328
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6329 y = FILL_Y(row + 1) - 1;
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6330 for (x = FILL_X(col); x < FILL_X(col + len); ++x)
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6331 {
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6332 offset = val[x % 8];
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6333 set_pixel(x, y - offset, gui.currSpColor);
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6334 }
d292c40ca788 updated for version 7.0060
vimboss
parents: 189
diff changeset
6335 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6336 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6337
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6338
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6339 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6340 * Output routines.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6341 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6342
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6343 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6344 * Flush any output to the screen
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6345 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6346 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6347 gui_mch_flush(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6348 {
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
6349 #if defined(FEAT_DIRECTX)
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
6350 if (IS_ENABLE_DIRECTX())
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
6351 DWriteContext_Flush(s_dwc);
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
6352 #endif
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
6353
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6354 GdiFlush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6355 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6356
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6357 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6358 clear_rect(RECT *rcp)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6359 {
12986
18e6f4addce9 patch 8.0.1369: MS-Windows: drawing underline slow, mFallbackDC not updated
Christian Brabandt <cb@256bit.org>
parents: 12950
diff changeset
6360 fill_rect(rcp, NULL, gui.back_pixel);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6361 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6362
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6363
636
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6364 void
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6365 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6366 {
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6367 RECT workarea_rect;
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6368
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6369 get_work_area(&workarea_rect);
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6370
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
6371 *screen_w = workarea_rect.right - workarea_rect.left
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6372 - (pGetSystemMetricsForDpi(SM_CXFRAME, s_dpi) +
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6373 pGetSystemMetricsForDpi(SM_CXPADDEDBORDER, s_dpi)) * 2;
636
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6374
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6375 // FIXME: dirty trick: Because the gui_get_base_height() doesn't include
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6376 // the menubar for MSwin, we subtract it from the screen height, so that
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6377 // the window size can be made to fit on the screen.
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
6378 *screen_h = workarea_rect.bottom - workarea_rect.top
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6379 - (pGetSystemMetricsForDpi(SM_CYFRAME, s_dpi) +
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6380 pGetSystemMetricsForDpi(SM_CXPADDEDBORDER, s_dpi)) * 2
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6381 - pGetSystemMetricsForDpi(SM_CYCAPTION, s_dpi)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6382 - gui_mswin_get_menu_height(FALSE);
636
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6383 }
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6384
5ad3b5d4ecc0 updated for version 7.0184
vimboss
parents: 615
diff changeset
6385
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6386 #if defined(FEAT_MENU) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6387 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6388 * Add a sub menu to the menu bar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6389 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6390 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6391 gui_mch_add_menu(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6392 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6393 int pos)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6394 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6395 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6396
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6397 menu->submenu_id = CreatePopupMenu();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6398 menu->id = s_menu_id++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6400 if (menu_is_menubar(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6401 {
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6402 WCHAR *wn;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6403 MENUITEMINFOW infow;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6404
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6405 wn = enc_to_utf16(menu->name, NULL);
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
6406 if (wn == NULL)
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6407 return;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6408
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6409 infow.cbSize = sizeof(infow);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6410 infow.fMask = MIIM_DATA | MIIM_TYPE | MIIM_ID
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6411 | MIIM_SUBMENU;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6412 infow.dwItemData = (long_u)menu;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6413 infow.wID = menu->id;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6414 infow.fType = MFT_STRING;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6415 infow.dwTypeData = wn;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6416 infow.cch = (UINT)wcslen(wn);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6417 infow.hSubMenu = menu->submenu_id;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6418 InsertMenuItemW((parent == NULL)
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6419 ? s_menuBar : parent->submenu_id,
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6420 (UINT)pos, TRUE, &infow);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6421 vim_free(wn);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6422 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6423
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6424 // Fix window size if menu may have wrapped
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6425 if (parent == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6426 gui_mswin_get_menu_height(!gui.starting);
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6427 # ifdef FEAT_TEAROFF
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6428 else if (IsWindow(parent->tearoff_handle))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6429 rebuild_tearoff(parent);
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6430 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6431 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6432
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6433 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6434 gui_mch_show_popupmenu(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6435 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6436 POINT mp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6437
27281
f7d73708b391 patch 8.2.4169: MS-Windows: unnessary casts and other minor things
Bram Moolenaar <Bram@vim.org>
parents: 27261
diff changeset
6438 (void)GetCursorPos(&mp);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6439 gui_mch_show_popupmenu_at(menu, (int)mp.x, (int)mp.y);
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 void
401
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6443 gui_make_popup(char_u *path_name, int mouse_pos)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6444 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6445 vimmenu_T *menu = gui_find_menu(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6446
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6447 if (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6448 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6449 POINT p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6450
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6451 // Find the position of the current cursor
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6452 GetDCOrgEx(s_hdc, &p);
401
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6453 if (mouse_pos)
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6454 {
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6455 int mx, my;
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6456
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6457 gui_mch_getmouse(&mx, &my);
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6458 p.x += mx;
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6459 p.y += my;
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6460 }
4a1ead01d30b updated for version 7.0105
vimboss
parents: 344
diff changeset
6461 else if (curwin != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6462 {
12513
3ca08bf99396 patch 8.0.1135: W_WINCOL() is always the same
Christian Brabandt <cb@256bit.org>
parents: 12477
diff changeset
6463 p.x += TEXT_X(curwin->w_wincol + curwin->w_wcol + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6464 p.y += TEXT_Y(W_WINROW(curwin) + curwin->w_wrow + 1);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6465 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6466 msg_scroll = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6467 gui_mch_show_popupmenu_at(menu, (int)p.x, (int)p.y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6468 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6469 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6470
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6471 # if defined(FEAT_TEAROFF) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6472 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6473 * 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
6474 * create it as a pseudo-"tearoff menu".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6475 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6476 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6477 gui_make_tearoff(char_u *path_name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6478 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6479 vimmenu_T *menu = gui_find_menu(path_name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6480
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6481 // Found the menu, so tear it off.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6482 if (menu != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6483 gui_mch_tearoff(menu->dname, menu, 0xffffL, 0xffffL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6484 }
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6485 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6486
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6487 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6488 * Add a menu item to a menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6489 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6490 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6491 gui_mch_add_menu_item(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6492 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6493 int idx)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6494 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6495 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6496
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6497 menu->id = s_menu_id++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6498 menu->submenu_id = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6499
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6500 # ifdef FEAT_TEAROFF
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6501 if (STRNCMP(menu->name, TEAR_STRING, TEAR_LEN) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6502 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6503 InsertMenu(parent->submenu_id, (UINT)idx, MF_BITMAP|MF_BYPOSITION,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6504 (UINT)menu->id, (LPCTSTR) s_htearbitmap);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6505 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6506 else
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6507 # endif
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6508 # ifdef FEAT_TOOLBAR
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6509 if (menu_is_toolbar(parent->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6510 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6511 TBBUTTON newtb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6512
20007
aadd1cae2ff5 patch 8.2.0559: clearing a struct is verbose
Bram Moolenaar <Bram@vim.org>
parents: 19934
diff changeset
6513 CLEAR_FIELD(newtb);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6514 if (menu_is_separator(menu->name))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6515 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6516 newtb.iBitmap = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6517 newtb.fsStyle = TBSTYLE_SEP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6518 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6519 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6520 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6521 newtb.iBitmap = get_toolbar_bitmap(menu);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6522 newtb.fsStyle = TBSTYLE_BUTTON;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6523 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6524 newtb.idCommand = menu->id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6525 newtb.fsState = TBSTATE_ENABLED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6526 newtb.iString = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6527 SendMessage(s_toolbarhwnd, TB_INSERTBUTTON, (WPARAM)idx,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6528 (LPARAM)&newtb);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6529 menu->submenu_id = (HMENU)-1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6530 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6531 else
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6532 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6533 {
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6534 WCHAR *wn;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6535
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6536 wn = enc_to_utf16(menu->name, NULL);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6537 if (wn != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6538 {
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6539 InsertMenuW(parent->submenu_id, (UINT)idx,
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6540 (menu_is_separator(menu->name)
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6541 ? MF_SEPARATOR : MF_STRING) | MF_BYPOSITION,
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6542 (UINT)menu->id, wn);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6543 vim_free(wn);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6544 }
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6545 # ifdef FEAT_TEAROFF
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6546 if (IsWindow(parent->tearoff_handle))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6547 rebuild_tearoff(parent);
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6548 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6549 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6550 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6551
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6552 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6553 * Destroy the machine specific menu widget.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6554 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6555 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6556 gui_mch_destroy_menu(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6557 {
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6558 # ifdef FEAT_TOOLBAR
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6559 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6560 * is this a toolbar button?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6561 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6562 if (menu->submenu_id == (HMENU)-1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6563 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6564 int iButton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6565
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6566 iButton = (int)SendMessage(s_toolbarhwnd, TB_COMMANDTOINDEX,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6567 (WPARAM)menu->id, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6568 SendMessage(s_toolbarhwnd, TB_DELETEBUTTON, (WPARAM)iButton, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6569 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6570 else
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6571 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6572 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6573 if (menu->parent != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6574 && menu_is_popup(menu->parent->dname)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6575 && menu->parent->submenu_id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6576 RemoveMenu(menu->parent->submenu_id, menu->id, MF_BYCOMMAND);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6577 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6578 RemoveMenu(s_menuBar, menu->id, MF_BYCOMMAND);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6579 if (menu->submenu_id != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6580 DestroyMenu(menu->submenu_id);
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6581 # ifdef FEAT_TEAROFF
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6582 if (IsWindow(menu->tearoff_handle))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6583 DestroyWindow(menu->tearoff_handle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6584 if (menu->parent != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6585 && menu->parent->children != NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6586 && IsWindow(menu->parent->tearoff_handle))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6587 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6588 // This menu must not show up when rebuilding the tearoff window.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6589 menu->modes = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6590 rebuild_tearoff(menu->parent);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6591 }
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6592 # endif
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6593 }
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6594 }
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6595
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6596 # ifdef FEAT_TEAROFF
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6597 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6598 rebuild_tearoff(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6599 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6600 //hackish
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6601 char_u tbuf[128];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6602 RECT trect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6603 RECT rct;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6604 RECT roct;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6605 int x, y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6606
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6607 HWND thwnd = menu->tearoff_handle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6608
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
6609 GetWindowText(thwnd, (LPSTR)tbuf, 127);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6610 if (GetWindowRect(thwnd, &trect)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6611 && GetWindowRect(s_hwnd, &rct)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6612 && GetClientRect(s_hwnd, &roct))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6613 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6614 x = trect.left - rct.left;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6615 y = (trect.top - rct.bottom + roct.bottom);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6616 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6617 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6618 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6619 x = y = 0xffffL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6620 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6621 DestroyWindow(thwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6622 if (menu->children != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6623 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6624 gui_mch_tearoff(tbuf, menu, x, y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6625 if (IsWindow(menu->tearoff_handle))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6626 (void) SetWindowPos(menu->tearoff_handle,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6627 NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6628 (int)trect.left,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6629 (int)trect.top,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6630 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6631 SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6632 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6633 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6634 # endif // FEAT_TEAROFF
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6635
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6636 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6637 * Make a menu either grey or not grey.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6638 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6639 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6640 gui_mch_menu_grey(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6641 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6642 int grey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6643 {
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6644 # ifdef FEAT_TOOLBAR
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6645 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6646 * is this a toolbar button?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6647 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6648 if (menu->submenu_id == (HMENU)-1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6649 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6650 SendMessage(s_toolbarhwnd, TB_ENABLEBUTTON,
27281
f7d73708b391 patch 8.2.4169: MS-Windows: unnessary casts and other minor things
Bram Moolenaar <Bram@vim.org>
parents: 27261
diff changeset
6651 (WPARAM)menu->id, (LPARAM) MAKELONG((grey ? FALSE : TRUE), 0));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6652 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6653 else
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6654 # endif
9236
9940e9b2a725 commit https://github.com/vim/vim/commit/762f1754370a1278167c8cba6c047ef319fc099c
Christian Brabandt <cb@256bit.org>
parents: 9213
diff changeset
6655 (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
6656 menu->id, MF_BYCOMMAND | (grey ? MF_GRAYED : MF_ENABLED));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6657
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6658 # ifdef FEAT_TEAROFF
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6659 if ((menu->parent != NULL) && (IsWindow(menu->parent->tearoff_handle)))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6660 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6661 WORD menuID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6662 HWND menuHandle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6663
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6664 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6665 * A tearoff button has changed state.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6666 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6667 if (menu->children == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6668 menuID = (WORD)(menu->id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6669 else
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
6670 menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6671 menuHandle = GetDlgItem(menu->parent->tearoff_handle, menuID);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6672 if (menuHandle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6673 EnableWindow(menuHandle, !grey);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6674
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6675 }
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6676 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6677 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6678
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6679 #endif // FEAT_MENU
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6680
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6681
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6682 // define some macros used to make the dialogue creation more readable
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6683
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6684 #define add_word(x) *p++ = (x)
615
7fe13e0f5dce updated for version 7.0175
vimboss
parents: 537
diff changeset
6685 #define add_long(x) dwp = (DWORD *)p; *dwp++ = (x); p = (WORD *)dwp
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6686
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6687 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6688 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6689 * stuff for dialogs
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6690 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6691
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6692 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6693 * The callback routine used by all the dialogs. Very simple. First,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6694 * acknowledges the INITDIALOG message so that Windows knows to do standard
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6695 * dialog stuff (Return = default, Esc = cancel....) Second, if a button is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6696 * pressed, return that button's ID - IDCANCEL (2), which is the button's
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6697 * number.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6698 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6699 static LRESULT CALLBACK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6700 dialog_callback(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6701 HWND hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6702 UINT message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6703 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
6704 LPARAM lParam UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6705 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6706 if (message == WM_INITDIALOG)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6707 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6708 CenterWindow(hwnd, GetWindow(hwnd, GW_OWNER));
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6709 // Set focus to the dialog. Set the default button, if specified.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6710 (void)SetFocus(hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6711 if (dialog_default_button > IDCANCEL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6712 (void)SetFocus(GetDlgItem(hwnd, dialog_default_button));
1356
c87f38b71d27 updated for version 7.1-070
vimboss
parents: 1288
diff changeset
6713 else
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6714 // We don't have a default, set focus on another element of the
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6715 // dialog window, probably the icon
1356
c87f38b71d27 updated for version 7.1-070
vimboss
parents: 1288
diff changeset
6716 (void)SetFocus(GetDlgItem(hwnd, DLG_NONBUTTON_CONTROL));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6717 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6718 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6719
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6720 if (message == WM_COMMAND)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6721 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6722 int button = LOWORD(wParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6723
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6724 // Don't end the dialog if something was selected that was
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6725 // not a button.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6726 if (button >= DLG_NONBUTTON_CONTROL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6727 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6728
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6729 // If the edit box exists, copy the string.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6730 if (s_textfield != NULL)
1795
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6731 {
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
6732 WCHAR *wp = ALLOC_MULT(WCHAR, IOSIZE);
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6733 char_u *p;
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6734
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6735 GetDlgItemTextW(hwnd, DLG_NONBUTTON_CONTROL + 2, wp, IOSIZE);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6736 p = utf16_to_enc(wp, NULL);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6737 vim_strncpy(s_textfield, p, IOSIZE);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6738 vim_free(p);
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
6739 vim_free(wp);
1795
1fc8d918d9fc updated for version 7.2-093
vimboss
parents: 1752
diff changeset
6740 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6741
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6742 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6743 * Need to check for IDOK because if the user just hits Return to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6744 * accept the default value, some reason this is what we get.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6745 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6746 if (button == IDOK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6747 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6748 if (dialog_default_button > IDCANCEL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6749 EndDialog(hwnd, dialog_default_button);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6750 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6751 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6752 EndDialog(hwnd, button - IDCANCEL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6753 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6754 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6755
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6756 if ((message == WM_SYSCOMMAND) && (wParam == SC_CLOSE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6757 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6758 EndDialog(hwnd, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6759 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6760 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6761 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6762 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6763
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6764 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6765 * Create a dialog dynamically from the parameter strings.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6766 * type = type of dialog (question, alert, etc.)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6767 * title = dialog title. may be NULL for default title.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6768 * message = text to display. Dialog sizes to accommodate it.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6769 * buttons = '\n' separated list of button captions, default first.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6770 * dfltbutton = number of default button.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6771 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6772 * This routine returns 1 if the first button is pressed,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6773 * 2 for the second, etc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6774 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6775 * 0 indicates Esc was pressed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6776 * -1 for unexpected error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6777 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6778 * If stubbing out this fn, return 1.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6779 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6780
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6781 static const char *dlg_icons[] = // must match names in resource file
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6782 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6783 "IDR_VIM",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6784 "IDR_VIM_ERROR",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6785 "IDR_VIM_ALERT",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6786 "IDR_VIM_INFO",
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6787 "IDR_VIM_QUESTION"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6788 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6789
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6790 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6791 gui_mch_dialog(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6792 int type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6793 char_u *title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6794 char_u *message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6795 char_u *buttons,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6796 int dfltbutton,
2684
951641b8784d updated for version 7.3.102
Bram Moolenaar <bram@vim.org>
parents: 2616
diff changeset
6797 char_u *textfield,
18139
59bc3cd42cf5 patch 8.1.2064: MS-Windows: compiler warnings for unused arguments
Bram Moolenaar <Bram@vim.org>
parents: 17958
diff changeset
6798 int ex_cmd UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6799 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6800 WORD *p, *pdlgtemplate, *pnumitems;
615
7fe13e0f5dce updated for version 7.0175
vimboss
parents: 537
diff changeset
6801 DWORD *dwp;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6802 int numButtons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6803 int *buttonWidths, *buttonPositions;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6804 int buttonYpos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6805 int nchar, i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6806 DWORD lStyle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6807 int dlgwidth = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6808 int dlgheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6809 int editboxheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6810 int horizWidth = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6811 int msgheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6812 char_u *pstart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6813 char_u *pend;
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6814 char_u *last_white;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6815 char_u *tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6816 RECT rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6817 HWND hwnd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6818 HDC hdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6819 HFONT font, oldFont;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6820 TEXTMETRIC fontInfo;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6821 int fontHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6822 int textWidth, minButtonWidth, messageWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6823 int maxDialogWidth;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
6824 int maxDialogHeight;
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
6825 int scroll_flag = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6826 int vertical;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6827 int dlgPaddingX;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6828 int dlgPaddingY;
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6829 # ifdef USE_SYSMENU_FONT
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
6830 LOGFONTW lfSysmenu;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6831 int use_lfSysmenu = FALSE;
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6832 # endif
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6833 garray_T ga;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6834 int l;
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6835 int dlg_icon_width;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6836 int dlg_icon_height;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6837 int dpi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6838
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6839 # ifndef NO_CONSOLE
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6840 // Don't output anything in silent mode ("ex -s")
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6841 # ifdef VIMDLL
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
6842 if (!(gui.in_use || gui.starting))
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6843 # endif
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
6844 if (silent_mode)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6845 return dfltbutton; // return default option
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6846 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6847
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
6848 if (s_hwnd == NULL)
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6849 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6850 load_dpi_func();
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6851 s_dpi = dpi = pGetDpiForSystem();
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
6852 get_dialog_font_metrics();
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6853 }
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6854 else
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6855 dpi = pGetDpiForSystem();
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6856
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6857 if ((type < 0) || (type > VIM_LAST_TYPE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6858 type = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6859
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6860 // allocate some memory for dialog template
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6861 // TODO should compute this really
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6862 pdlgtemplate = p = (PWORD)LocalAlloc(LPTR,
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
6863 DLG_ALLOC_SIZE + STRLEN(message) * 2);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6864
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6865 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6866 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6867
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6868 /*
4352
04736b4030ec updated for version 7.3.925
Bram Moolenaar <bram@vim.org>
parents: 4238
diff changeset
6869 * make a copy of 'buttons' to fiddle with it. compiler grizzles because
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6870 * vim_strsave() doesn't take a const arg (why not?), so cast away the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6871 * const.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6872 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6873 tbuffer = vim_strsave(buttons);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6874 if (tbuffer == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6875 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6876
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6877 --dfltbutton; // Change from one-based to zero-based
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6878
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6879 // Count buttons
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6880 numButtons = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6881 for (i = 0; tbuffer[i] != '\0'; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6882 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6883 if (tbuffer[i] == DLG_BUTTON_SEP)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6884 numButtons++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6885 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6886 if (dfltbutton >= numButtons)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6887 dfltbutton = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6888
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6889 // Allocate array to hold the width of each button
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
6890 buttonWidths = ALLOC_MULT(int, numButtons);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6891 if (buttonWidths == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6892 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6893
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6894 // Allocate array to hold the X position of each button
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
6895 buttonPositions = ALLOC_MULT(int, numButtons);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6896 if (buttonPositions == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6897 return -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6898
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6899 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6900 * Calculate how big the dialog must be.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6901 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6902 hwnd = GetDesktopWindow();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6903 hdc = GetWindowDC(hwnd);
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6904 # ifdef USE_SYSMENU_FONT
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6905 if (gui_w32_get_menu_font(&lfSysmenu) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6906 {
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
6907 font = CreateFontIndirectW(&lfSysmenu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6908 use_lfSysmenu = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6909 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6910 else
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
6911 # endif
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
6912 font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0,
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
6913 0, 0, 0, 0, VARIABLE_PITCH, DLG_FONT_NAME);
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
6914
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
6915 oldFont = SelectFont(hdc, font);
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
6916 dlgPaddingX = DLG_PADDING_X;
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
6917 dlgPaddingY = DLG_PADDING_Y;
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
6918
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6919 GetTextMetrics(hdc, &fontInfo);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6920 fontHeight = fontInfo.tmHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6921
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6922 // Minimum width for horizontal button
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
6923 minButtonWidth = GetTextWidth(hdc, (char_u *)"Cancel", 6);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6924
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6925 // Maximum width of a dialog, if possible
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6926 if (s_hwnd == NULL)
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6927 {
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6928 RECT workarea_rect;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6929
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6930 // We don't have a window, use the desktop area.
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6931 get_work_area(&workarea_rect);
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6932 maxDialogWidth = workarea_rect.right - workarea_rect.left - 100;
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6933 if (maxDialogWidth > adjust_by_system_dpi(600))
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6934 maxDialogWidth = adjust_by_system_dpi(600);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6935 // Leave some room for the taskbar.
5249
47a09a572ea6 updated for version 7.4b.001
Bram Moolenaar <bram@vim.org>
parents: 5225
diff changeset
6936 maxDialogHeight = workarea_rect.bottom - workarea_rect.top - 150;
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6937 }
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6938 else
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6939 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6940 // Use our own window for the size, unless it's very small.
5284
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
6941 GetWindowRect(s_hwnd, &rect);
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6942 maxDialogWidth = rect.right - rect.left
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6943 - (pGetSystemMetricsForDpi(SM_CXFRAME, dpi) +
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6944 pGetSystemMetricsForDpi(SM_CXPADDEDBORDER, dpi)) * 2;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6945 if (maxDialogWidth < adjust_by_system_dpi(DLG_MIN_MAX_WIDTH))
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6946 maxDialogWidth = adjust_by_system_dpi(DLG_MIN_MAX_WIDTH);
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6947
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6948 maxDialogHeight = rect.bottom - rect.top
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6949 - (pGetSystemMetricsForDpi(SM_CYFRAME, dpi) +
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6950 pGetSystemMetricsForDpi(SM_CXPADDEDBORDER, dpi)) * 4
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6951 - pGetSystemMetricsForDpi(SM_CYCAPTION, dpi);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6952 if (maxDialogHeight < adjust_by_system_dpi(DLG_MIN_MAX_HEIGHT))
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6953 maxDialogHeight = adjust_by_system_dpi(DLG_MIN_MAX_HEIGHT);
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6954 }
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6955
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6956 // Set dlgwidth to width of message.
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6957 // Copy the message into "ga", changing NL to CR-NL and inserting line
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6958 // breaks where needed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6959 pstart = message;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6960 messageWidth = 0;
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6961 msgheight = 0;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6962 ga_init2(&ga, sizeof(char), 500);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6963 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6964 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6965 msgheight += fontHeight; // at least one line
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6966
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6967 // Need to figure out where to break the string. The system does it
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6968 // at a word boundary, which would mean we can't compute the number of
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6969 // wrapped lines.
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6970 textWidth = 0;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6971 last_white = NULL;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6972 for (pend = pstart; *pend != NUL && *pend != '\n'; )
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
6973 {
474
a5fcf36ef512 updated for version 7.0127
vimboss
parents: 435
diff changeset
6974 l = (*mb_ptr2len)(pend);
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10783
diff changeset
6975 if (l == 1 && VIM_ISWHITE(*pend)
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6976 && textWidth > maxDialogWidth * 3 / 4)
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6977 last_white = pend;
4999
b4a71dbdb787 updated for version 7.3.1244
Bram Moolenaar <bram@vim.org>
parents: 4352
diff changeset
6978 textWidth += GetTextWidthEnc(hdc, pend, l);
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6979 if (textWidth >= maxDialogWidth)
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
6980 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6981 // Line will wrap.
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6982 messageWidth = maxDialogWidth;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
6983 msgheight += fontHeight;
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6984 textWidth = 0;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6985
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6986 if (last_white != NULL)
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6987 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
6988 // break the line just after a space
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6989 if (pend > last_white)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
6990 ga.ga_len -= (int)(pend - (last_white + 1));
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6991 pend = last_white + 1;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6992 last_white = NULL;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6993 }
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6994 ga_append(&ga, '\r');
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6995 ga_append(&ga, '\n');
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6996 continue;
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
6997 }
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6998
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
6999 while (--l >= 0)
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7000 ga_append(&ga, *pend++);
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7001 }
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7002 if (textWidth > messageWidth)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7003 messageWidth = textWidth;
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7004
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7005 ga_append(&ga, '\r');
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7006 ga_append(&ga, '\n');
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7007 pstart = pend + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7008 } while (*pend != NUL);
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7009
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7010 if (ga.ga_data != NULL)
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7011 message = ga.ga_data;
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7012
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7013 messageWidth += 10; // roundoff space
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7014
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7015 dlg_icon_width = adjust_by_system_dpi(DLG_ICON_WIDTH);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7016 dlg_icon_height = adjust_by_system_dpi(DLG_ICON_HEIGHT);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7017
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7018 // Add width of icon to dlgwidth, and some space
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7019 dlgwidth = messageWidth + dlg_icon_width + 3 * dlgPaddingX
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7020 + pGetSystemMetricsForDpi(SM_CXVSCROLL, dpi);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7021
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7022 if (msgheight < dlg_icon_height)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7023 msgheight = dlg_icon_height;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7024
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7025 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7026 * Check button names. A long one will make the dialog wider.
1116
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
7027 * When called early (-register error message) p_go isn't initialized.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7028 */
1116
e76a088056dd updated for version 7.0-242
vimboss
parents: 948
diff changeset
7029 vertical = (p_go != NULL && vim_strchr(p_go, GO_VERTICAL) != NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7030 if (!vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7031 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7032 // Place buttons horizontally if they fit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7033 horizWidth = dlgPaddingX;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7034 pstart = tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7035 i = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7036 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7037 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7038 pend = vim_strchr(pstart, DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7039 if (pend == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7040 pend = pstart + STRLEN(pstart); // Last button name.
5001
43329b2b5b79 updated for version 7.3.1245
Bram Moolenaar <bram@vim.org>
parents: 4999
diff changeset
7041 textWidth = GetTextWidthEnc(hdc, pstart, (int)(pend - pstart));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7042 if (textWidth < minButtonWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7043 textWidth = minButtonWidth;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7044 textWidth += dlgPaddingX; // Padding within button
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7045 buttonWidths[i] = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7046 buttonPositions[i++] = horizWidth;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7047 horizWidth += textWidth + dlgPaddingX; // Pad between buttons
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7048 pstart = pend + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7049 } while (*pend != NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7050
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7051 if (horizWidth > maxDialogWidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7052 vertical = TRUE; // Too wide to fit on the screen.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7053 else if (horizWidth > dlgwidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7054 dlgwidth = horizWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7055 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7056
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7057 if (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7058 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7059 // Stack buttons vertically.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7060 pstart = tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7061 do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7062 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7063 pend = vim_strchr(pstart, DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7064 if (pend == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7065 pend = pstart + STRLEN(pstart); // Last button name.
5001
43329b2b5b79 updated for version 7.3.1245
Bram Moolenaar <bram@vim.org>
parents: 4999
diff changeset
7066 textWidth = GetTextWidthEnc(hdc, pstart, (int)(pend - pstart));
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7067 textWidth += dlgPaddingX; // Padding within button
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7068 textWidth += DLG_VERT_PADDING_X * 2; // Padding around button
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7069 if (textWidth > dlgwidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7070 dlgwidth = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7071 pstart = pend + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7072 } while (*pend != NUL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7073 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7074
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7075 if (dlgwidth < DLG_MIN_WIDTH)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7076 dlgwidth = DLG_MIN_WIDTH; // Don't allow a really thin dialog!
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7077
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7078 // start to fill in the dlgtemplate information. addressing by WORDs
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7079 lStyle = DS_MODALFRAME | WS_CAPTION | DS_3DLOOK | WS_VISIBLE | DS_SETFONT;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7080
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7081 add_long(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7082 add_long(0); // (lExtendedStyle)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7083 pnumitems = p; //save where the number of items must be stored
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7084 add_word(0); // NumberOfItems(will change later)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7085 add_word(10); // x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7086 add_word(10); // y
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7087 add_word(PixelToDialogX(dlgwidth)); // cx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7088
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7089 // Dialog height.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7090 if (vertical)
5284
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7091 dlgheight = msgheight + 2 * dlgPaddingY
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7092 + DLG_VERT_PADDING_Y + 2 * fontHeight * numButtons;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7093 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7094 dlgheight = msgheight + 3 * dlgPaddingY + 2 * fontHeight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7095
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7096 // Dialog needs to be taller if contains an edit box.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7097 editboxheight = fontHeight + dlgPaddingY + 4 * DLG_VERT_PADDING_Y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7098 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7099 dlgheight += editboxheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7100
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7101 // Restrict the size to a maximum. Causes a scrollbar to show up.
5284
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7102 if (dlgheight > maxDialogHeight)
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7103 {
6110
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
7104 msgheight = msgheight - (dlgheight - maxDialogHeight);
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
7105 dlgheight = maxDialogHeight;
1bff71d20262 updated for version 7.4.393
Bram Moolenaar <bram@vim.org>
parents: 5284
diff changeset
7106 scroll_flag = WS_VSCROLL;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7107 // Make sure scrollbar doesn't appear in the middle of the dialog
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7108 messageWidth = dlgwidth - dlg_icon_width - 3 * dlgPaddingX;
5284
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7109 }
7ed1ec814daf updated for version 7.4b.018
Bram Moolenaar <bram@vim.org>
parents: 5249
diff changeset
7110
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7111 add_word(PixelToDialogY(dlgheight));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7113 add_word(0); // Menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7114 add_word(0); // Class
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7115
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7116 // copy the title of the dialog
12543
e9028055f6d6 patch 8.0.1150: MS-Windows GUI: dialog font size is incorrect
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
7117 nchar = nCopyAnsiToWideChar(p, (title ? (LPSTR)title
e9028055f6d6 patch 8.0.1150: MS-Windows GUI: dialog font size is incorrect
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
7118 : (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7119 p += nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7120
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7121 // do the font, since DS_3DLOOK doesn't work properly
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7122 # ifdef USE_SYSMENU_FONT
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7123 if (use_lfSysmenu)
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7124 {
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7125 // point size
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7126 *p++ = -MulDiv(lfSysmenu.lfHeight, 72,
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7127 GetDeviceCaps(hdc, LOGPIXELSY));
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7128 wcscpy(p, lfSysmenu.lfFaceName);
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7129 nchar = (int)wcslen(lfSysmenu.lfFaceName) + 1;
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7130 }
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7131 else
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7132 # endif
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7133 {
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7134 *p++ = DLG_FONT_POINT_SIZE; // point size
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7135 nchar = nCopyAnsiToWideChar(p, DLG_FONT_NAME, FALSE);
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7136 }
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7137 p += nchar;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7138
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7139 buttonYpos = msgheight + 2 * dlgPaddingY;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7141 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7142 buttonYpos += editboxheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7143
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7144 pstart = tbuffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7145 if (!vertical)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7146 horizWidth = (dlgwidth - horizWidth) / 2; // Now it's X offset
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7147 for (i = 0; i < numButtons; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7148 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7149 // get end of this button.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7150 for ( pend = pstart;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7151 *pend && (*pend != DLG_BUTTON_SEP);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7152 pend++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7153 ;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7154
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7155 if (*pend)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7156 *pend = '\0';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7157
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7158 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7159 * old NOTE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7160 * setting the BS_DEFPUSHBUTTON style doesn't work because Windows sets
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7161 * the focus to the first tab-able button and in so doing makes that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7162 * the default!! Grrr. Workaround: Make the default button the only
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7163 * one with WS_TABSTOP style. Means user can't tab between buttons, but
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7164 * he/she can use arrow keys.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7165 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7166 * new NOTE: BS_DEFPUSHBUTTON is required to be able to select the
1213
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
7167 * right button when hitting <Enter>. E.g., for the ":confirm quit"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7168 * dialog. Also needed for when the textfield is the default control.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7169 * It appears to work now (perhaps not on Win95?).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7170 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7171 if (vertical)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7172 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7173 p = add_dialog_element(p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7174 (i == dfltbutton
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7175 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7176 PixelToDialogX(DLG_VERT_PADDING_X),
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7177 PixelToDialogY(buttonYpos // TBK
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7178 + 2 * fontHeight * i),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7179 PixelToDialogX(dlgwidth - 2 * DLG_VERT_PADDING_X),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7180 (WORD)(PixelToDialogY(2 * fontHeight) - 1),
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7181 (WORD)(IDCANCEL + 1 + i), (WORD)0x0080, (char *)pstart);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7182 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7183 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7184 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7185 p = add_dialog_element(p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7186 (i == dfltbutton
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7187 ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON) | WS_TABSTOP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7188 PixelToDialogX(horizWidth + buttonPositions[i]),
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7189 PixelToDialogY(buttonYpos), // TBK
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7190 PixelToDialogX(buttonWidths[i]),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7191 (WORD)(PixelToDialogY(2 * fontHeight) - 1),
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7192 (WORD)(IDCANCEL + 1 + i), (WORD)0x0080, (char *)pstart);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7193 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7194 pstart = pend + 1; //next button
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7195 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7196 *pnumitems += numButtons;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7197
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7198 // Vim icon
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7199 p = add_dialog_element(p, SS_ICON,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7200 PixelToDialogX(dlgPaddingX),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7201 PixelToDialogY(dlgPaddingY),
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7202 PixelToDialogX(dlg_icon_width),
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7203 PixelToDialogY(dlg_icon_height),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7204 DLG_NONBUTTON_CONTROL + 0, (WORD)0x0082,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7205 dlg_icons[type]);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7206
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7207 // Dialog message
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7208 p = add_dialog_element(p, ES_LEFT|scroll_flag|ES_MULTILINE|ES_READONLY,
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7209 PixelToDialogX(2 * dlgPaddingX + dlg_icon_width),
153
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7210 PixelToDialogY(dlgPaddingY),
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7211 (WORD)(PixelToDialogX(messageWidth) + 1),
19670b05ee32 updated for version 7.0047
vimboss
parents: 148
diff changeset
7212 PixelToDialogY(msgheight),
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7213 DLG_NONBUTTON_CONTROL + 1, (WORD)0x0081, (char *)message);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7214
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7215 // Edit box
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7216 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7217 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7218 p = add_dialog_element(p, ES_LEFT|ES_AUTOHSCROLL|WS_TABSTOP|WS_BORDER,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7219 PixelToDialogX(2 * dlgPaddingX),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7220 PixelToDialogY(2 * dlgPaddingY + msgheight),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7221 PixelToDialogX(dlgwidth - 4 * dlgPaddingX),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7222 PixelToDialogY(fontHeight + dlgPaddingY),
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7223 DLG_NONBUTTON_CONTROL + 2, (WORD)0x0081, (char *)textfield);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7224 *pnumitems += 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7225 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7227 *pnumitems += 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7228
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7229 SelectFont(hdc, oldFont);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7230 DeleteObject(font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7231 ReleaseDC(hwnd, hdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7232
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7233 // Let the dialog_callback() function know which button to make default
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7234 // If we have an edit box, make that the default. We also need to tell
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7235 // dialog_callback() if this dialog contains an edit box or not. We do
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7236 // this by setting s_textfield if it does.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7237 if (textfield != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7238 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7239 dialog_default_button = DLG_NONBUTTON_CONTROL + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7240 s_textfield = textfield;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7241 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7242 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7243 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7244 dialog_default_button = IDCANCEL + 1 + dfltbutton;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7245 s_textfield = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7246 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7247
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7248 // show the dialog box modally and get a return value
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7249 nchar = (int)DialogBoxIndirect(
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
7250 g_hinst,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7251 (LPDLGTEMPLATE)pdlgtemplate,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7252 s_hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7253 (DLGPROC)dialog_callback);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7254
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7255 LocalFree(LocalHandle(pdlgtemplate));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7256 vim_free(tbuffer);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7257 vim_free(buttonWidths);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7258 vim_free(buttonPositions);
158
78423945b251 updated for version 7.0048
vimboss
parents: 153
diff changeset
7259 vim_free(ga.ga_data);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7260
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7261 // Focus back to our window (for when MDI is used).
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7262 (void)SetFocus(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7263
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7264 return nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7265 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7266
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7267 #endif // FEAT_GUI_DIALOG
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7268
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7269 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7270 * Put a simple element (basic class) onto a dialog template in memory.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7271 * return a pointer to where the next item should be added.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7272 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7273 * parameters:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7274 * lStyle = additional style flags
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7275 * (be careful, NT3.51 & Win32s will ignore the new ones)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7276 * x,y = x & y positions IN DIALOG UNITS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7277 * w,h = width and height IN DIALOG UNITS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7278 * Id = ID used in messages
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7279 * clss = class ID, e.g 0x0080 for a button, 0x0082 for a static
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7280 * caption = usually text or resource name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7281 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7282 * TODO: use the length information noted here to enable the dialog creation
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7283 * routines to work out more exactly how much memory they need to alloc.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7284 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7285 static PWORD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7286 add_dialog_element(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7287 PWORD p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7288 DWORD lStyle,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7289 WORD x,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7290 WORD y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7291 WORD w,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7292 WORD h,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7293 WORD Id,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7294 WORD clss,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7295 const char *caption)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7296 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7297 int nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7298
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7299 p = lpwAlign(p); // Align to dword boundary
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7300 lStyle = lStyle | WS_VISIBLE | WS_CHILD;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7301 *p++ = LOWORD(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7302 *p++ = HIWORD(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7303 *p++ = 0; // LOWORD (lExtendedStyle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7304 *p++ = 0; // HIWORD (lExtendedStyle)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7305 *p++ = x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7306 *p++ = y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7307 *p++ = w;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7308 *p++ = h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7309 *p++ = Id; //9 or 10 words in all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7310
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7311 *p++ = (WORD)0xffff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7312 *p++ = clss; //2 more here
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7313
12543
e9028055f6d6 patch 8.0.1150: MS-Windows GUI: dialog font size is incorrect
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
7314 nchar = nCopyAnsiToWideChar(p, (LPSTR)caption, TRUE); //strlen(caption)+1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7315 p += nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7316
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7317 *p++ = 0; // advance pointer over nExtraStuff WORD - 2 more
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7318
26771
fc859aea8cec patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents: 24804
diff changeset
7319 return p; // total = 15 + strlen(caption) words
fc859aea8cec patch 8.2.3914: various spelling mistakes in comments
Bram Moolenaar <Bram@vim.org>
parents: 24804
diff changeset
7320 // bytes read = 2 * total
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7321 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7322
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7323
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7324 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7325 * Helper routine. Take an input pointer, return closest pointer that is
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7326 * aligned on a DWORD (4 byte) boundary. Taken from the Win32SDK samples.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7327 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7328 static LPWORD
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7329 lpwAlign(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7330 LPWORD lpIn)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7331 {
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7332 long_u ul;
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7333
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7334 ul = (long_u)lpIn;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7335 ul += 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7336 ul >>= 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7337 ul <<= 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7338 return (LPWORD)ul;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7340
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7341 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7342 * Helper routine. Takes second parameter as Ansi string, copies it to first
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7343 * parameter as wide character (16-bits / char) string, and returns integer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7344 * number of wide characters (words) in string (including the trailing wide
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7345 * char NULL). Partly taken from the Win32SDK samples.
12543
e9028055f6d6 patch 8.0.1150: MS-Windows GUI: dialog font size is incorrect
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
7346 * If "use_enc" is TRUE, 'encoding' is used for "lpAnsiIn". If FALSE, current
e9028055f6d6 patch 8.0.1150: MS-Windows GUI: dialog font size is incorrect
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
7347 * ACP is used for "lpAnsiIn". */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7348 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7349 nCopyAnsiToWideChar(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7350 LPWORD lpWCStr,
12543
e9028055f6d6 patch 8.0.1150: MS-Windows GUI: dialog font size is incorrect
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
7351 LPSTR lpAnsiIn,
e9028055f6d6 patch 8.0.1150: MS-Windows GUI: dialog font size is incorrect
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
7352 BOOL use_enc)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7353 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7354 int nChar = 0;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7355 int len = lstrlen(lpAnsiIn) + 1; // include NUL character
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7356 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7357 WCHAR *wn;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7358
12543
e9028055f6d6 patch 8.0.1150: MS-Windows GUI: dialog font size is incorrect
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
7359 if (use_enc && enc_codepage >= 0 && (int)GetACP() != enc_codepage)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7360 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7361 // 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
7362 wn = enc_to_utf16((char_u *)lpAnsiIn, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7363 if (wn != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7364 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7365 wcscpy(lpWCStr, wn);
835
8bebcabccc2c updated for version 7.0e01
vimboss
parents: 824
diff changeset
7366 nChar = (int)wcslen(wn) + 1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7367 vim_free(wn);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7368 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7369 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7370 if (nChar == 0)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7371 // Use Win32 conversion function.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7372 nChar = MultiByteToWideChar(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7373 enc_codepage > 0 ? enc_codepage : CP_ACP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7374 MB_PRECOMPOSED,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7375 lpAnsiIn, len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7376 lpWCStr, len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7377 for (i = 0; i < nChar; ++i)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7378 if (lpWCStr[i] == (WORD)'\t') // replace tabs with spaces
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7379 lpWCStr[i] = (WORD)' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7380
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7381 return nChar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7382 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7383
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7384
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7385 #ifdef FEAT_TEAROFF
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7386 /*
12668
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7387 * Lookup menu handle from "menu_id".
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7388 */
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7389 static HMENU
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7390 tearoff_lookup_menuhandle(
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7391 vimmenu_T *menu,
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7392 WORD menu_id)
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7393 {
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7394 for ( ; menu != NULL; menu = menu->next)
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7395 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7396 if (menu->modes == 0) // this menu has just been deleted
12668
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7397 continue;
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7398 if (menu_is_separator(menu->dname))
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7399 continue;
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7400 if ((WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000) == menu_id)
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7401 return menu->submenu_id;
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7402 }
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7403 return NULL;
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7404 }
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7405
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7406 /*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7407 * The callback function for all the modeless dialogs that make up the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7408 * "tearoff menus" Very simple - forward button presses (to fool Vim into
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7409 * thinking its menus have been clicked), and go away when closed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7410 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7411 static LRESULT CALLBACK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7412 tearoff_callback(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7413 HWND hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7414 UINT message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7415 WPARAM wParam,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7416 LPARAM lParam)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7417 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7418 if (message == WM_INITDIALOG)
12668
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7419 {
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7420 SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)lParam);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7421 return (TRUE);
12668
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7422 }
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7423
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7424 // May show the mouse pointer again.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7425 HandleMouseHide(message, lParam);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7426
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7427 if (message == WM_COMMAND)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7428 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7429 if ((WORD)(LOWORD(wParam)) & 0x8000)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7430 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7431 POINT mp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7432 RECT rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7433
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7434 if (GetCursorPos(&mp) && GetWindowRect(hwnd, &rect))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7435 {
12668
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7436 vimmenu_T *menu;
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7437
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7438 menu = (vimmenu_T*)GetWindowLongPtr(hwnd, DWLP_USER);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7439 (void)TrackPopupMenu(
12668
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7440 tearoff_lookup_menuhandle(menu, LOWORD(wParam)),
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7441 TPM_LEFTALIGN | TPM_LEFTBUTTON,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7442 (int)rect.right - 8,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7443 (int)mp.y,
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7444 (int)0, // reserved param
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7445 s_hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7446 NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7447 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7448 * NOTE: The pop-up menu can eat the mouse up event.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7449 * We deal with this in normal.c.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7450 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7451 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7452 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7453 else
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7454 // Pass on messages to the main Vim window
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7455 PostMessage(s_hwnd, WM_COMMAND, LOWORD(wParam), 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7456 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7457 * Give main window the focus back: this is so after
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7458 * choosing a tearoff button you can start typing again
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7459 * straight away.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7460 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7461 (void)SetFocus(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7462 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7463 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7464 if ((message == WM_SYSCOMMAND) && (wParam == SC_CLOSE))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7465 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7466 DestroyWindow(hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7467 return TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7468 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7469
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7470 // When moved around, give main window the focus back.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7471 if (message == WM_EXITSIZEMOVE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7472 (void)SetActiveWindow(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7473
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7474 return FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7475 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7476 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7477
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7478
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7479 /*
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7480 * Computes the dialog base units based on the current dialog font.
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7481 * We don't use the GetDialogBaseUnits() API, because we don't use the
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7482 * (old-style) system font.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7483 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7484 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7485 get_dialog_font_metrics(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7486 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7487 HDC hdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7488 HFONT hfontTools = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7489 SIZE size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7490 #ifdef USE_SYSMENU_FONT
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
7491 LOGFONTW lfSysmenu;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7492 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7493
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7494 #ifdef USE_SYSMENU_FONT
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7495 if (gui_w32_get_menu_font(&lfSysmenu) == OK)
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
7496 hfontTools = CreateFontIndirectW(&lfSysmenu);
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7497 else
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7498 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7499 hfontTools = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0,
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7500 0, 0, 0, 0, VARIABLE_PITCH, DLG_FONT_NAME);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7501
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7502 hdc = GetDC(s_hwnd);
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7503 SelectObject(hdc, hfontTools);
27332
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
7504 GetAverageFontSize(hdc, &size);
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7505 ReleaseDC(s_hwnd, hdc);
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7506
27332
251cae25bb49 patch 8.2.4194: MS-Windows: code for calculating font size is duplicated
Bram Moolenaar <Bram@vim.org>
parents: 27322
diff changeset
7507 s_dlgfntwidth = (WORD)size.cx;
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7508 s_dlgfntheight = (WORD)size.cy;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7509 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7510
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7511 #if defined(FEAT_MENU) && defined(FEAT_TEAROFF)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7512 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7513 * Create a pseudo-"tearoff menu" based on the child
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7514 * items of a given menu pointer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7515 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7516 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7517 gui_mch_tearoff(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7518 char_u *title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7519 vimmenu_T *menu,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7520 int initX,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7521 int initY)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7522 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7523 WORD *p, *pdlgtemplate, *pnumitems, *ptrueheight;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7524 int template_len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7525 int nchar, textWidth, submenuWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7526 DWORD lStyle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7527 DWORD lExtendedStyle;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7528 WORD dlgwidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7529 WORD menuID;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7530 vimmenu_T *pmenu;
12668
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7531 vimmenu_T *top_menu;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7532 vimmenu_T *the_menu = menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7533 HWND hwnd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7534 HDC hdc;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7535 HFONT font, oldFont;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7536 int col, spaceWidth, len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7537 int columnWidths[2];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7538 char_u *label, *text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7539 int acLen = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7540 int nameLen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7541 int padding0, padding1, padding2 = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7542 int sepPadding=0;
87
014ba200db86 updated for version 7.0035
vimboss
parents: 39
diff changeset
7543 int x;
014ba200db86 updated for version 7.0035
vimboss
parents: 39
diff changeset
7544 int y;
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7545 # ifdef USE_SYSMENU_FONT
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
7546 LOGFONTW lfSysmenu;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7547 int use_lfSysmenu = FALSE;
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7548 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7549
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7550 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7551 * If this menu is already torn off, move it to the mouse position.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7552 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7553 if (IsWindow(menu->tearoff_handle))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7554 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7555 POINT mp;
27281
f7d73708b391 patch 8.2.4169: MS-Windows: unnessary casts and other minor things
Bram Moolenaar <Bram@vim.org>
parents: 27261
diff changeset
7556 if (GetCursorPos(&mp))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7557 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7558 SetWindowPos(menu->tearoff_handle, NULL, mp.x, mp.y, 0, 0,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7559 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7560 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7561 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7562 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7563
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7564 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7565 * Create a new tearoff.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7566 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7567 if (*title == MNU_HIDDEN_CHAR)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7568 title++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7569
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7570 // Allocate memory to store the dialog template. It's made bigger when
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7571 // needed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7572 template_len = DLG_ALLOC_SIZE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7573 pdlgtemplate = p = (WORD *)LocalAlloc(LPTR, template_len);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7574 if (p == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7575 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7576
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7577 hwnd = GetDesktopWindow();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7578 hdc = GetWindowDC(hwnd);
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7579 # ifdef USE_SYSMENU_FONT
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7580 if (gui_w32_get_menu_font(&lfSysmenu) == OK)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7581 {
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
7582 font = CreateFontIndirectW(&lfSysmenu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7583 use_lfSysmenu = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7584 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7585 else
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7586 # endif
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7587 font = CreateFont(-DLG_FONT_POINT_SIZE, 0, 0, 0, 0, 0, 0, 0,
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7588 0, 0, 0, 0, VARIABLE_PITCH, DLG_FONT_NAME);
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7589
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7590 oldFont = SelectFont(hdc, font);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7591
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7592 // Calculate width of a single space. Used for padding columns to the
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7593 // right width.
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7594 spaceWidth = GetTextWidth(hdc, (char_u *)" ", 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7595
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7596 // Figure out max width of the text column, the accelerator column and the
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7597 // optional submenu column.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7598 submenuWidth = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7599 for (col = 0; col < 2; col++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7600 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7601 columnWidths[col] = 0;
19934
3ff714d765ba patch 8.2.0523: loops are repeated
Bram Moolenaar <Bram@vim.org>
parents: 18788
diff changeset
7602 FOR_ALL_CHILD_MENUS(menu, pmenu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7603 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7604 // Use "dname" here to compute the width of the visible text.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7605 text = (col == 0) ? pmenu->dname : pmenu->actext;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7606 if (text != NULL && *text != NUL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7607 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7608 textWidth = GetTextWidthEnc(hdc, text, (int)STRLEN(text));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7609 if (textWidth > columnWidths[col])
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7610 columnWidths[col] = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7611 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7612 if (pmenu->children != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7613 submenuWidth = TEAROFF_COLUMN_PADDING * spaceWidth;
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 if (columnWidths[1] == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7617 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7618 // no accelerators
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7619 if (submenuWidth != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7620 columnWidths[0] += submenuWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7621 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7622 columnWidths[0] += spaceWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7623 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7624 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7625 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7626 // there is an accelerator column
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7627 columnWidths[0] += TEAROFF_COLUMN_PADDING * spaceWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7628 columnWidths[1] += submenuWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7629 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7630
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7631 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7632 * Now find the total width of our 'menu'.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7633 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7634 textWidth = columnWidths[0] + columnWidths[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7635 if (submenuWidth != 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7636 {
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7637 submenuWidth = GetTextWidth(hdc, (char_u *)TEAROFF_SUBMENU_LABEL,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7638 (int)STRLEN(TEAROFF_SUBMENU_LABEL));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7639 textWidth += submenuWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7640 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7641 dlgwidth = GetTextWidthEnc(hdc, title, (int)STRLEN(title));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7642 if (textWidth > dlgwidth)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7643 dlgwidth = textWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7644 dlgwidth += 2 * TEAROFF_PADDING_X + TEAROFF_BUTTON_PAD_X;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7645
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7646 // start to fill in the dlgtemplate information. addressing by WORDs
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7647 lStyle = DS_MODALFRAME | WS_CAPTION | WS_SYSMENU | DS_SETFONT | WS_VISIBLE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7648
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7649 lExtendedStyle = WS_EX_TOOLWINDOW|WS_EX_STATICEDGE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7650 *p++ = LOWORD(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7651 *p++ = HIWORD(lStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7652 *p++ = LOWORD(lExtendedStyle);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7653 *p++ = HIWORD(lExtendedStyle);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7654 pnumitems = p; // save where the number of items must be stored
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7655 *p++ = 0; // NumberOfItems(will change later)
87
014ba200db86 updated for version 7.0035
vimboss
parents: 39
diff changeset
7656 gui_mch_getmouse(&x, &y);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7657 if (initX == 0xffffL)
87
014ba200db86 updated for version 7.0035
vimboss
parents: 39
diff changeset
7658 *p++ = PixelToDialogX(x); // x
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7659 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7660 *p++ = PixelToDialogX(initX); // x
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7661 if (initY == 0xffffL)
87
014ba200db86 updated for version 7.0035
vimboss
parents: 39
diff changeset
7662 *p++ = PixelToDialogY(y); // y
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7663 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7664 *p++ = PixelToDialogY(initY); // y
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7665 *p++ = PixelToDialogX(dlgwidth); // cx
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7666 ptrueheight = p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7667 *p++ = 0; // dialog height: changed later anyway
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7668 *p++ = 0; // Menu
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7669 *p++ = 0; // Class
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7670
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7671 // copy the title of the dialog
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7672 nchar = nCopyAnsiToWideChar(p, ((*title)
12543
e9028055f6d6 patch 8.0.1150: MS-Windows GUI: dialog font size is incorrect
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
7673 ? (LPSTR)title
e9028055f6d6 patch 8.0.1150: MS-Windows GUI: dialog font size is incorrect
Christian Brabandt <cb@256bit.org>
parents: 12513
diff changeset
7674 : (LPSTR)("Vim "VIM_VERSION_MEDIUM)), TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7675 p += nchar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7676
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7677 // do the font, since DS_3DLOOK doesn't work properly
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7678 # ifdef USE_SYSMENU_FONT
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7679 if (use_lfSysmenu)
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7680 {
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7681 // point size
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7682 *p++ = -MulDiv(lfSysmenu.lfHeight, 72,
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7683 GetDeviceCaps(hdc, LOGPIXELSY));
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7684 wcscpy(p, lfSysmenu.lfFaceName);
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7685 nchar = (int)wcslen(lfSysmenu.lfFaceName) + 1;
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7686 }
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7687 else
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7688 # endif
27322
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7689 {
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7690 *p++ = DLG_FONT_POINT_SIZE; // point size
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7691 nchar = nCopyAnsiToWideChar(p, DLG_FONT_NAME, FALSE);
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7692 }
574cd25f0962 patch 8.2.4189: MS-Windows: code for "old look" is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27293
diff changeset
7693 p += nchar;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7694
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7695 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7696 * Loop over all the items in the menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7697 * But skip over the tearbar.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7698 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7699 if (STRCMP(menu->children->name, TEAR_STRING) == 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7700 menu = menu->children->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7701 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7702 menu = menu->children;
12668
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7703 top_menu = menu;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7704 for ( ; menu != NULL; menu = menu->next)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7705 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7706 if (menu->modes == 0) // this menu has just been deleted
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7707 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7708 if (menu_is_separator(menu->dname))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7709 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7710 sepPadding += 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7711 continue;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7712 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7713
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7714 // Check if there still is plenty of room in the template. Make it
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7715 // larger when needed.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7716 if (((char *)p - (char *)pdlgtemplate) + 1000 > template_len)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7717 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7718 WORD *newp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7719
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7720 newp = (WORD *)LocalAlloc(LPTR, template_len + 4096);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7721 if (newp != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7722 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7723 template_len += 4096;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7724 mch_memmove(newp, pdlgtemplate,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7725 (char *)p - (char *)pdlgtemplate);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7726 p = newp + (p - pdlgtemplate);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7727 pnumitems = newp + (pnumitems - pdlgtemplate);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7728 ptrueheight = newp + (ptrueheight - pdlgtemplate);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7729 LocalFree(LocalHandle(pdlgtemplate));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7730 pdlgtemplate = newp;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7731 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7732 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7733
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7734 // Figure out minimal length of this menu label. Use "name" for the
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7735 // actual text, "dname" for estimating the displayed size. "name"
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7736 // has "&a" for mnemonic and includes the accelerator.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7737 len = nameLen = (int)STRLEN(menu->name);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7738 padding0 = (columnWidths[0] - GetTextWidthEnc(hdc, menu->dname,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7739 (int)STRLEN(menu->dname))) / spaceWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7740 len += padding0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7741
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7742 if (menu->actext != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7743 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7744 acLen = (int)STRLEN(menu->actext);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7745 len += acLen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7746 textWidth = GetTextWidthEnc(hdc, menu->actext, acLen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7747 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7748 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7749 textWidth = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7750 padding1 = (columnWidths[1] - textWidth) / spaceWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7751 len += padding1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7752
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7753 if (menu->children == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7754 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7755 padding2 = submenuWidth / spaceWidth;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7756 len += padding2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7757 menuID = (WORD)(menu->id);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7758 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7759 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7760 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7761 len += (int)STRLEN(TEAROFF_SUBMENU_LABEL);
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7762 menuID = (WORD)((long_u)(menu->submenu_id) | (DWORD)0x8000);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7763 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7764
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7765 // Allocate menu label and fill it in
16764
ef00b6bc186b patch 8.1.1384: using "int" for alloc() often results in compiler warnings
Bram Moolenaar <Bram@vim.org>
parents: 16606
diff changeset
7766 text = label = alloc(len + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7767 if (label == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7768 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7769
419
f713fc55bf7b updated for version 7.0109
vimboss
parents: 401
diff changeset
7770 vim_strncpy(text, menu->name, nameLen);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7771 text = vim_strchr(text, TAB); // stop at TAB before actext
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7772 if (text == NULL)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7773 text = label + nameLen; // no actext, use whole name
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7774 while (padding0-- > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7775 *text++ = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7776 if (menu->actext != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7777 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7778 STRNCPY(text, menu->actext, acLen);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7779 text += acLen;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7780 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7781 while (padding1-- > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7782 *text++ = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7783 if (menu->children != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7784 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7785 STRCPY(text, TEAROFF_SUBMENU_LABEL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7786 text += STRLEN(TEAROFF_SUBMENU_LABEL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7787 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7788 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7789 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7790 while (padding2-- > 0)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7791 *text++ = ' ';
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7792 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7793 *text = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7794
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7795 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7796 * BS_LEFT will just be ignored on Win32s/NT3.5x - on
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7797 * W95/NT4 it makes the tear-off look more like a menu.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7798 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7799 p = add_dialog_element(p,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7800 BS_PUSHBUTTON|BS_LEFT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7801 (WORD)PixelToDialogX(TEAROFF_PADDING_X),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7802 (WORD)(sepPadding + 1 + 13 * (*pnumitems)),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7803 (WORD)PixelToDialogX(dlgwidth - 2 * TEAROFF_PADDING_X),
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7804 (WORD)12,
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7805 menuID, (WORD)0x0080, (char *)label);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7806 vim_free(label);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7807 (*pnumitems)++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7808 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7809
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7810 *ptrueheight = (WORD)(sepPadding + 1 + 13 * (*pnumitems));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7811
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7812
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7813 // show modelessly
12668
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7814 the_menu->tearoff_handle = CreateDialogIndirectParam(
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
7815 g_hinst,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7816 (LPDLGTEMPLATE)pdlgtemplate,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7817 s_hwnd,
12668
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7818 (DLGPROC)tearoff_callback,
637096f179c4 patch 8.0.1212: MS-Windows: tear-off menu does not work on 64 bit
Christian Brabandt <cb@256bit.org>
parents: 12666
diff changeset
7819 (LPARAM)top_menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7820
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7821 LocalFree(LocalHandle(pdlgtemplate));
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7822 SelectFont(hdc, oldFont);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7823 DeleteObject(font);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7824 ReleaseDC(hwnd, hdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7825
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7826 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7827 * Reassert ourselves as the active window. This is so that after creating
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7828 * 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
7829 * typing again!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7830 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7831 (void)SetActiveWindow(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7832
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7833 // make sure the right buttons are enabled
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7834 force_menu_update = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7835 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7836 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7837
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7838 #if defined(FEAT_TOOLBAR) || defined(PROTO)
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7839 # include "gui_w32_rc.h"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7840
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7841 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7842 * Create the toolbar, initially unpopulated.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7843 * (just like the menu, there are no defaults, it's all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7844 * set up through menu.vim)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7845 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7846 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7847 initialise_toolbar(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7848 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7849 InitCommonControls();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7850 s_toolbarhwnd = CreateToolbarEx(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7851 s_hwnd,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7852 WS_CHILD | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7853 4000, //any old big number
1213
8906c10ecbb0 updated for version 7.1b
vimboss
parents: 1153
diff changeset
7854 31, //number of images in initial bitmap
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
7855 g_hinst,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7856 IDR_TOOLBAR1, // id of initial bitmap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7857 NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7858 0, // initial number of buttons
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7859 TOOLBAR_BUTTON_WIDTH, //api guide is wrong!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7860 TOOLBAR_BUTTON_HEIGHT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7861 TOOLBAR_BUTTON_WIDTH,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7862 TOOLBAR_BUTTON_HEIGHT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7863 sizeof(TBBUTTON)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7864 );
18652
94b88fa5825d patch 8.1.2318: MS-Windows GUI: main background shows in toolbar
Bram Moolenaar <Bram@vim.org>
parents: 18617
diff changeset
7865
94b88fa5825d patch 8.1.2318: MS-Windows GUI: main background shows in toolbar
Bram Moolenaar <Bram@vim.org>
parents: 18617
diff changeset
7866 // Remove transparency from the toolbar to prevent the main window
94b88fa5825d patch 8.1.2318: MS-Windows GUI: main background shows in toolbar
Bram Moolenaar <Bram@vim.org>
parents: 18617
diff changeset
7867 // background colour showing through
94b88fa5825d patch 8.1.2318: MS-Windows GUI: main background shows in toolbar
Bram Moolenaar <Bram@vim.org>
parents: 18617
diff changeset
7868 SendMessage(s_toolbarhwnd, TB_SETSTYLE, 0,
94b88fa5825d patch 8.1.2318: MS-Windows GUI: main background shows in toolbar
Bram Moolenaar <Bram@vim.org>
parents: 18617
diff changeset
7869 SendMessage(s_toolbarhwnd, TB_GETSTYLE, 0, 0) & ~TBSTYLE_TRANSPARENT);
94b88fa5825d patch 8.1.2318: MS-Windows GUI: main background shows in toolbar
Bram Moolenaar <Bram@vim.org>
parents: 18617
diff changeset
7870
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
7871 s_toolbar_wndproc = SubclassWindow(s_toolbarhwnd, toolbar_wndproc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7872
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7873 gui_mch_show_toolbar(vim_strchr(p_go, GO_TOOLBAR) != NULL);
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7874
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7875 update_toolbar_size();
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7876 }
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7877
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7878 static void
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7879 update_toolbar_size(void)
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7880 {
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7881 int w, h;
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
7882 TBMETRICS tbm;
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
7883
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
7884 tbm.cbSize = sizeof(TBMETRICS);
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7885 tbm.dwMask = TBMF_PAD | TBMF_BUTTONSPACING;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7886 SendMessage(s_toolbarhwnd, TB_GETMETRICS, 0, (LPARAM)&tbm);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7887 //TRACE("Pad: %d, %d", tbm.cxPad, tbm.cyPad);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7888 //TRACE("ButtonSpacing: %d, %d", tbm.cxButtonSpacing, tbm.cyButtonSpacing);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7889
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7890 w = (TOOLBAR_BUTTON_WIDTH + tbm.cxPad) * s_dpi / DEFAULT_DPI;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7891 h = (TOOLBAR_BUTTON_HEIGHT + tbm.cyPad) * s_dpi / DEFAULT_DPI;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7892 //TRACE("button size: %d, %d", w, h);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7893 SendMessage(s_toolbarhwnd, TB_SETBUTTONSIZE, 0, MAKELPARAM(w, h));
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7894 gui.toolbar_height = h + 6;
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7895
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7896 //DWORD s = SendMessage(s_toolbarhwnd, TB_GETBUTTONSIZE, 0, 0);
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7897 //TRACE("actual button size: %d, %d", LOWORD(s), HIWORD(s));
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7898
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7899 // TODO:
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7900 // Currently, this function only updates the size of toolbar buttons.
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
7901 // It would be nice if the toolbar images are resized based on DPI.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7902 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7903
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
7904 static LRESULT CALLBACK
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
7905 toolbar_wndproc(
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
7906 HWND hwnd,
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
7907 UINT uMsg,
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
7908 WPARAM wParam,
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
7909 LPARAM lParam)
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
7910 {
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
7911 HandleMouseHide(uMsg, lParam);
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
7912 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
7913 }
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
7914
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7915 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7916 get_toolbar_bitmap(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7917 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7918 int i = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7919
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7920 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7921 * Check user bitmaps first, unless builtin is specified.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7922 */
10264
c036c0f636d5 commit https://github.com/vim/vim/commit/cea912af725c54f4727a0565e31661f6b29c6bb1
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
7923 if (!menu->icon_builtin)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7924 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7925 char_u fname[MAXPATHL];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7926 HANDLE hbitmap = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7927
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7928 if (menu->iconfile != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7929 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7930 gui_find_iconfile(menu->iconfile, fname, "bmp");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7931 hbitmap = LoadImage(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7932 NULL,
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7933 (LPCSTR)fname,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7934 IMAGE_BITMAP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7935 TOOLBAR_BUTTON_WIDTH,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7936 TOOLBAR_BUTTON_HEIGHT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7937 LR_LOADFROMFILE |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7938 LR_LOADMAP3DCOLORS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7939 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7940 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7941
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7942 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7943 * If the LoadImage call failed, or the "icon=" file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7944 * didn't exist or wasn't specified, try the menu name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7945 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7946 if (hbitmap == NULL
5020
5eff37e92f03 updated for version 7.3.1254
Bram Moolenaar <bram@vim.org>
parents: 5016
diff changeset
7947 && (gui_find_bitmap(
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7948 # ifdef FEAT_MULTI_LANG
5020
5eff37e92f03 updated for version 7.3.1254
Bram Moolenaar <bram@vim.org>
parents: 5016
diff changeset
7949 menu->en_dname != NULL ? menu->en_dname :
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
7950 # endif
5020
5eff37e92f03 updated for version 7.3.1254
Bram Moolenaar <bram@vim.org>
parents: 5016
diff changeset
7951 menu->dname, fname, "bmp") == OK))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7952 hbitmap = LoadImage(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7953 NULL,
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
7954 (LPCSTR)fname,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7955 IMAGE_BITMAP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7956 TOOLBAR_BUTTON_WIDTH,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7957 TOOLBAR_BUTTON_HEIGHT,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7958 LR_LOADFROMFILE |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7959 LR_LOADMAP3DCOLORS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7960 );
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7961
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7962 if (hbitmap != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7963 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7964 TBADDBITMAP tbAddBitmap;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7965
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7966 tbAddBitmap.hInst = NULL;
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7967 tbAddBitmap.nID = (long_u)hbitmap;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7968
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7969 i = (int)SendMessage(s_toolbarhwnd, TB_ADDBITMAP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7970 (WPARAM)1, (LPARAM)&tbAddBitmap);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
7971 // i will be set to -1 if it fails
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7972 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7973 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7974 if (i == -1 && menu->iconidx >= 0 && menu->iconidx < TOOLBAR_BITMAP_COUNT)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7975 i = menu->iconidx;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7976
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7977 return i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7978 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7979 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7980
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
7981 #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
7982 static void
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
7983 initialise_tabline(void)
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
7984 {
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
7985 InitCommonControls();
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
7986
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
7987 s_tabhwnd = CreateWindow(WC_TABCONTROL, "Vim tabline",
840
2c885fab04e3 updated for version 7.0e06
vimboss
parents: 837
diff changeset
7988 WS_CHILD|TCS_FOCUSNEVER|TCS_TOOLTIPS,
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
7989 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
7990 CW_USEDEFAULT, s_hwnd, NULL, g_hinst, NULL);
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
7991 s_tabline_wndproc = SubclassWindow(s_tabhwnd, tabline_wndproc);
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 812
diff changeset
7992
843
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
7993 gui.tabline_height = TABLINE_HEIGHT;
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
7994
9f279ebda751 updated for version 7.0f01
vimboss
parents: 842
diff changeset
7995 set_tabline_font();
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
7996 }
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
7997
12666
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
7998 /*
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
7999 * Get tabpage_T from POINT.
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8000 */
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8001 static tabpage_T *
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8002 GetTabFromPoint(
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8003 HWND hWnd,
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8004 POINT pt)
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8005 {
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8006 tabpage_T *ptp = NULL;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8007
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8008 if (gui_mch_showing_tabline())
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8009 {
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8010 TCHITTESTINFO htinfo;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8011 htinfo.pt = pt;
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
8012 // ignore if a window under cursor is not tabcontrol.
12666
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8013 if (s_tabhwnd == hWnd)
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8014 {
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8015 int idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8016 if (idx != -1)
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8017 ptp = find_tabpage(idx + 1);
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8018 }
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8019 }
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8020 return ptp;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8021 }
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8022
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8023 static POINT s_pt = {0, 0};
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8024 static HCURSOR s_hCursor = NULL;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8025
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8026 static LRESULT CALLBACK
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8027 tabline_wndproc(
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8028 HWND hwnd,
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8029 UINT uMsg,
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8030 WPARAM wParam,
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8031 LPARAM lParam)
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8032 {
12666
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8033 POINT pt;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8034 tabpage_T *tp;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8035 RECT rect;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8036 int nCenter;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8037 int idx0;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8038 int idx1;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8039
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8040 HandleMouseHide(uMsg, lParam);
12666
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8041
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8042 switch (uMsg)
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8043 {
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8044 case WM_LBUTTONDOWN:
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8045 {
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8046 s_pt.x = GET_X_LPARAM(lParam);
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8047 s_pt.y = GET_Y_LPARAM(lParam);
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8048 SetCapture(hwnd);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8049 s_hCursor = GetCursor(); // backup default cursor
12666
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8050 break;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8051 }
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8052 case WM_MOUSEMOVE:
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8053 if (GetCapture() == hwnd
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8054 && ((wParam & MK_LBUTTON)) != 0)
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8055 {
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8056 pt.x = GET_X_LPARAM(lParam);
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8057 pt.y = s_pt.y;
27160
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
8058 if (abs(pt.x - s_pt.x) >
4482dd5f8869 patch 8.2.4109: MS-Windows: high dpi support is outdated
Bram Moolenaar <Bram@vim.org>
parents: 26966
diff changeset
8059 pGetSystemMetricsForDpi(SM_CXDRAG, s_dpi))
12666
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8060 {
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8061 SetCursor(LoadCursor(NULL, IDC_SIZEWE));
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8062
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8063 tp = GetTabFromPoint(hwnd, pt);
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8064 if (tp != NULL)
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8065 {
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8066 idx0 = tabpage_index(curtab) - 1;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8067 idx1 = tabpage_index(tp) - 1;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8068
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8069 TabCtrl_GetItemRect(hwnd, idx1, &rect);
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8070 nCenter = rect.left + (rect.right - rect.left) / 2;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8071
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8072 // Check if the mouse cursor goes over the center of
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8073 // the next tab to prevent "flickering".
12666
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8074 if ((idx0 < idx1) && (nCenter < pt.x))
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8075 {
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8076 tabpage_move(idx1 + 1);
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8077 update_screen(0);
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8078 }
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8079 else if ((idx1 < idx0) && (pt.x < nCenter))
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8080 {
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8081 tabpage_move(idx1);
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8082 update_screen(0);
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8083 }
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8084 }
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8085 }
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8086 }
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8087 break;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8088 case WM_LBUTTONUP:
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8089 {
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8090 if (GetCapture() == hwnd)
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8091 {
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8092 SetCursor(s_hCursor);
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8093 ReleaseCapture();
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8094 }
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8095 break;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8096 }
30523
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8097 case WM_MBUTTONUP:
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8098 {
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8099 TCHITTESTINFO htinfo;
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8100
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8101 htinfo.pt.x = GET_X_LPARAM(lParam);
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8102 htinfo.pt.y = GET_Y_LPARAM(lParam);
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8103 idx0 = TabCtrl_HitTest(hwnd, &htinfo);
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8104 if (idx0 != -1)
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8105 {
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8106 idx0 += 1;
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8107 send_tabline_menu_event(idx0, TABLINE_MENU_CLOSE);
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8108 }
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8109 break;
5ab992f09df8 patch 9.0.0597: cannot close a tab page with the middle mouse button
Bram Moolenaar <Bram@vim.org>
parents: 30200
diff changeset
8110 }
12666
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8111 default:
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8112 break;
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8113 }
856a840679e3 patch 8.0.1211: cannot reorder tab pages with drag & drop
Christian Brabandt <cb@256bit.org>
parents: 12543
diff changeset
8114
5223
91d478da863e updated for version 7.4a.037
Bram Moolenaar <bram@vim.org>
parents: 5020
diff changeset
8115 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
8116 }
810
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
8117 #endif
9f345c48220b updated for version 7.0c
vimboss
parents: 786
diff changeset
8118
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8119 #if defined(FEAT_OLE) || defined(FEAT_EVAL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8120 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8121 * Make the GUI window come to the foreground.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8122 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8123 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8124 gui_mch_set_foreground(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8125 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8126 if (IsIconic(s_hwnd))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8127 SendMessage(s_hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8128 SetForegroundWindow(s_hwnd);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8129 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8130 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8131
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8132 #if defined(FEAT_MBYTE_IME) && defined(DYNAMIC_IME)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8133 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8134 dyn_imm_load(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8135 {
2612
fa5dee44df3f updated for version 7.3.034
Bram Moolenaar <bram@vim.org>
parents: 2520
diff changeset
8136 hLibImm = vimLoadLib("imm32.dll");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8137 if (hLibImm == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8138 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8140 pImmGetCompositionStringW
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
8141 = (LONG (WINAPI *)(HIMC, DWORD, LPVOID, DWORD))GetProcAddress(hLibImm, "ImmGetCompositionStringW");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8142 pImmGetContext
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
8143 = (HIMC (WINAPI *)(HWND))GetProcAddress(hLibImm, "ImmGetContext");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8144 pImmAssociateContext
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
8145 = (HIMC (WINAPI *)(HWND, HIMC))GetProcAddress(hLibImm, "ImmAssociateContext");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8146 pImmReleaseContext
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
8147 = (BOOL (WINAPI *)(HWND, HIMC))GetProcAddress(hLibImm, "ImmReleaseContext");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8148 pImmGetOpenStatus
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
8149 = (BOOL (WINAPI *)(HIMC))GetProcAddress(hLibImm, "ImmGetOpenStatus");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8150 pImmSetOpenStatus
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
8151 = (BOOL (WINAPI *)(HIMC, BOOL))GetProcAddress(hLibImm, "ImmSetOpenStatus");
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
8152 pImmGetCompositionFontW
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
8153 = (BOOL (WINAPI *)(HIMC, LPLOGFONTW))GetProcAddress(hLibImm, "ImmGetCompositionFontW");
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
8154 pImmSetCompositionFontW
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
8155 = (BOOL (WINAPI *)(HIMC, LPLOGFONTW))GetProcAddress(hLibImm, "ImmSetCompositionFontW");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8156 pImmSetCompositionWindow
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
8157 = (BOOL (WINAPI *)(HIMC, LPCOMPOSITIONFORM))GetProcAddress(hLibImm, "ImmSetCompositionWindow");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8158 pImmGetConversionStatus
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
8159 = (BOOL (WINAPI *)(HIMC, LPDWORD, LPDWORD))GetProcAddress(hLibImm, "ImmGetConversionStatus");
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
8160 pImmSetConversionStatus
29105
faf7fcd1c8d5 patch 8.2.5073: clang on MS-Windows produces warnings
Bram Moolenaar <Bram@vim.org>
parents: 29096
diff changeset
8161 = (BOOL (WINAPI *)(HIMC, DWORD, DWORD))GetProcAddress(hLibImm, "ImmSetConversionStatus");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8162
27229
6837d2c14dee patch 8.2.4143: MS-Windows: IME support for Win9x is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27160
diff changeset
8163 if ( pImmGetCompositionStringW == NULL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8164 || pImmGetContext == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8165 || pImmAssociateContext == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8166 || pImmReleaseContext == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8167 || pImmGetOpenStatus == NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8168 || pImmSetOpenStatus == NULL
16152
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
8169 || pImmGetCompositionFontW == NULL
8f4eccaaf2c0 patch 8.1.1081: MS-Windows: cannot use some fonts
Bram Moolenaar <Bram@vim.org>
parents: 16123
diff changeset
8170 || pImmSetCompositionFontW == NULL
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8171 || pImmSetCompositionWindow == NULL
777
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
8172 || pImmGetConversionStatus == NULL
f664cc974a7a updated for version 7.0227
vimboss
parents: 714
diff changeset
8173 || pImmSetConversionStatus == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8174 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8175 FreeLibrary(hLibImm);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8176 hLibImm = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8177 pImmGetContext = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8178 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8179 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8180
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8181 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8182 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8183
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8184 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8185
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8186 #if defined(FEAT_SIGN_ICONS) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8187
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8188 # ifdef FEAT_XPM_W32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8189 # define IMAGE_XPM 100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8190 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8191
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8192 typedef struct _signicon_t
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8193 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8194 HANDLE hImage;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8195 UINT uType;
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8196 # ifdef FEAT_XPM_W32
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8197 HANDLE hShape; // Mask bitmap handle
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8198 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8199 } signicon_t;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8200
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8201 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8202 gui_mch_drawsign(int row, int col, int typenr)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8203 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8204 signicon_t *sign;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8205 int x, y, w, h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8207 if (!gui.in_use || (sign = (signicon_t *)sign_get_image(typenr)) == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8208 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8209
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8210 # if defined(FEAT_DIRECTX)
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
8211 if (IS_ENABLE_DIRECTX())
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
8212 DWriteContext_Flush(s_dwc);
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8213 # endif
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
8214
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8215 x = TEXT_X(col);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8216 y = TEXT_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8217 w = gui.char_width * 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8218 h = gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8219 switch (sign->uType)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8220 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8221 case IMAGE_BITMAP:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8222 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8223 HDC hdcMem;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8224 HBITMAP hbmpOld;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8225
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8226 hdcMem = CreateCompatibleDC(s_hdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8227 hbmpOld = (HBITMAP)SelectObject(hdcMem, sign->hImage);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8228 BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCCOPY);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8229 SelectObject(hdcMem, hbmpOld);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8230 DeleteDC(hdcMem);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8231 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8232 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8233 case IMAGE_ICON:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8234 case IMAGE_CURSOR:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8235 DrawIconEx(s_hdc, x, y, (HICON)sign->hImage, w, h, 0, NULL, DI_NORMAL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8236 break;
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8237 # ifdef FEAT_XPM_W32
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8238 case IMAGE_XPM:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8239 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8240 HDC hdcMem;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8241 HBITMAP hbmpOld;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8242
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8243 hdcMem = CreateCompatibleDC(s_hdc);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8244 hbmpOld = (HBITMAP)SelectObject(hdcMem, sign->hShape);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8245 // Make hole
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8246 BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCAND);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8247
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8248 SelectObject(hdcMem, sign->hImage);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8249 // Paint sign
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8250 BitBlt(s_hdc, x, y, w, h, hdcMem, 0, 0, SRCPAINT);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8251 SelectObject(hdcMem, hbmpOld);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8252 DeleteDC(hdcMem);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8253 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8254 break;
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8255 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8256 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8257 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8258
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8259 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8260 close_signicon_image(signicon_t *sign)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8261 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8262 if (sign)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8263 switch (sign->uType)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8264 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8265 case IMAGE_BITMAP:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8266 DeleteObject((HGDIOBJ)sign->hImage);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8267 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8268 case IMAGE_CURSOR:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8269 DestroyCursor((HCURSOR)sign->hImage);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8270 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8271 case IMAGE_ICON:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8272 DestroyIcon((HICON)sign->hImage);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8273 break;
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8274 # ifdef FEAT_XPM_W32
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8275 case IMAGE_XPM:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8276 DeleteObject((HBITMAP)sign->hImage);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8277 DeleteObject((HBITMAP)sign->hShape);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8278 break;
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8279 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8280 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8281 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8282
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8283 void *
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8284 gui_mch_register_sign(char_u *signfile)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8285 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8286 signicon_t sign, *psign;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8287 char_u *ext;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8288
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8289 sign.hImage = NULL;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8290 ext = signfile + STRLEN(signfile) - 4; // get extension
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8291 if (ext > signfile)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8292 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8293 int do_load = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8294
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8295 if (!STRICMP(ext, ".bmp"))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8296 sign.uType = IMAGE_BITMAP;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8297 else if (!STRICMP(ext, ".ico"))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8298 sign.uType = IMAGE_ICON;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8299 else if (!STRICMP(ext, ".cur") || !STRICMP(ext, ".ani"))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8300 sign.uType = IMAGE_CURSOR;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8301 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8302 do_load = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8303
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8304 if (do_load)
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8305 sign.hImage = (HANDLE)LoadImage(NULL, (LPCSTR)signfile, sign.uType,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8306 gui.char_width * 2, gui.char_height,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8307 LR_LOADFROMFILE | LR_CREATEDIBSECTION);
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8308 # ifdef FEAT_XPM_W32
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8309 if (!STRICMP(ext, ".xpm"))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8310 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8311 sign.uType = IMAGE_XPM;
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8312 LoadXpmImage((char *)signfile, (HBITMAP *)&sign.hImage,
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8313 (HBITMAP *)&sign.hShape);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8314 }
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8315 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8316 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8317
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8318 psign = NULL;
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
8319 if (sign.hImage && (psign = ALLOC_ONE(signicon_t)) != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8320 *psign = sign;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8321
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8322 if (!psign)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8323 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8324 if (sign.hImage)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8325 close_signicon_image(&sign);
26883
7f150a4936f2 patch 8.2.3970: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26865
diff changeset
8326 emsg(_(e_couldnt_read_in_sign_data));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8327 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8328 return (void *)psign;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8330 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8331
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8332 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8333 gui_mch_destroy_sign(void *sign)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8334 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8335 if (sign)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8336 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8337 close_signicon_image((signicon_t *)sign);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8338 vim_free(sign);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8339 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8340 }
293
f811be6fa9b5 updated for version 7.0077
vimboss
parents: 236
diff changeset
8341 #endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8342
12871
1a450ce6980c patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents: 12802
diff changeset
8343 #if defined(FEAT_BEVAL_GUI) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8344
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8345 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8346 * BALLOON-EVAL IMPLEMENTATION FOR WINDOWS.
148
72aefd4c1e0d updated for version 7.0046
vimboss
parents: 87
diff changeset
8347 * Added by Sergey Khorev <sergey.khorev@gmail.com>
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8348 *
12871
1a450ce6980c patch 8.0.1312: balloon_show() only works in terminal when compiled with GUI
Christian Brabandt <cb@256bit.org>
parents: 12802
diff changeset
8349 * The only reused thing is beval.h and get_beval_info()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8350 * from gui_beval.c (note it uses x and y of the BalloonEval struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8351 * to get current mouse position).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8352 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8353 * Trying to use as more Windows services as possible, and as less
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8354 * IE version as possible :)).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8355 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8356 * 1) Don't create ToolTip in gui_mch_create_beval_area, only initialize
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8357 * BalloonEval struct.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8358 * 2) Enable/Disable simply create/kill BalloonEval Timer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8359 * 3) When there was enough inactivity, timer procedure posts
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8360 * async request to debugger
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8361 * 4) gui_mch_post_balloon (invoked from netbeans.c) creates tooltip control
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8362 * and performs some actions to show it ASAP
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 1489
diff changeset
8363 * 5) WM_NOTIFY:TTN_POP destroys created tooltip
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8364 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8365
15277
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8366 static void
16196
973070a30381 patch 8.1.1103: MS-Windows: old API calls are no longer needed
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
8367 make_tooltip(BalloonEval *beval, char *text, POINT pt)
15277
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8368 {
27370
584f91cc2508 patch 8.2.4213: too much code for supporting old MSVC versions
Bram Moolenaar <Bram@vim.org>
parents: 27342
diff changeset
8369 TOOLINFOW *pti;
584f91cc2508 patch 8.2.4213: too much code for supporting old MSVC versions
Bram Moolenaar <Bram@vim.org>
parents: 27342
diff changeset
8370 RECT rect;
584f91cc2508 patch 8.2.4213: too much code for supporting old MSVC versions
Bram Moolenaar <Bram@vim.org>
parents: 27342
diff changeset
8371
584f91cc2508 patch 8.2.4213: too much code for supporting old MSVC versions
Bram Moolenaar <Bram@vim.org>
parents: 27342
diff changeset
8372 pti = alloc(sizeof(TOOLINFOW));
15277
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8373 if (pti == NULL)
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8374 return;
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8375
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8376 beval->balloon = CreateWindowExW(WS_EX_TOPMOST, TOOLTIPS_CLASSW,
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8377 NULL, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8378 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
16451
7ae2396cef62 patch 8.1.1230: a lot of code is shared between vim.exe and gvim.exe
Bram Moolenaar <Bram@vim.org>
parents: 16439
diff changeset
8379 beval->target, NULL, g_hinst, NULL);
15277
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8380
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8381 SetWindowPos(beval->balloon, HWND_TOPMOST, 0, 0, 0, 0,
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8382 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8383
27370
584f91cc2508 patch 8.2.4213: too much code for supporting old MSVC versions
Bram Moolenaar <Bram@vim.org>
parents: 27342
diff changeset
8384 pti->cbSize = sizeof(TOOLINFOW);
15277
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8385 pti->uFlags = TTF_SUBCLASS;
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8386 pti->hwnd = beval->target;
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8387 pti->hinst = 0; // Don't use string resources
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8388 pti->uId = ID_BEVAL_TOOLTIP;
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8389
27293
e91b577be192 patch 8.2.4175: MS-Windows: runtime check for multi-line balloon is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27283
diff changeset
8390 pti->lpszText = LPSTR_TEXTCALLBACKW;
e91b577be192 patch 8.2.4175: MS-Windows: runtime check for multi-line balloon is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27283
diff changeset
8391 beval->tofree = enc_to_utf16((char_u*)text, NULL);
e91b577be192 patch 8.2.4175: MS-Windows: runtime check for multi-line balloon is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27283
diff changeset
8392 pti->lParam = (LPARAM)beval->tofree;
e91b577be192 patch 8.2.4175: MS-Windows: runtime check for multi-line balloon is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27283
diff changeset
8393 // switch multiline tooltips on
e91b577be192 patch 8.2.4175: MS-Windows: runtime check for multi-line balloon is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27283
diff changeset
8394 if (GetClientRect(s_textArea, &rect))
e91b577be192 patch 8.2.4175: MS-Windows: runtime check for multi-line balloon is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27283
diff changeset
8395 SendMessageW(beval->balloon, TTM_SETMAXTIPWIDTH, 0,
e91b577be192 patch 8.2.4175: MS-Windows: runtime check for multi-line balloon is obsolete
Bram Moolenaar <Bram@vim.org>
parents: 27283
diff changeset
8396 (LPARAM)rect.right);
15277
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8397
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8398 // Limit ballooneval bounding rect to CursorPos neighbourhood.
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8399 pti->rect.left = pt.x - 3;
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8400 pti->rect.top = pt.y - 3;
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8401 pti->rect.right = pt.x + 3;
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8402 pti->rect.bottom = pt.y + 3;
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8403
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8404 SendMessageW(beval->balloon, TTM_ADDTOOLW, 0, (LPARAM)pti);
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8405 // Make tooltip appear sooner.
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8406 SendMessageW(beval->balloon, TTM_SETDELAYTIME, TTDT_INITIAL, 10);
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8407 // I've performed some tests and it seems the longest possible life time
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8408 // of tooltip is 30 seconds.
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8409 SendMessageW(beval->balloon, TTM_SETDELAYTIME, TTDT_AUTOPOP, 30000);
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8410 /*
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8411 * HACK: force tooltip to appear, because it'll not appear until
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8412 * first mouse move. D*mn M$
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8413 * Amazingly moving (2, 2) and then (-1, -1) the mouse doesn't move.
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8414 */
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8415 mouse_event(MOUSEEVENTF_MOVE, 2, 2, 0, 0);
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8416 mouse_event(MOUSEEVENTF_MOVE, (DWORD)-1, (DWORD)-1, 0, 0);
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8417 vim_free(pti);
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8418 }
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8419
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8420 static void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8421 delete_tooltip(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8422 {
7056
1ebd7608cfd9 commit https://github.com/vim/vim/commit/8e5f5b47c2198ffa4161c21a4140eaa9bed46f37
Christian Brabandt <cb@256bit.org>
parents: 7032
diff changeset
8423 PostMessage(beval->balloon, WM_CLOSE, 0, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8424 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8425
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8426 static VOID CALLBACK
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
8427 beval_timer_proc(
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
8428 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
8429 UINT uMsg UNUSED,
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
8430 UINT_PTR idEvent UNUSED,
10783
04eb70c77cf4 patch 8.0.0281: some files are still using ARGSUSED instead of UNUSED
Christian Brabandt <cb@256bit.org>
parents: 10440
diff changeset
8431 DWORD dwTime)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8432 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8433 POINT pt;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8434 RECT rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8435
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8436 if (cur_beval == NULL || cur_beval->showState == ShS_SHOWING || !p_beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8437 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8438
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8439 GetCursorPos(&pt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8440 if (WindowFromPoint(pt) != s_textArea)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8441 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8442
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8443 ScreenToClient(s_textArea, &pt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8444 GetClientRect(s_textArea, &rect);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8445 if (!PtInRect(&rect, pt))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8446 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8447
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
8448 if (last_user_activity > 0
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
8449 && (dwTime - last_user_activity) >= (DWORD)p_bdlay
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8450 && (cur_beval->showState != ShS_PENDING
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8451 || abs(cur_beval->x - pt.x) > 3
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8452 || abs(cur_beval->y - pt.y) > 3))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8453 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8454 // Pointer resting in one place long enough, it's time to show
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8455 // the tooltip.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8456 cur_beval->showState = ShS_PENDING;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8457 cur_beval->x = pt.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8458 cur_beval->y = pt.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8459
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8460 if (cur_beval->msgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8461 (*cur_beval->msgCB)(cur_beval, 0);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8462 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8463 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8464
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8465 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
8466 gui_mch_disable_beval_area(BalloonEval *beval UNUSED)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8467 {
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
8468 KillTimer(s_textArea, beval_timer_id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8469 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8470
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8471 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8472 gui_mch_enable_beval_area(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8473 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8474 if (beval == NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8475 return;
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
8476 beval_timer_id = SetTimer(s_textArea, 0, (UINT)(p_bdlay / 2),
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
8477 beval_timer_proc);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8478 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8479
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8480 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8481 gui_mch_post_balloon(BalloonEval *beval, char_u *mesg)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8482 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8483 POINT pt;
11129
f4ea50924c6d patch 8.0.0452: some macros are in lower case
Christian Brabandt <cb@256bit.org>
parents: 10783
diff changeset
8484
16600
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16596
diff changeset
8485 vim_free(beval->msg);
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16596
diff changeset
8486 beval->msg = mesg == NULL ? NULL : vim_strsave(mesg);
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16596
diff changeset
8487 if (beval->msg == NULL)
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16596
diff changeset
8488 {
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16596
diff changeset
8489 delete_tooltip(beval);
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16596
diff changeset
8490 beval->showState = ShS_NEUTRAL;
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16596
diff changeset
8491 return;
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16596
diff changeset
8492 }
ff3c99bd1038 patch 8.1.1303: not possible to hide a balloon
Bram Moolenaar <Bram@vim.org>
parents: 16596
diff changeset
8493
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8494 if (beval->showState == ShS_SHOWING)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8495 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8496 GetCursorPos(&pt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8497 ScreenToClient(s_textArea, &pt);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8498
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8499 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
8500 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8501 // cursor is still here
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8502 gui_mch_disable_beval_area(cur_beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8503 beval->showState = ShS_SHOWING;
8090
54cfe888c627 commit https://github.com/vim/vim/commit/418f81b5fa400ed59793384f2f3d9df45390f080
Christian Brabandt <cb@256bit.org>
parents: 7856
diff changeset
8504 make_tooltip(beval, (char *)mesg, pt);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8505 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8506 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8507
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8508 BalloonEval *
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8509 gui_mch_create_beval_area(
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8510 void *target UNUSED, // ignored, always use s_textArea
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8511 char_u *mesg,
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8512 void (*mesgCB)(BalloonEval *, int),
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 7807
diff changeset
8513 void *clientData)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8514 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8515 // partially stolen from gui_beval.c
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8516 BalloonEval *beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8517
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8518 if (mesg != NULL && mesgCB != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8519 {
26893
79c76ca2c53c patch 8.2.3975: error messages are spread out
Bram Moolenaar <Bram@vim.org>
parents: 26883
diff changeset
8520 iemsg(_(e_cannot_create_ballooneval_with_both_message_and_callback));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8521 return NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8522 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8523
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16768
diff changeset
8524 beval = ALLOC_CLEAR_ONE(BalloonEval);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8525 if (beval != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8526 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8527 beval->target = s_textArea;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8528
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8529 beval->showState = ShS_NEUTRAL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8530 beval->msg = mesg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8531 beval->msgCB = mesgCB;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8532 beval->clientData = clientData;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8533
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8534 InitCommonControls();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8535 cur_beval = beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8536
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8537 if (p_beval)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8538 gui_mch_enable_beval_area(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8539 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8540 return beval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8541 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8542
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8543 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
8544 Handle_WM_Notify(HWND hwnd UNUSED, LPNMHDR pnmh)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8545 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8546 if (pnmh->idFrom != ID_BEVAL_TOOLTIP) // it is not our tooltip
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8547 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8548
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8549 if (cur_beval != NULL)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8550 {
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8551 switch (pnmh->code)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8552 {
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8553 case TTN_SHOW:
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8554 break;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8555 case TTN_POP: // Before tooltip disappear
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8556 delete_tooltip(cur_beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8557 gui_mch_enable_beval_area(cur_beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8558
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8559 cur_beval->showState = ShS_NEUTRAL;
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8560 break;
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8561 case TTN_GETDISPINFO:
1481
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
8562 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8563 // if you get there then we have new common controls
27370
584f91cc2508 patch 8.2.4213: too much code for supporting old MSVC versions
Bram Moolenaar <Bram@vim.org>
parents: 27342
diff changeset
8564 NMTTDISPINFO *info = (NMTTDISPINFO *)pnmh;
1481
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
8565 info->lpszText = (LPSTR)info->lParam;
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
8566 info->uFlags |= TTF_DI_SETITEM;
0c61c201ba76 updated for version 7.1-196
vimboss
parents: 1376
diff changeset
8567 }
435
73f016dbb279 updated for version 7.0112
vimboss
parents: 419
diff changeset
8568 break;
15277
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8569 case TTN_GETDISPINFOW:
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8570 {
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8571 // if we get here then we have new common controls
27370
584f91cc2508 patch 8.2.4213: too much code for supporting old MSVC versions
Bram Moolenaar <Bram@vim.org>
parents: 27342
diff changeset
8572 NMTTDISPINFOW *info = (NMTTDISPINFOW *)pnmh;
15277
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8573 info->lpszText = (LPWSTR)info->lParam;
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8574 info->uFlags |= TTF_DI_SETITEM;
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8575 }
71b762af30c3 patch 8.1.0647: MS-Windows: balloon_show() does not handle wide characters
Bram Moolenaar <Bram@vim.org>
parents: 15034
diff changeset
8576 break;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8577 }
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 static void
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
8582 track_user_activity(UINT uMsg)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8583 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8584 if ((uMsg >= WM_MOUSEFIRST && uMsg <= WM_MOUSELAST)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8585 || (uMsg >= WM_KEYFIRST && uMsg <= WM_KEYLAST))
27525
27694b525305 patch 8.2.4290: MS-Windows: using type casts for timer IDs
Bram Moolenaar <Bram@vim.org>
parents: 27455
diff changeset
8586 last_user_activity = GetTickCount();
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_destroy_beval_area(BalloonEval *beval)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8591 {
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8592 # ifdef FEAT_VARTABS
15288
e3dfd25b0679 patch 8.1.0652: freeing memory for balloon eval too early
Bram Moolenaar <Bram@vim.org>
parents: 15277
diff changeset
8593 vim_free(beval->vts);
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8594 # endif
15288
e3dfd25b0679 patch 8.1.0652: freeing memory for balloon eval too early
Bram Moolenaar <Bram@vim.org>
parents: 15277
diff changeset
8595 vim_free(beval->tofree);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8596 vim_free(beval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8597 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 18773
diff changeset
8598 #endif // FEAT_BEVAL_GUI
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8599
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8600 #if defined(FEAT_NETBEANS_INTG) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8601 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8602 * We have multiple signs to draw at the same location. Draw the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8603 * multi-sign indicator (down-arrow) instead. This is the Win32 version.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8604 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8605 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8606 netbeans_draw_multisign_indicator(int row)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8607 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8608 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8609 int y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8610 int x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8611
2210
8c6a66e2b3cc Add :nbstart and :nbclose.
Bram Moolenaar <bram@vim.org>
parents: 2078
diff changeset
8612 if (!netbeans_active())
2311
ccda151dde4e Support completion for ":find". (Nazri Ramliy)
Bram Moolenaar <bram@vim.org>
parents: 2224
diff changeset
8613 return;
2210
8c6a66e2b3cc Add :nbstart and :nbclose.
Bram Moolenaar <bram@vim.org>
parents: 2078
diff changeset
8614
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8615 x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8616 y = TEXT_Y(row);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8617
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8618 # if defined(FEAT_DIRECTX)
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
8619 if (IS_ENABLE_DIRECTX())
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
8620 DWriteContext_Flush(s_dwc);
18773
38a3bef525e6 patch 8.1.2376: preprocessor indents are incorrect
Bram Moolenaar <Bram@vim.org>
parents: 18763
diff changeset
8621 # endif
12934
2ebc3df65ca2 patch 8.0.1343: MS-Windows: does not show colored emojis
Christian Brabandt <cb@256bit.org>
parents: 12924
diff changeset
8622
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8623 for (i = 0; i < gui.char_height - 3; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8624 SetPixel(s_hdc, x+2, y++, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8625
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8626 SetPixel(s_hdc, x+0, y, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8627 SetPixel(s_hdc, x+2, y, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8628 SetPixel(s_hdc, x+4, y++, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8629 SetPixel(s_hdc, x+1, y, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8630 SetPixel(s_hdc, x+2, y, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8631 SetPixel(s_hdc, x+3, y++, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8632 SetPixel(s_hdc, x+2, y, gui.currFgColor);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8633 }
7743
6069f43cea4e commit https://github.com/vim/vim/commit/e0874f8cbcddfcf9965a85ba35199964efb1d01a
Christian Brabandt <cb@256bit.org>
parents: 7560
diff changeset
8634 #endif
29432
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8635
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8636 #if defined(FEAT_EVAL) || defined(PROTO)
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8637 int
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8638 test_gui_w32_sendevent(dict_T *args)
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8639 {
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8640 char_u *event;
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8641 INPUT inputs[1];
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8642
29442
827d9f2b7a71 patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents: 29440
diff changeset
8643 event = dict_get_string(args, "event", TRUE);
29432
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8644 if (event == NULL)
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8645 return FALSE;
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8646
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8647 ZeroMemory(inputs, sizeof(inputs));
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8648
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8649 if (STRICMP(event, "keydown") == 0 || STRICMP(event, "keyup") == 0)
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8650 {
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8651 WORD vkCode;
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8652
29442
827d9f2b7a71 patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents: 29440
diff changeset
8653 vkCode = dict_get_number_def(args, "keycode", 0);
29432
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8654 if (vkCode <= 0 || vkCode >= 0xFF)
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8655 {
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8656 semsg(_(e_invalid_argument_nr), (long)vkCode);
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8657 return FALSE;
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8658 }
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8659
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8660 inputs[0].type = INPUT_KEYBOARD;
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8661 inputs[0].ki.wVk = vkCode;
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8662 if (STRICMP(event, "keyup") == 0)
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8663 inputs[0].ki.dwFlags = KEYEVENTF_KEYUP;
30144
17f72013adea patch 9.0.0408: GUI test sometimes fails on MS-Windows
Bram Moolenaar <Bram@vim.org>
parents: 29558
diff changeset
8664 (void)SetForegroundWindow(s_hwnd);
29432
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8665 SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8666 }
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8667 else
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8668 semsg(_(e_invalid_argument_str), event);
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8669
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8670 vim_free(event);
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8671
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8672 return TRUE;
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8673 }
339fe2968690 patch 9.0.0058: Win32: cannot test low level events
Bram Moolenaar <Bram@vim.org>
parents: 29310
diff changeset
8674 #endif