annotate src/gui_photon.c @ 20753:661eb972cb22

Update runtime files Commit: https://github.com/vim/vim/commit/acc224064033e5cea21ef7f1eefb356ca06ff11d Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 7 21:07:18 2020 +0200 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Sun, 07 Jun 2020 21:15:04 +0200
parents 2ef19eed524a
children fcccc29bd386
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: 9939
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 * Photon GUI support by Julian Kinraid
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 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 * Clipboard support is in os_qnx.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 * PhAttach() is called in os_qnx.c:qnx_init()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 #include "vim.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
16 // cproto fails on missing include files
3927
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3076
diff changeset
17 #ifndef PROTO
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3076
diff changeset
18 # ifdef FEAT_TOOLBAR
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3076
diff changeset
19 # include <photon/PxImage.h>
e6d8b44065bc updated for version 7.3.719
Bram Moolenaar <bram@vim.org>
parents: 3076
diff changeset
20 # endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 #if !defined(__QNX__)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
24 // Used when generating prototypes.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 # define PgColor_t int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 # define PhEvent_t int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 # define PhPoint_t int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 # define PtWidget_t int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 # define Pg_BLACK 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 # define PtCallbackF_t int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 # define PtCallbackInfo_t int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 # define PhTile_t int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 # define PtWidget_t int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 # define PhImage_t int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 #define ARRAY_LENGTH(a) (sizeof(a) / sizeof(a[0]))
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
38 #define RGB(r, g, b) PgRGB(r, g, b)
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
39
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
40 #define EVENT_BUFFER_SIZE sizeof(PhEvent_t) + 1000
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
42 // Some defines for gui_mch_mousehide()
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 #define MOUSE_HIDE TRUE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 #define MOUSE_SHOW FALSE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
46 // Optional support for using a PtPanelGroup widget, needs work
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 #undef USE_PANEL_GROUP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 #ifdef USE_PANEL_GROUP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 static char *empty_title = " ";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 static char **panel_titles = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 static ushort_t num_panels = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 static short pg_margin_left, pg_margin_right, pg_margin_top, pg_margin_bottom;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
56 #define GUI_PH_MARGIN 4 // Size of the bevel
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 #define GUI_PH_MOUSE_TYPE Ph_CURSOR_INSERT
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 static PgColor_t gui_ph_mouse_color = Pg_BLACK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 static PhPoint_t gui_ph_raw_offset;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
62 static PtWidget_t *gui_ph_timer_cursor; // handle cursor blinking
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
63 static PtWidget_t *gui_ph_timer_timeout; // used in gui_mch_wait_for_chars
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
64 static short is_timeout; // Has the timeout occurred?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 * This is set inside the mouse callback for a right mouse
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 * button click, and used for the popup menus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 static PhPoint_t abs_mouse;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
72 // Try and avoid redraws while a resize is in progress
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 static int is_ignore_draw = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
75 // Used for converting to/from utf-8 and other charsets
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 static struct PxTransCtrl *charset_translate;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 * Cursor blink functions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 * This is a simple state machine:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 * BLINK_NONE not blinking at all
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 * BLINK_OFF blinking, cursor is not shown
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 * BLINK_ON blinking, cursor is shown
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 static enum {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 BLINK_NONE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 BLINK_OFF,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 BLINK_ON
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 } blink_state = BLINK_NONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 static long_u blink_waittime = 700;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 static long_u blink_ontime = 400;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 static long_u blink_offtime = 250;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 static struct
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 int key_sym;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 char_u vim_code0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 char_u vim_code1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 } special_keys[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 {Pk_Up, 'k', 'u'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 {Pk_Down, 'k', 'd'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 {Pk_Left, 'k', 'l'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 {Pk_Right, 'k', 'r'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 {Pk_F1, 'k', '1'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 {Pk_F2, 'k', '2'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 {Pk_F3, 'k', '3'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 {Pk_F4, 'k', '4'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 {Pk_F5, 'k', '5'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 {Pk_F6, 'k', '6'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 {Pk_F7, 'k', '7'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 {Pk_F8, 'k', '8'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 {Pk_F9, 'k', '9'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 {Pk_F10, 'k', ';'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 {Pk_F11, 'F', '1'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 {Pk_F12, 'F', '2'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 {Pk_F13, 'F', '3'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 {Pk_F14, 'F', '4'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 {Pk_F15, 'F', '5'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 {Pk_F16, 'F', '6'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 {Pk_F17, 'F', '7'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 {Pk_F18, 'F', '8'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 {Pk_F19, 'F', '9'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 {Pk_F20, 'F', 'A'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 {Pk_F21, 'F', 'B'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 {Pk_F22, 'F', 'C'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 {Pk_F23, 'F', 'D'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 {Pk_F24, 'F', 'E'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 {Pk_F25, 'F', 'F'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 {Pk_F26, 'F', 'G'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 {Pk_F27, 'F', 'H'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 {Pk_F28, 'F', 'I'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 {Pk_F29, 'F', 'J'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 {Pk_F30, 'F', 'K'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 {Pk_F31, 'F', 'L'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 {Pk_F32, 'F', 'M'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 {Pk_F33, 'F', 'N'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 {Pk_F34, 'F', 'O'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 {Pk_F35, 'F', 'P'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 {Pk_Help, '%', '1'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 {Pk_BackSpace, 'k', 'b'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 {Pk_Insert, 'k', 'I'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 {Pk_Delete, 'k', 'D'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 {Pk_Home, 'k', 'h'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152 {Pk_End, '@', '7'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 {Pk_Prior, 'k', 'P'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 {Pk_Next, 'k', 'N'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 {Pk_Print, '%', '9'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157 {Pk_KP_Add, 'K', '6'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 {Pk_KP_Subtract,'K', '7'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159 {Pk_KP_Divide, 'K', '8'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 {Pk_KP_Multiply,'K', '9'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
161 {Pk_KP_Enter, 'K', 'A'},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
162
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
163 {Pk_KP_0, KS_EXTRA, KE_KINS}, // Insert
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
164 {Pk_KP_Decimal, KS_EXTRA, KE_KDEL}, // Delete
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
165
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
166 {Pk_KP_4, 'k', 'l'}, // Left
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
167 {Pk_KP_6, 'k', 'r'}, // Right
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
168 {Pk_KP_8, 'k', 'u'}, // Up
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
169 {Pk_KP_2, 'k', 'd'}, // Down
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
170
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
171 {Pk_KP_7, 'K', '1'}, // Home
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
172 {Pk_KP_1, 'K', '4'}, // End
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
173
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
174 {Pk_KP_9, 'K', '3'}, // Page Up
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
175 {Pk_KP_3, 'K', '5'}, // Page Down
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
176
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
177 {Pk_KP_5, '&', '8'}, // Undo
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
178
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
179 // Keys that we want to be able to use any modifier with:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
180 {Pk_Return, CAR, NUL},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
181 {Pk_space, ' ', NUL},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
182 {Pk_Tab, TAB, NUL},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
183 {Pk_Escape, ESC, NUL},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
184 {NL, NL, NUL},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
185 {CAR, CAR, NUL},
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
186
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
187 // End of list marker:
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
188 {0, 0, 0}
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
189 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
190
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
191
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
192 ////////////////////////////////////////////////////////////////////////////
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
193
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
194 static PtCallbackF_t gui_ph_handle_timer_cursor;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
195 static PtCallbackF_t gui_ph_handle_timer_timeout;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
196
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
197 static PtCallbackF_t gui_ph_handle_window_cb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
198
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
199 static PtCallbackF_t gui_ph_handle_scrollbar;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
200 static PtCallbackF_t gui_ph_handle_keyboard;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
201 static PtCallbackF_t gui_ph_handle_mouse;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
202 static PtCallbackF_t gui_ph_handle_pulldown_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
203 static PtCallbackF_t gui_ph_handle_menu;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
204 static PtCallbackF_t gui_ph_handle_focus; // focus change of text area
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
205
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
206 static PtCallbackF_t gui_ph_handle_menu_resize;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
207
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
208 // When a menu is unrealized, give focus back to vimTextArea
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
209 static PtCallbackF_t gui_ph_handle_menu_unrealized;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
211 #ifdef USE_PANEL_GROUP
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
212 static void gui_ph_get_panelgroup_margins(short*, short*, short*, short*);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
213 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
214
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
215 static void gui_ph_draw_start(void);
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
216 static void gui_ph_draw_end(void);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
217
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
218 // Set the text for the balloon
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
219 static PtWidget_t * gui_ph_show_tooltip(PtWidget_t *window,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
220 PtWidget_t *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
221 int position,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
222 char *text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
223 char *font,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
224 PgColor_t fill_color,
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
225 PgColor_t text_color);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
226
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
227 ////////////////////////////////////////////////////////////////////////////
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
228
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
229 static PtWidget_t * gui_ph_show_tooltip(PtWidget_t *window,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
230 PtWidget_t *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
231 int position,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
232 char *text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
233 char *font,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
234 PgColor_t fill_color,
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
235 PgColor_t text_color)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
236 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
237 PtArg_t arg;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
238 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
239 char_u *tooltip;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
240
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
241 PtSetArg(&arg, Pt_ARG_POINTER, &menu, 0);
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
242 PtGetResources(widget, 1, &arg);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
243
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
244 // Override the text and position
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
245
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
246 tooltip = text;
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
247 if (menu != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
248 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
249 int index = MENU_INDEX_TIP;
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
250 if (menu->strings[ index ] != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
251 tooltip = menu->strings[ index ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
252 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
253
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
254 return PtInflateBalloon(
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
255 window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
256 widget,
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
257 // Don't put the balloon at the bottom,
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
258 // it gets drawn over by gfx done in the PtRaw
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
259 Pt_BALLOON_TOP,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
260 tooltip,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
261 font,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
262 fill_color,
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
263 text_color);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
264 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
265
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
266 static void
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
267 gui_ph_resize_container(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
268 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
269 PhArea_t area;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
270
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
271 PtWidgetArea(gui.vimWindow, &area);
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
272 PtWidgetPos (gui.vimContainer, &area.pos);
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
273
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
274 PtSetResource(gui.vimContainer, Pt_ARG_AREA, &area, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
275 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
276
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
277 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
278 gui_ph_handle_menu_resize(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
279 PtWidget_t *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
280 void *other,
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
281 PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
282 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
283 PtContainerCallback_t *sizes = info->cbdata;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
284 PtWidget_t *container;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
285 PhPoint_t below_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
286 int_u height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
287
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
288 height = sizes->new_dim.h;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
289
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
290 // Because vim treats the toolbar and menubar separately,
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
291 // and here they're lumped together into a PtToolbarGroup,
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
292 // we only need either menu_height or toolbar_height set at once
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
293 if (gui.menu_is_active)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
294 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
295 gui.menu_height = height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
296 gui.toolbar_height = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
297 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
298 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
299 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
300 gui.toolbar_height = height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
301 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
302
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
303 below_menu.x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
304 below_menu.y = height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
305
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
306 #ifdef USE_PANEL_GROUP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
307 container = gui.vimPanelGroup;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
308 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
309 container = gui.vimContainer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
310 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
311
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
312 PtSetResource(container, Pt_ARG_POS, &below_menu, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
313
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
314 gui_ph_resize_container();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
315
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
316 #ifdef USE_PANEL_GROUP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
317 gui_ph_get_panelgroup_margins(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
318 &pg_margin_top, &pg_margin_bottom,
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
319 &pg_margin_left, &pg_margin_right);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
320 #endif
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
321 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
322 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
323
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
324 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
325 * Pt_ARG_TIMER_REPEAT isn't used because the on & off times
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
326 * are different
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
327 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
328 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
329 gui_ph_handle_timer_cursor(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
330 PtWidget_t *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
331 void *data,
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
332 PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
333 {
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
334 if (blink_state == BLINK_ON)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
335 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
336 gui_undraw_cursor();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
337 blink_state = BLINK_OFF;
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
338 PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL,
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
339 blink_offtime, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
340 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
341 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
342 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
343 gui_update_cursor(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
344 blink_state = BLINK_ON;
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
345 PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL,
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
346 blink_ontime, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
347 }
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
348 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
349 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
350
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
351 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
352 gui_ph_handle_timer_timeout(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
353 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
354 is_timeout = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
355
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
356 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
357 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
358
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
359 static int
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
360 gui_ph_handle_window_cb(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
361 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
362 PhWindowEvent_t *we = info->cbdata;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
363 ushort_t *width, *height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
364
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
365 switch (we->event_f) {
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
366 case Ph_WM_CLOSE:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
367 gui_shell_closed();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
368 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
369
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
370 case Ph_WM_FOCUS:
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
371 // Just in case it's hidden and needs to be shown
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
372 gui_mch_mousehide(MOUSE_SHOW);
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
373
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
374 if (we->event_state == Ph_WM_EVSTATE_FOCUS)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
375 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
376 gui_focus_change(TRUE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
377 gui_mch_start_blink();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
378 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
379 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
380 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
381 gui_focus_change(FALSE);
13152
f4c3a7f410f4 patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
382 gui_mch_stop_blink(TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
383 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
384 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
385
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
386 case Ph_WM_RESIZE:
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
387 PtGetResource(gui.vimWindow, Pt_ARG_WIDTH, &width, 0);
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
388 PtGetResource(gui.vimWindow, Pt_ARG_HEIGHT, &height, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
389 #ifdef USE_PANEL_GROUP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
390 width -= (pg_margin_left + pg_margin_right);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
391 height -= (pg_margin_top + pg_margin_bottom);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
392 #endif
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
393 gui_resize_shell(*width, *height);
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
394 gui_set_shellsize(FALSE, FALSE, RESIZE_BOTH);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
395 is_ignore_draw = FALSE;
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
396 PtEndFlux(gui.vimContainer);
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
397 PtContainerRelease(gui.vimContainer);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
398 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
399
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
400 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
401 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
402 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
403
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
404 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
405 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
406
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
407 static int
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
408 gui_ph_handle_scrollbar(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
409 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
410 PtScrollbarCallback_t *scroll;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
411 scrollbar_T *sb;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
412 int value, dragging = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
413
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
414 scroll = info->cbdata;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
415
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
416 sb = (scrollbar_T *) data;
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
417 if (sb != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
418 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
419 value = scroll->position;
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
420 switch (scroll->action)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
421 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
422 case Pt_SCROLL_DRAGGED:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
423 dragging = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
424 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
425
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
426 case Pt_SCROLL_SET:
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
427 // FIXME: return straight away here?
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
428 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
429 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
430 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
431
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
432 gui_drag_scrollbar(sb, value, dragging);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
433 }
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
434 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
435 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
436
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
437 static int
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
438 gui_ph_handle_keyboard(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
439 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
440 PhKeyEvent_t *key;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
441 unsigned char string[6];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
442 int len, i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
443 int ch, modifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
444
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
445 key = PhGetData(info->event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
446
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
447 ch = modifiers = len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
448
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
449 if (p_mh)
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
450 gui_mch_mousehide(MOUSE_HIDE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
451
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
452 // We're a good lil photon program, aren't we? yes we are, yeess wee arrr
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
453 if (key->key_flags & Pk_KF_Compose)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
454 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
455
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
456 if ((key->key_flags & Pk_KF_Cap_Valid) &&
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
457 PkIsKeyDown(key->key_flags))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
458 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
459 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
460 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
461 * Only show the menu if the Alt key is down, and the Shift & Ctrl
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
462 * keys aren't down, as well as the other conditions
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
463 */
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
464 if (((key->key_mods & Pk_KM_Alt) &&
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
465 !(key->key_mods & Pk_KM_Shift) &&
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
466 !(key->key_mods & Pk_KM_Ctrl)) &&
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
467 gui.menu_is_active &&
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
468 (*p_wak == 'y' ||
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
469 (*p_wak == 'm' &&
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
470 gui_is_menu_shortcut(key->key_cap))))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
471 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
472 // Fallthrough and let photon look for the hotkey
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
473 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
474 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
475 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
476
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
477 for (i = 0; special_keys[i].key_sym != 0; i++)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
478 {
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
479 if (special_keys[i].key_sym == key->key_cap)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
480 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
481 len = 0;
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
482 if (special_keys[i].vim_code1 == NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
483 ch = special_keys[i].vim_code0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
484 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
485 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
486 // Detect if a keypad number key has been pressed
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
487 // and change the key if Num Lock is on
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
488 if (key->key_cap >= Pk_KP_Enter && key->key_cap <= Pk_KP_9
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
489 && (key->key_mods & Pk_KM_Num_Lock))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
490 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
491 // FIXME: For now, just map the key to a ascii value
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
492 // (see <photon/PkKeyDef.h>)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
493 ch = key->key_cap - 0xf080;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
494 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
495 else
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
496 ch = TO_SPECIAL(special_keys[i].vim_code0,
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
497 special_keys[i].vim_code1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
498 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
499 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
500 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
501 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
502
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
503 if (key->key_mods & Pk_KM_Ctrl)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
504 modifiers |= MOD_MASK_CTRL;
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
505 if (key->key_mods & Pk_KM_Alt)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
506 modifiers |= MOD_MASK_ALT;
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
507 if (key->key_mods & Pk_KM_Shift)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
508 modifiers |= MOD_MASK_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
509
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
510 // Is this not a special key?
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
511 if (special_keys[i].key_sym == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
512 {
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
513 ch = PhTo8859_1(key);
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
514 if (ch == -1 || (enc_utf8 && ch > 127))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
515 {
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
516 len = PhKeyToMb(string, key);
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
517 if (len > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
518 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
519 static char buf[6];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
520 int src_taken, dst_made;
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
521 if (enc_utf8 != TRUE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
522 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
523 PxTranslateFromUTF(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
524 charset_translate,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
525 string,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
526 len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
527 &src_taken,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
528 buf,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
529 6,
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
530 &dst_made);
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
531
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
532 add_to_input_buf(buf, dst_made);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
533 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
534 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
535 {
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
536 add_to_input_buf(string, len);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
537 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
538
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
539 return Pt_CONSUME;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
540 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
541 len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
542 ch = key->key_cap;
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
543 if (ch < 0xff)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
544 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
545 // FIXME: is this the right thing to do?
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
546 if (modifiers & MOD_MASK_CTRL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
547 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
548 modifiers &= ~MOD_MASK_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
549
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
550 if ((ch >= 'a' && ch <= 'z') ||
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
551 ch == '[' ||
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
552 ch == ']' ||
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
553 ch == '\\')
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
554 ch = Ctrl_chr(ch);
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
555 else if (ch == '2')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
556 ch = NUL;
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
557 else if (ch == '6')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
558 ch = 0x1e;
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
559 else if (ch == '-')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
560 ch = 0x1f;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
561 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
562 modifiers |= MOD_MASK_CTRL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
563 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
564
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
565 if (modifiers & MOD_MASK_ALT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
566 {
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
567 ch = Meta(ch);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
568 modifiers &= ~MOD_MASK_ALT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
569 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
570 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
571 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
572 {
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
573 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
574 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
575 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
576 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
577 modifiers &= ~MOD_MASK_SHIFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
578 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
579
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
580 ch = simplify_key(ch, &modifiers);
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
581 if (modifiers)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
582 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
583 string[ len++ ] = CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
584 string[ len++ ] = KS_MODIFIER;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
585 string[ len++ ] = modifiers;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
586 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
587
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
588 if (IS_SPECIAL(ch))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
589 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
590 string[ len++ ] = CSI;
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
591 string[ len++ ] = K_SECOND(ch);
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
592 string[ len++ ] = K_THIRD(ch);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
593 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
594 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
595 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
596 string[ len++ ] = ch;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
597 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
598
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
599 if (len == 1 && ((ch == Ctrl_C && ctrl_c_interrupts)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
600 || ch == intr_char))
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
601 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
602 trash_input_buf();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
603 got_int = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
604 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
605
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
606 if (len == 1 && string[0] == CSI)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
607 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
608 // Turn CSI into K_CSI.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
609 string[ len++ ] = KS_EXTRA;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
610 string[ len++ ] = KE_CSI;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
611 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
612
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
613 if (len > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
614 {
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
615 add_to_input_buf(string, len);
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
616 return Pt_CONSUME;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
617 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
618 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
619
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
620 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
621 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
622
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
623 static int
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
624 gui_ph_handle_mouse(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
625 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
626 PhPointerEvent_t *pointer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
627 PhRect_t *pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
628 int button = 0, repeated_click, modifiers = 0x0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
629 short mouse_x, mouse_y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
630
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
631 pointer = PhGetData(info->event);
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
632 pos = PhGetRects(info->event);
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
633
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
634 gui_mch_mousehide(MOUSE_SHOW);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
635
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
636 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
637 * Coordinates need to be relative to the base window,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
638 * not relative to the vimTextArea widget
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
639 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
640 mouse_x = pos->ul.x + gui.border_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
641 mouse_y = pos->ul.y + gui.border_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
642
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
643 if (info->event->type == Ph_EV_PTR_MOTION_NOBUTTON)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
644 {
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
645 gui_mouse_moved(mouse_x, mouse_y);
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
646 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
647 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
648
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
649 if (pointer->key_mods & Pk_KM_Shift)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
650 modifiers |= MOUSE_SHIFT;
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
651 if (pointer->key_mods & Pk_KM_Ctrl)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
652 modifiers |= MOUSE_CTRL;
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
653 if (pointer->key_mods & Pk_KM_Alt)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
654 modifiers |= MOUSE_ALT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
655
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
656 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
657 * FIXME More than one button may be involved, but for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
658 * now just deal with one
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
659 */
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
660 if (pointer->buttons & Ph_BUTTON_SELECT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
661 button = MOUSE_LEFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
662
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
663 if (pointer->buttons & Ph_BUTTON_MENU)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
664 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
665 button = MOUSE_RIGHT;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
666 // Need the absolute coordinates for the popup menu
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
667 abs_mouse.x = pointer->pos.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
668 abs_mouse.y = pointer->pos.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
669 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
670
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
671 if (pointer->buttons & Ph_BUTTON_ADJUST)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
672 button = MOUSE_MIDDLE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
673
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
674 // Catch a real release (not phantom or other releases
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
675 if (info->event->type == Ph_EV_BUT_RELEASE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
676 button = MOUSE_RELEASE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
677
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
678 if (info->event->type & Ph_EV_PTR_MOTION_BUTTON)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
679 button = MOUSE_DRAG;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
680
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
681 #if 0
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
682 // Vim doesn't use button repeats
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
683 if (info->event->type & Ph_EV_BUT_REPEAT)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
684 button = MOUSE_DRAG;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
685 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
686
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
687 // Don't do anything if it is one of the phantom mouse release events
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
688 if ((button != MOUSE_RELEASE) ||
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
689 (info->event->subtype == Ph_EV_RELEASE_REAL))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
690 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
691 repeated_click = (pointer->click_count >= 2) ? TRUE : FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
692
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
693 gui_send_mouse_event(button , mouse_x, mouse_y, repeated_click, modifiers);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
694 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
695
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
696 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
697 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
698
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
699 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
700 * Handle a focus change of the PtRaw widget
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
701 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
702 static int
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
703 gui_ph_handle_focus(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
704 {
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
705 if (info->reason == Pt_CB_LOST_FOCUS)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
706 {
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
707 PtRemoveEventHandler(gui.vimTextArea, Ph_EV_PTR_MOTION_NOBUTTON,
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
708 gui_ph_handle_mouse, NULL);
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
709
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
710 gui_mch_mousehide(MOUSE_SHOW);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
711 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
712 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
713 {
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
714 PtAddEventHandler(gui.vimTextArea, Ph_EV_PTR_MOTION_NOBUTTON,
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
715 gui_ph_handle_mouse, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
716 }
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
717 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
718 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
719
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
720 static void
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
721 gui_ph_handle_raw_draw(PtWidget_t *widget, PhTile_t *damage)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
722 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
723 PhRect_t *r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
724 PhPoint_t offset;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
725 PhPoint_t translation;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
726
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
727 if (is_ignore_draw == TRUE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
728 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
729
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
730 PtSuperClassDraw(PtBasic, widget, damage);
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
731 PgGetTranslation(&translation);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
732 PgClearTranslation();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
733
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
734 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
735 /*
1214
a91a2e0c4108 updated for version 7.1b
vimboss
parents: 834
diff changeset
736 * This causes some weird problems, with drawing being done from
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
737 * within this raw drawing function (rather than just simple clearing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
738 * and text drawing done by gui_redraw)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
739 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
740 * The main problem is when PhBlit is used, and the cursor appearing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
741 * in places where it shouldn't
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
742 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
743 out_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
744 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
745
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
746 PtWidgetOffset(widget, &offset);
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
747 PhTranslatePoint(&offset, PtWidgetPos(gui.vimTextArea, NULL));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
748
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
749 #if 1
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
750 // Redraw individual damage regions
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
751 if (damage->next != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
752 damage = damage->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
753
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
754 while (damage != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
755 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
756 r = &damage->rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
757 gui_redraw(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
758 r->ul.x - offset.x, r->ul.y - offset.y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
759 r->lr.x - r->ul.x + 1,
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
760 r->lr.y - r->ul.y + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
761 damage = damage->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
762 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
763 #else
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
764 // Redraw the rectangle that covers all the damaged regions
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
765 r = &damage->rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
766 gui_redraw(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
767 r->ul.x - offset.x, r->ul.y - offset.y,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
768 r->lr.x - r->ul.x + 1,
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
769 r->lr.y - r->ul.y + 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
770 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
771
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
772 PgSetTranslation(&translation, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
773 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
774
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
775 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
776 gui_ph_handle_pulldown_menu(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
777 PtWidget_t *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
778 void *data,
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
779 PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
780 {
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
781 if (data != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
782 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
783 vimmenu_T *menu = (vimmenu_T *) data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
784
3054
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
785 PtPositionMenu(menu->submenu_id, NULL);
eb4972982bfe updated for version 7.3.299
Bram Moolenaar <bram@vim.org>
parents: 3052
diff changeset
786 PtRealizeWidget(menu->submenu_id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
787 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
788
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
789 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
790 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
791
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
792 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
793 * This is used for pulldown/popup menus and also toolbar buttons
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
794 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
795 static int
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
796 gui_ph_handle_menu(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
797 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
798 if (data != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
799 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
800 vimmenu_T *menu = (vimmenu_T *) data;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
801 gui_menu_cb(menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
802 }
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
803 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
804 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
805
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
806 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
807 * Stop focus from disappearing into the menubar...
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
808 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
809 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
810 gui_ph_handle_menu_unrealized(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
811 PtWidget_t *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
812 void *data,
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
813 PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
814 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
815 PtGiveFocus(gui.vimTextArea, NULL);
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
816 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
817 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
818
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
819 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
820 gui_ph_handle_window_open(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
821 PtWidget_t *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
822 void *data,
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
823 PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
824 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
825 gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH);
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
826 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
827 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
828
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
829 ////////////////////////////////////////////////////////////////////////////
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
830
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
831 #define DRAW_START gui_ph_draw_start()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
832 #define DRAW_END gui_ph_draw_end()
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
833
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
834 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
835 * TODO: Set a clipping rect?
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
836 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
837 static void
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
838 gui_ph_draw_start(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
839 {
1922
e65e50609469 updated for version 7.2-219
vimboss
parents: 1214
diff changeset
840 PhGC_t *gc;
e65e50609469 updated for version 7.2-219
vimboss
parents: 1214
diff changeset
841
e65e50609469 updated for version 7.2-219
vimboss
parents: 1214
diff changeset
842 gc = PgGetGC();
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
843 PgSetRegion(PtWidgetRid(PtFindDisjoint(gui.vimTextArea)));
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
844 PgClearClippingsCx(gc);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
845 PgClearTranslationCx(gc);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
846
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
847 PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
848 PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL));
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
849
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
850 PgSetTranslation(&gui_ph_raw_offset, Pg_RELATIVE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
851 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
852
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
853 static void
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
854 gui_ph_draw_end(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
855 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
856 gui_ph_raw_offset.x = -gui_ph_raw_offset.x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
857 gui_ph_raw_offset.y = -gui_ph_raw_offset.y;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
858 PgSetTranslation(&gui_ph_raw_offset, Pg_RELATIVE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
859 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
860
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
861 #ifdef USE_PANEL_GROUP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
862 static vimmenu_T *
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
863 gui_ph_find_buffer_item(char_u *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
864 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
865 vimmenu_T *top_level = root_menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
866 vimmenu_T *items = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
867
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
868 while (top_level != NULL &&
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
869 (STRCMP(top_level->dname, "Buffers") != 0))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
870 top_level = top_level->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
871
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
872 if (top_level != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
873 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
874 items = top_level->children;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
875
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
876 while (items != NULL &&
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
877 (STRCMP(items->dname, name) != 0))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
878 items = items->next;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
879 }
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
880 return items;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
881 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
882
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
883 static void
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
884 gui_ph_pg_set_buffer_num(int_u buf_num)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
885 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
886 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
887 char search[16];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
888 char *mark;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
889
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
890 if (gui.vimTextArea == NULL || buf_num == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
891 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
892
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
893 search[0] = '(';
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
894 ultoa(buf_num, &search[1], 10);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
895 STRCAT(search, ")");
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
896
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
897 for (i = 0; i < num_panels; i++)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
898 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
899 // find the last "(" in the panel title and see if the buffer
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
900 // number in the title matches the one we're looking for
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
901 mark = STRRCHR(panel_titles[ i ], '(');
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
902 if (mark != NULL && STRCMP(mark, search) == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
903 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
904 PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_CURRENT_INDEX,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
905 i, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
906 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
907 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
908 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
909
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
910 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
911 gui_ph_handle_pg_change(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
912 PtWidget_t *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
913 void *data,
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
914 PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
915 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
916 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
917 PtPanelGroupCallback_t *panel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
918
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
919 if (info->event != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
920 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
921 panel = info->cbdata;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
922 if (panel->new_panel != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
923 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
924 menu = gui_ph_find_buffer_item(panel->new_panel);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
925 if (menu)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
926 gui_menu_cb(menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
927 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
928 }
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
929 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
930 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
931
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
932 static void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
933 gui_ph_get_panelgroup_margins(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
934 short *top,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
935 short *bottom,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
936 short *left,
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
937 short *right)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
938 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
939 unsigned short abs_raw_x, abs_raw_y, abs_panel_x, abs_panel_y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
940 const unsigned short *margin_top, *margin_bottom;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
941 const unsigned short *margin_left, *margin_right;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
942
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
943 PtGetAbsPosition(gui.vimTextArea, &abs_raw_x, &abs_raw_y);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
944 PtGetAbsPosition(gui.vimPanelGroup, &abs_panel_x, &abs_panel_y);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
945
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
946 PtGetResource(gui.vimPanelGroup, Pt_ARG_MARGIN_RIGHT, &margin_right, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
947 PtGetResource(gui.vimPanelGroup, Pt_ARG_MARGIN_BOTTOM, &margin_bottom, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
948
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
949 abs_raw_x -= abs_panel_x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
950 abs_raw_y -= abs_panel_y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
951
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
952 *top = abs_raw_y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
953 *bottom = *margin_bottom;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
954
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
955 *left = abs_raw_x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
956 *right = *margin_right;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
957 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
958
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
959 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
960 * Used for the tabs for PtPanelGroup
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
961 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
962 static int
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
963 gui_ph_is_buffer_item(vimmenu_T *menu, vimmenu_T *parent)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
964 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
965 char *mark;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
966
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
967 if (STRCMP(parent->dname, "Buffers") == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
968 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
969 // Look for '(' digits ')'
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
970 mark = vim_strchr(menu->dname, '(');
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
971 if (mark != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
972 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
973 mark++;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
974 while (isdigit(*mark))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
975 mark++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
976
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
977 if (*mark == ')')
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
978 return TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
979 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
980 }
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
981 return FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
982 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
983
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
984 static void
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
985 gui_ph_pg_add_buffer(char *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
986 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
987 char **new_titles = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
988
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
989 new_titles = ALLOC_MULT(char *, (num_panels + 1));
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
990 if (new_titles != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
991 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
992 if (num_panels > 0)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
993 memcpy(new_titles, panel_titles, num_panels * sizeof(char **));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
994
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
995 new_titles[ num_panels++ ] = name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
996
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
997 PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
998 num_panels);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
999
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1000 vim_free(panel_titles);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1001 panel_titles = new_titles;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1002 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1003 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1004
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1005 static void
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1006 gui_ph_pg_remove_buffer(char *name)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1007 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1008 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1009 char **new_titles = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1010
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1011 // If there is only 1 panel, we just use the temporary place holder
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1012 if (num_panels > 1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1013 {
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1014 new_titles = ALLOC_MULT(char *, num_panels - 1);
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1015 if (new_titles != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1016 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1017 char **s = new_titles;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1018 // Copy all the titles except the one we're removing
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1019 for (i = 0; i < num_panels; i++)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1020 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1021 if (STRCMP(panel_titles[ i ], name) != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1022 *s++ = panel_titles[ i ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1023 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1024 num_panels--;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1025
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1026 PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, new_titles,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1027 num_panels);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1028
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1029 vim_free(panel_titles);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1030 panel_titles = new_titles;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1031 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1032 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1033 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1034 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1035 num_panels--;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1036 PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, &empty_title,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1037 1);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1038
13244
ac42c4b11dbc patch 8.0.1496: clearing a pointer takes two lines
Christian Brabandt <cb@256bit.org>
parents: 13152
diff changeset
1039 VIM_CLEAR(panel_titles);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1040 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1041 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1042
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1043 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1044 * When a buffer item is deleted from the buffer menu
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1045 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1046 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1047 gui_ph_handle_buffer_remove(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1048 PtWidget_t *widget,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1049 void *data,
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1050 PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1051 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1052 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1053
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1054 if (data != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1055 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1056 menu = (vimmenu_T *) data;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1057 gui_ph_pg_remove_buffer(menu->dname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1058 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1059
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1060 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1061 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1062 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1063
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1064 static int
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1065 gui_ph_pane_resize(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1066 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1067 if (PtWidgetIsRealized(widget))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1068 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1069 is_ignore_draw = TRUE;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1070 PtStartFlux(gui.vimContainer);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1071 PtContainerHold(gui.vimContainer);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1072 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1073
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1074 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1075 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1076
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1077 ////////////////////////////////////////////////////////////////////////////
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1078
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1079 void
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1080 gui_ph_encoding_changed(int new_encoding)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1081 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1082 // Default encoding is latin1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1083 char *charset = "latin1";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1084 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1085
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1086 struct {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1087 int encoding;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1088 char *name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1089 } charsets[] = {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1090 { DBCS_JPN, "SHIFT_JIS" },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1091 { DBCS_KOR, "csEUCKR" },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1092 { DBCS_CHT, "big5" },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1093 { DBCS_CHS, "gb" }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1094 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1095
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1096 for (i = 0; i < ARRAY_LENGTH(charsets); i++)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1097 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1098 if (new_encoding == charsets[ i ].encoding)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1099 charset = charsets[ i ].name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1100 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1101
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1102 charset_translate = PxTranslateSet(charset_translate, charset);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1103 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1104
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1105 ////////////////////////////////////////////////////////////////////////////
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1106
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1107 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 4352
diff changeset
1108 gui_mch_prepare(int *argc, char **argv)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1109 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1110 PtInit(NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1111 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1113 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1114 gui_mch_init(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1115 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1116 PtArg_t args[10];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1117 int flags = 0, n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1118
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1119 PhDim_t window_size = {100, 100}; // Arbitrary values
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1120 PhPoint_t pos = {0, 0};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1121
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1122 gui.event_buffer = alloc(EVENT_BUFFER_SIZE);
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1123 if (gui.event_buffer == NULL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1124 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1125
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1126 // Get a translation so we can convert from ISO Latin-1 to UTF
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1127 charset_translate = PxTranslateSet(NULL, "latin1");
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1128
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1129 // The +2 is for the 1 pixel dark line on each side
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1130 gui.border_offset = gui.border_width = GUI_PH_MARGIN + 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1131
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1132 // Handle close events ourselves
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1133 PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, Ph_WM_CLOSE);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1134 PtSetArg(&args[ n++ ], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1135 Ph_WM_CLOSE | Ph_WM_RESIZE | Ph_WM_FOCUS);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1136 PtSetArg(&args[ n++ ], Pt_ARG_DIM, &window_size, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1137 gui.vimWindow = PtCreateWidget(PtWindow, NULL, n, args);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1138 if (gui.vimWindow == NULL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1139 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1140
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1141 PtAddCallback(gui.vimWindow, Pt_CB_WINDOW, gui_ph_handle_window_cb, NULL);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1142 PtAddCallback(gui.vimWindow, Pt_CB_WINDOW_OPENING,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1143 gui_ph_handle_window_open, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1145 n = 0;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1146 PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_ALL, Pt_IS_ANCHORED);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1147 PtSetArg(&args[ n++ ], Pt_ARG_DIM, &window_size, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1148 PtSetArg(&args[ n++ ], Pt_ARG_POS, &pos, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1150 #ifdef USE_PANEL_GROUP
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1151 // Put in a temporary place holder title
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1152 PtSetArg(&args[ n++ ], Pt_ARG_PG_PANEL_TITLES, &empty_title, 1);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1153
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1154 gui.vimPanelGroup = PtCreateWidget(PtPanelGroup, gui.vimWindow, n, args);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1155 if (gui.vimPanelGroup == NULL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1156 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1157
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1158 PtAddCallback(gui.vimPanelGroup, Pt_CB_PG_PANEL_SWITCHING,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1159 gui_ph_handle_pg_change, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1160 #else
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1161 // Turn off all edge decorations
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1162 PtSetArg(&args[ n++ ], Pt_ARG_BASIC_FLAGS, Pt_FALSE, Pt_ALL);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1163 PtSetArg(&args[ n++ ], Pt_ARG_BEVEL_WIDTH, 0, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1164 PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_WIDTH, 0, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1165 PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 0, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1166 PtSetArg(&args[ n++ ], Pt_ARG_CONTAINER_FLAGS, Pt_TRUE, Pt_AUTO_EXTENT);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1167
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1168 gui.vimContainer = PtCreateWidget(PtPane, gui.vimWindow, n, args);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1169 if (gui.vimContainer == NULL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1170 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1171
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1172 PtAddCallback(gui.vimContainer, Pt_CB_RESIZE, gui_ph_pane_resize, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1173 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1174
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1175 // Size for the text area is set in gui_mch_set_text_area_pos
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1176 n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1177
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1178 PtSetArg(&args[ n++ ], Pt_ARG_RAW_DRAW_F, gui_ph_handle_raw_draw, 1);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1179 PtSetArg(&args[ n++ ], Pt_ARG_BEVEL_WIDTH, GUI_PH_MARGIN, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1180 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1181 * Using focus render also causes the whole widget to be redrawn
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1182 * whenever it changes focus, which is very annoying :p
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1183 */
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1184 PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1185 Pt_GETS_FOCUS | Pt_HIGHLIGHTED);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1186 #ifndef FEAT_MOUSESHAPE
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1187 PtSetArg(&args[ n++ ], Pt_ARG_CURSOR_TYPE, GUI_PH_MOUSE_TYPE, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1188 PtSetArg(&args[ n++ ], Pt_ARG_CURSOR_COLOR, gui_ph_mouse_color, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1189 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1190
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1191 gui.vimTextArea = PtCreateWidget(PtRaw, Pt_DFLT_PARENT, n, args);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1192 if (gui.vimTextArea == NULL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1193 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1194
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1195 // TODO: use PtAddEventHandlers instead?
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1196 // Not using Ph_EV_BUT_REPEAT because vim wouldn't use it anyway
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1197 PtAddEventHandler(gui.vimTextArea,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1198 Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_PTR_MOTION_BUTTON,
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1199 gui_ph_handle_mouse, NULL);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1200 PtAddEventHandler(gui.vimTextArea, Ph_EV_KEY,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1201 gui_ph_handle_keyboard, NULL);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1202 PtAddCallback(gui.vimTextArea, Pt_CB_GOT_FOCUS,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1203 gui_ph_handle_focus, NULL);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1204 PtAddCallback(gui.vimTextArea, Pt_CB_LOST_FOCUS,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1205 gui_ph_handle_focus, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1206
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1207 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1208 * Now that the text area widget has been created, set up the colours,
19195
2ef19eed524a patch 8.2.0156: various typos in source files and tests
Bram Moolenaar <Bram@vim.org>
parents: 18788
diff changeset
1209 * which will call PtSetResource from gui_mch_new_colors
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1210 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1211
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1212 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1213 * Create the two timers, not as accurate as using the kernel timer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1214 * functions, but good enough
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1215 */
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1216 gui_ph_timer_cursor = PtCreateWidget(PtTimer, gui.vimWindow, 0, NULL);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1217 if (gui_ph_timer_cursor == NULL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1218 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1219
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1220 gui_ph_timer_timeout = PtCreateWidget(PtTimer, gui.vimWindow, 0, NULL);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1221 if (gui_ph_timer_timeout == NULL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1222 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1223
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1224 PtAddCallback(gui_ph_timer_cursor, Pt_CB_TIMER_ACTIVATE,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1225 gui_ph_handle_timer_cursor, NULL);
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1226 PtAddCallback(gui_ph_timer_timeout, Pt_CB_TIMER_ACTIVATE,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1227 gui_ph_handle_timer_timeout, NULL);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1228
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1229 #ifdef FEAT_MENU
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1230 n = 0;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1231 PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1232 PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, Pt_ANCHOR_LEFT_RIGHT,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1233 Pt_IS_ANCHORED);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1234 gui.vimToolBarGroup = PtCreateWidget(PtToolbarGroup, gui.vimWindow,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1235 n, args);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1236 if (gui.vimToolBarGroup == NULL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1237 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1238
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1239 PtAddCallback(gui.vimToolBarGroup, Pt_CB_RESIZE,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1240 gui_ph_handle_menu_resize, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1241
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1242 n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1243 flags = 0;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1244 PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1245 if (! vim_strchr(p_go, GO_MENUS))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1246 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1247 flags |= Pt_DELAY_REALIZE;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1248 PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_TRUE, flags);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1249 }
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1250 gui.vimMenuBar = PtCreateWidget(PtMenuBar, gui.vimToolBarGroup, n, args);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1251 if (gui.vimMenuBar == NULL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1252 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1253
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1254 # ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1255 n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1256
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1257 PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1258 Pt_ANCHOR_LEFT_RIGHT |Pt_TOP_ANCHORED_TOP, Pt_IS_ANCHORED);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1259 PtSetArg(&args[ n++ ], Pt_ARG_RESIZE_FLAGS, Pt_TRUE,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1260 Pt_RESIZE_Y_AS_REQUIRED);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1261 PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, window_size.w, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1262
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1263 flags = Pt_GETS_FOCUS;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1264 if (! vim_strchr(p_go, GO_TOOLBAR))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1265 flags |= Pt_DELAY_REALIZE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1266
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1267 PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, flags);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1268
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1269 gui.vimToolBar = PtCreateWidget(PtToolbar, gui.vimToolBarGroup, n, args);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1270 if (gui.vimToolBar == NULL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1271 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1272
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1273 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1274 * Size for the toolbar is fetched in gui_mch_show_toolbar, after
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1275 * the buttons have been added and the toolbar has resized it's height
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1276 * for the buttons to fit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1277 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1278 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1280 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1281
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1282 return OK;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1283 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1284
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1285 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1286 gui_mch_init_check(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1287 {
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1288 return (is_photon_available == TRUE) ? OK : FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1289 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1290
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1291 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1292 gui_mch_open(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1293 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1294 gui.norm_pixel = Pg_BLACK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1295 gui.back_pixel = Pg_WHITE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1296
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1297 set_normal_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1298
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1299 gui_check_colors();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1300 gui.def_norm_pixel = gui.norm_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1301 gui.def_back_pixel = gui.back_pixel;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1302
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1303 highlight_gui_started();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1304
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1305 if (gui_win_x != -1 && gui_win_y != -1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1306 gui_mch_set_winpos(gui_win_x, gui_win_y);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1307
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1308 return (PtRealizeWidget(gui.vimWindow) == 0) ? OK : FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1309 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1310
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1311 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1312 gui_mch_exit(int rc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1313 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1314 PtDestroyWidget(gui.vimWindow);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1315
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1316 PxTranslateSet(charset_translate, NULL);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1317
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1318 vim_free(gui.event_buffer);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1319
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1320 #ifdef USE_PANEL_GROUPS
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1321 vim_free(panel_titles);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1322 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1323 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1324
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1325 ////////////////////////////////////////////////////////////////////////////
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1326 // events
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1327
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1328 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1329 * When no events are available, photon will call this function, working is
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1330 * set to FALSE, and the gui_mch_update loop will exit.
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1331 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1332 static int
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1333 exit_gui_mch_update(void *data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1334 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1335 *(int *)data = FALSE;
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1336 return Pt_END;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1337 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1338
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1339 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1340 gui_mch_update(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1341 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1342 int working = TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1343
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1344 PtAppAddWorkProc(NULL, exit_gui_mch_update, &working);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1345 while ((working == TRUE) && !vim_is_input_buf_full())
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1346 PtProcessEvent();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1347 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1348
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1349 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1350 gui_mch_wait_for_chars(int wtime)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1351 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1352 is_timeout = FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1353
15665
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
1354 if (wtime >= 0)
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
1355 PtSetResource(gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL,
31367ce5aac7 patch 8.1.0840: getchar(0) never returns a character in the terminal
Bram Moolenaar <Bram@vim.org>
parents: 15595
diff changeset
1356 wtime == 0 ? 1 : wtime, 0);
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1357
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1358 while (1)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1359 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1360 PtProcessEvent();
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1361 if (input_available())
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1362 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1363 PtSetResource(gui_ph_timer_timeout, Pt_ARG_TIMER_INITIAL, 0, 0);
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1364 return OK;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1365 }
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1366 else if (is_timeout == TRUE)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1367 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1368 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1369 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1370
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1371 #if defined(FEAT_BROWSE) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1372 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1373 * Put up a file requester.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1374 * Returns the selected name in allocated memory, or NULL for Cancel.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1375 * saving, select file to write
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1376 * title title for the window
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1377 * default_name default name (well duh!)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1378 * ext not used (extension added)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1379 * initdir initial directory, NULL for current dir
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1380 * filter not used (file name filter)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1381 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1382 char_u *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1383 gui_mch_browse(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1384 int saving,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1385 char_u *title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1386 char_u *default_name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1387 char_u *ext,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1388 char_u *initdir,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1389 char_u *filter)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1390 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1391 PtFileSelectionInfo_t file;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1392 int flags;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1393 char_u *default_path;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1394 char_u *open_text = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1395
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1396 flags = 0;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1397 memset(&file, 0, sizeof(file));
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1398
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1399 default_path = alloc(MAXPATHL + 1 + NAME_MAX + 1);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1400 if (default_path != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1401 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1402 if (saving == TRUE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1403 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1404 // Don't need Pt_FSR_CONFIRM_EXISTING, vim will ask anyway
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1405 flags |= Pt_FSR_NO_FCHECK;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1406 open_text = "&Save";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1407 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1408
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1409 // combine the directory and filename into a single path
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1410 if (initdir == NULL || *initdir == NUL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1411 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1412 mch_dirname(default_path, MAXPATHL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1413 initdir = default_path;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1414 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1415 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1416 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1417 STRCPY(default_path, initdir);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1418 initdir = default_path;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1419 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1420
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1421 if (default_name != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1422 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1423 if (default_path[ STRLEN(default_path) - 1 ] != '/')
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1424 STRCAT(default_path, "/");
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1425
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1426 STRCAT(default_path, default_name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1427 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1428
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1429 // TODO: add a filter?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1430 PtFileSelection(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1431 gui.vimWindow,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1432 NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1433 title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1434 default_path,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1435 NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1436 open_text,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1437 NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1438 NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1439 &file,
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1440 flags);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1441
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1442 vim_free(default_path);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1443
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1444 if (file.ret == Pt_FSDIALOG_BTN1)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1445 return vim_strsave(file.path);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1446 }
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1447 return NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1448 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1449 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1450
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1451 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1452 static PtWidget_t *gui_ph_dialog_text = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1453
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1454 static int
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1455 gui_ph_dialog_close(int button, void *data)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1456 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1457 PtModalCtrl_t *modal_ctrl = data;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1458 char_u *dialog_text, *vim_text;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1459
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1460 if (gui_ph_dialog_text != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1461 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1462 PtGetResource(gui_ph_dialog_text, Pt_ARG_TEXT_STRING, &dialog_text, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1463 PtGetResource(gui_ph_dialog_text, Pt_ARG_POINTER, &vim_text, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1464 STRNCPY(vim_text, dialog_text, IOSIZE - 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1465 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1466
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1467 PtModalUnblock(modal_ctrl, (void *) button);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1468
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1469 return Pt_TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1470 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1471
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1472 static int
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1473 gui_ph_dialog_text_enter(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1474 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1475 if (info->reason_subtype == Pt_EDIT_ACTIVATE)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1476 gui_ph_dialog_close(1, data);
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1477 return Pt_CONTINUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1478 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1479
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1480 static int
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1481 gui_ph_dialog_esc(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1482 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1483 PhKeyEvent_t *key;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1484
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1485 key = PhGetData(info->event);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1486 if ((key->key_flags & Pk_KF_Cap_Valid) && (key->key_cap == Pk_Escape))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1487 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1488 gui_ph_dialog_close(0, data);
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1489 return Pt_CONSUME;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1490 }
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1491 return Pt_PROCESS;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1492 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1493
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1494 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1495 gui_mch_dialog(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1496 int type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1497 char_u *title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1498 char_u *message,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1499 char_u *buttons,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1500 int default_button,
2684
951641b8784d updated for version 7.3.102
Bram Moolenaar <bram@vim.org>
parents: 1922
diff changeset
1501 char_u *textfield,
951641b8784d updated for version 7.3.102
Bram Moolenaar <bram@vim.org>
parents: 1922
diff changeset
1502 int ex_cmd)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1503 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1504 char_u *str;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1505 char_u **button_array;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1506 char_u *buttons_copy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1507
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1508 int button_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1509 int i, len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1510 int dialog_result = -1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1511
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1512 // FIXME: the vertical option in guioptions is blatantly ignored
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1513 // FIXME: so is the type
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1514
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1515 button_count = len = i = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1516
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1517 if (buttons == NULL || *buttons == NUL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1518 return -1;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1519
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1520 // There is one less separator than buttons, so bump up the button count
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1521 button_count = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1522
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1523 // Count string length and number of separators
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1524 for (str = buttons; *str; str++)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1525 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1526 len++;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1527 if (*str == DLG_BUTTON_SEP)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1528 button_count++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1529 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1530
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1531 if (title == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1532 title = "Vim";
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1533
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1534 buttons_copy = alloc(len + 1);
16825
ce04ebdf26b8 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts
Bram Moolenaar <Bram@vim.org>
parents: 16162
diff changeset
1535 button_array = ALLOC_MULT(char_u *, button_count);
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1536 if (buttons_copy != NULL && button_array != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1537 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1538 STRCPY(buttons_copy, buttons);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1539
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1540 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1541 * Convert DLG_BUTTON_SEP into NUL's and fill in
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1542 * button_array with the pointer to each NUL terminated string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1543 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1544 str = buttons_copy;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1545 for (i = 0; i < button_count; i++)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1546 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1547 button_array[ i ] = str;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1548 for (; *str; str++)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1549 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1550 if (*str == DLG_BUTTON_SEP)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1551 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1552 *str++ = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1553 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1554 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1555 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1556 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1557 #ifndef FEAT_GUI_TEXTDIALOG
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1558 dialog_result = PtAlert(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1559 gui.vimWindow, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1560 title,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1561 NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1562 message, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1563 button_count, (const char **) button_array, NULL,
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1564 default_button, 0, Pt_MODAL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1565 #else
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1566 // Writing the dialog ourselves lets us add extra features, like
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1567 // trapping the escape key and returning 0 to vim
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1568 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1569 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1570 PtArg_t args[5];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1571 PtWidget_t *dialog, *pane;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1572 PtModalCtrl_t modal_ctrl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1573 PtDialogInfo_t di;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1574
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1575 memset(&di, 0, sizeof(di));
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1576 memset(&modal_ctrl, 0, sizeof(modal_ctrl));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1577
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1578 n = 0;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1579 PtSetArg(&args[n++], Pt_ARG_GROUP_ROWS_COLS, 0, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1580 PtSetArg(&args[n++], Pt_ARG_WIDTH, 350, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1581 PtSetArg(&args[n++], Pt_ARG_GROUP_ORIENTATION,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1582 Pt_GROUP_VERTICAL, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1583 PtSetArg(&args[n++], Pt_ARG_GROUP_FLAGS,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1584 Pt_TRUE, Pt_GROUP_NO_KEYS | Pt_GROUP_STRETCH_HORIZONTAL);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1585 PtSetArg(&args[n++], Pt_ARG_CONTAINER_FLAGS, Pt_FALSE, Pt_TRUE);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1586 pane = PtCreateWidget(PtGroup, NULL, n, args);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1587
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1588 n = 0;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1589 PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, message, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1590 PtCreateWidget(PtLabel, pane, n, args);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1591
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1592 if (textfield != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1593 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1594 n = 0;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1595 PtSetArg(&args[n++], Pt_ARG_MAX_LENGTH, IOSIZE - 1, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1596 PtSetArg(&args[n++], Pt_ARG_TEXT_STRING, textfield, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1597 PtSetArg(&args[n++], Pt_ARG_POINTER, textfield, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1598 gui_ph_dialog_text = PtCreateWidget(PtText, pane, n, args);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1599 PtAddCallback(gui_ph_dialog_text, Pt_CB_ACTIVATE,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1600 gui_ph_dialog_text_enter, &modal_ctrl);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1601 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1602
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1603 di.parent = gui.vimWindow;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1604 di.pane = pane;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1605 di.title = title;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1606 di.buttons = (const char **) button_array;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1607 di.nbtns = button_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1608 di.def_btn = default_button;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1609 // This is just to give the dialog the close button.
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1610 // We check for the Escape key ourselves and return 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1611 di.esc_btn = button_count;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1612 di.callback = gui_ph_dialog_close;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1613 di.data = &modal_ctrl;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1614
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1615 dialog = PtCreateDialog(&di);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1616 PtAddFilterCallback(dialog, Ph_EV_KEY,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1617 gui_ph_dialog_esc, &modal_ctrl);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1618
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1619 if (gui_ph_dialog_text != NULL)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1620 PtGiveFocus(gui_ph_dialog_text, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1621
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1622 // Open dialog, block the vim window and wait for the dialog to close
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1623 PtRealizeWidget(dialog);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1624 PtMakeModal(dialog, Ph_CURSOR_NOINPUT, Ph_CURSOR_DEFAULT_COLOR);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1625 dialog_result = (int) PtModalBlock(&modal_ctrl, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1626
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1627 PtDestroyWidget(dialog);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1628 gui_ph_dialog_text = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1629 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1630 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1631 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1632
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1633 vim_free(button_array);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1634 vim_free(buttons_copy);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1635
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1636 return dialog_result;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1637 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1638 #endif
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1639 ////////////////////////////////////////////////////////////////////////////
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1640 // window size/position/state
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1641
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1642 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1643 gui_mch_get_winpos(int *x, int *y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1644 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1645 PhPoint_t *pos;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1646
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1647 pos = PtWidgetPos(gui.vimWindow, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1648
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1649 *x = pos->x;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1650 *y = pos->y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1651
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
1652 return OK;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1653 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1654
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1655 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1656 gui_mch_set_winpos(int x, int y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1657 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1658 PhPoint_t pos = { x, y };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1659
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1660 PtSetResource(gui.vimWindow, Pt_ARG_POS, &pos, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1661 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1662
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1663 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1664 gui_mch_set_shellsize(int width, int height,
812
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 444
diff changeset
1665 int min_width, int min_height, int base_width, int base_height,
68c15f2c7d3f updated for version 7.0c01
vimboss
parents: 444
diff changeset
1666 int direction)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1667 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1668 PhDim_t window_size = { width, height };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1669 PhDim_t min_size = { min_width, min_height };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1670
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1671 #ifdef USE_PANEL_GROUP
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1672 window_size.w += pg_margin_left + pg_margin_right;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1673 window_size.h += pg_margin_top + pg_margin_bottom;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1674 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1675
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1676 PtSetResource(gui.vimWindow, Pt_ARG_MINIMUM_DIM, &min_size, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1677 PtSetResource(gui.vimWindow, Pt_ARG_DIM, &window_size, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1678
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1679 if (! PtWidgetIsRealized(gui.vimWindow))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1680 gui_ph_resize_container();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1681 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1682
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1683 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1684 * Return the amount of screen space that hasn't been allocated (such as
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1685 * by the shelf).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1686 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1687 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1688 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1689 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1690 PhRect_t console;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1691
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1692 PhWindowQueryVisible(Ph_QUERY_WORKSPACE, 0,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1693 PhInputGroup(NULL), &console);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1694
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1695 *screen_w = console.lr.x - console.ul.x + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1696 *screen_h = console.lr.y - console.ul.y + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1697 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1698
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1699 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1700 gui_mch_iconify(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1701 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1702 PhWindowEvent_t event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1703
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1704 memset(&event, 0, sizeof (event));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1705 event.event_f = Ph_WM_HIDE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1706 event.event_state = Ph_WM_EVSTATE_HIDE;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1707 event.rid = PtWidgetRid(gui.vimWindow);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1708 PtForwardWindowEvent(&event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1709 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1710
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1711 #if defined(FEAT_EVAL) || defined(PROTO)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1712 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1713 * Bring the Vim window to the foreground.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1714 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1715 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 4352
diff changeset
1716 gui_mch_set_foreground(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1717 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1718 PhWindowEvent_t event;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1719
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1720 memset(&event, 0, sizeof (event));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1721 event.event_f = Ph_WM_TOFRONT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1722 event.event_state = Ph_WM_EVSTATE_FFRONT;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1723 event.rid = PtWidgetRid(gui.vimWindow);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1724 PtForwardWindowEvent(&event);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1725 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1726 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1727
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1728 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1729 gui_mch_settitle(char_u *title, char_u *icon)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1730 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1731 #ifdef USE_PANEL_GROUP
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1732 gui_ph_pg_set_buffer_num(curwin->w_buffer->b_fnum);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1733 #endif
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1734 PtSetResource(gui.vimWindow, Pt_ARG_WINDOW_TITLE, title, 0);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1735 // Not sure what to do with the icon text, set balloon text somehow?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1736 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1737
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1738 ////////////////////////////////////////////////////////////////////////////
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1739 // Scrollbar
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1740
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1741 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1742 gui_mch_set_scrollbar_thumb(scrollbar_T *sb, int val, int size, int max)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1743 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1744 int n = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1745 PtArg_t args[3];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1746
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1747 PtSetArg(&args[ n++ ], Pt_ARG_MAXIMUM, max, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1748 PtSetArg(&args[ n++ ], Pt_ARG_SLIDER_SIZE, size, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1749 PtSetArg(&args[ n++ ], Pt_ARG_GAUGE_VALUE, val, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1750 PtSetResources(sb->id, n, args);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1751 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1752
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1753 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1754 gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1755 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1756 PhArea_t area = {{ x, y }, { w, h }};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1757
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1758 PtSetResource(sb->id, Pt_ARG_AREA, &area, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1759 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1760
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1761 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1762 gui_mch_create_scrollbar(scrollbar_T *sb, int orient)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1763 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1764 int n = 0;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1765 // int anchor_flags = 0;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1766 PtArg_t args[4];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1767
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1768 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1769 * Stop the scrollbar from being realized when the parent
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1770 * is realized, so it can be explicitly realized by vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1771 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1772 * Also, don't let the scrollbar get focus
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1773 */
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1774 PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_DELAY_REALIZE,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1775 Pt_DELAY_REALIZE | Pt_GETS_FOCUS);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1776 PtSetArg(&args[ n++ ], Pt_ARG_SCROLLBAR_FLAGS, Pt_SCROLLBAR_SHOW_ARROWS, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1777 #if 0
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1778 // Don't need this anchoring for the scrollbars
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1779 if (orient == SBAR_HORIZ)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1780 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1781 anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM |
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1782 Pt_LEFT_ANCHORED_LEFT | Pt_RIGHT_ANCHORED_RIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1783 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1784 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1785 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1786 anchor_flags = Pt_BOTTOM_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_TOP;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1787 if (sb->wp != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1788 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1789 if (sb == &sb->wp->w_scrollbars[ SBAR_LEFT ])
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1790 anchor_flags |= Pt_LEFT_ANCHORED_LEFT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1791 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1792 anchor_flags |= Pt_RIGHT_ANCHORED_RIGHT;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1793 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1794 }
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1795 PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS, anchor_flags, Pt_IS_ANCHORED);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1796 #endif
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1797 PtSetArg(&args[ n++ ], Pt_ARG_ORIENTATION,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1798 (orient == SBAR_HORIZ) ? Pt_HORIZONTAL : Pt_VERTICAL, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1799 #ifdef USE_PANEL_GROUP
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1800 sb->id = PtCreateWidget(PtScrollbar, gui.vimPanelGroup, n, args);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1801 #else
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1802 sb->id = PtCreateWidget(PtScrollbar, gui.vimContainer, n, args);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1803 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1804
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1805 PtAddCallback(sb->id, Pt_CB_SCROLLBAR_MOVE, gui_ph_handle_scrollbar, sb);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1806 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1807
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1808 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1809 gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1810 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1811 if (flag != 0)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1812 PtRealizeWidget(sb->id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1813 else
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1814 PtUnrealizeWidget(sb->id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1815 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1816
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1817 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1818 gui_mch_destroy_scrollbar(scrollbar_T *sb)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1819 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1820 PtDestroyWidget(sb->id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1821 sb->id = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1822 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1823
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1824 ////////////////////////////////////////////////////////////////////////////
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1825 // Mouse functions
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1826
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1827 #if defined(FEAT_MOUSESHAPE) || defined(PROTO)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1828 // The last set mouse pointer shape is remembered, to be used when it goes
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1829 // from hidden to not hidden.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1830 static int last_shape = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1831
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1832 // Table for shape IDs. 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: 16825
diff changeset
1833 // misc2.c!
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1834 static int mshape_ids[] =
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1835 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1836 Ph_CURSOR_POINTER, // arrow
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1837 Ph_CURSOR_NONE, // blank
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1838 Ph_CURSOR_INSERT, // beam
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1839 Ph_CURSOR_DRAG_VERTICAL, // updown
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1840 Ph_CURSOR_DRAG_VERTICAL, // udsizing
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1841 Ph_CURSOR_DRAG_HORIZONTAL, // leftright
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1842 Ph_CURSOR_DRAG_HORIZONTAL, // lrsizing
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1843 Ph_CURSOR_WAIT, // busy
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1844 Ph_CURSOR_DONT, // no
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1845 Ph_CURSOR_CROSSHAIR, // crosshair
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1846 Ph_CURSOR_FINGER, // hand1
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1847 Ph_CURSOR_FINGER, // hand2
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1848 Ph_CURSOR_FINGER, // pencil
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1849 Ph_CURSOR_QUESTION_POINT, // question
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1850 Ph_CURSOR_POINTER, // right-arrow
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1851 Ph_CURSOR_POINTER, // up-arrow
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1852 Ph_CURSOR_POINTER // last one
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1853 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1854
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1855 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 4352
diff changeset
1856 mch_set_mouse_shape(int shape)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1857 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1858 int id;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1859
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1860 if (!gui.in_use)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1861 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1862
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1863 if (shape == MSHAPE_HIDE || gui.pointer_hidden)
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1864 PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1865 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1866 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1867 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1868 if (shape >= MSHAPE_NUMBERED)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1869 id = Ph_CURSOR_POINTER;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1870 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1871 id = mshape_ids[shape];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1872
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1873 PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE, id, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1874 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1875 if (shape != MSHAPE_HIDE)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1876 last_shape = shape;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1877 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1878 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1879
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1880 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1881 gui_mch_mousehide(int hide)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1882 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1883 if (gui.pointer_hidden != hide)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1884 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1885 gui.pointer_hidden = hide;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1886 #ifdef FEAT_MOUSESHAPE
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1887 if (hide)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1888 PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1889 Ph_CURSOR_NONE, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1890 else
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1891 mch_set_mouse_shape(last_shape);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1892 #else
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1893 PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_TYPE,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1894 (hide == MOUSE_SHOW) ? GUI_PH_MOUSE_TYPE : Ph_CURSOR_NONE,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1895 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1896 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1897 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1898 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1899
95
a2081e6febb8 updated for version 7.0037
vimboss
parents: 87
diff changeset
1900 void
87
014ba200db86 updated for version 7.0035
vimboss
parents: 44
diff changeset
1901 gui_mch_getmouse(int *x, int *y)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1902 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1903 PhCursorInfo_t info;
87
014ba200db86 updated for version 7.0035
vimboss
parents: 44
diff changeset
1904 short ix, iy;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1905
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1906 // FIXME: does this return the correct position,
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1907 // with respect to the border?
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1908 PhQueryCursor(PhInputGroup(NULL), &info);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1909 PtGetAbsPosition(gui.vimTextArea , &ix, &iy);
87
014ba200db86 updated for version 7.0035
vimboss
parents: 44
diff changeset
1910
014ba200db86 updated for version 7.0035
vimboss
parents: 44
diff changeset
1911 *x = info.pos.x - ix;
014ba200db86 updated for version 7.0035
vimboss
parents: 44
diff changeset
1912 *y = info.pos.y - iy;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1913 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1914
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1915 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1916 gui_mch_setmouse(int x, int y)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1917 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1918 short abs_x, abs_y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1919
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1920 PtGetAbsPosition(gui.vimTextArea, &abs_x, &abs_y);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1921 // Add the border offset?
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1922 PhMoveCursorAbs(PhInputGroup(NULL), abs_x + x, abs_y + y);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1923 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1924
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1925 ////////////////////////////////////////////////////////////////////////////
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1926 // Colours
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1927
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1928 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1929 * Return the RGB value of a pixel as a long.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1930 */
9939
ccb6461b82df commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents: 9428
diff changeset
1931 guicolor_T
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1932 gui_mch_get_rgb(guicolor_T pixel)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1933 {
9939
ccb6461b82df commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents: 9428
diff changeset
1934 return (guicolor_T)(PgRGB(PgRedValue(pixel),
ccb6461b82df commit https://github.com/vim/vim/commit/1b58cdd160c2e0ada0f638679a2aa27e4665fc48
Christian Brabandt <cb@256bit.org>
parents: 9428
diff changeset
1935 PgGreenValue(pixel), PgBlueValue(pixel)));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1936 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1937
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1938 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1939 gui_mch_new_colors(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1940 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1941 #if 0 // Don't bother changing the cursor colour
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1942 short color_diff;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1943
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1944 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1945 * If there isn't enough difference between the background colour and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1946 * the mouse pointer colour then change the mouse pointer colour
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1947 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1948 color_diff = gui_get_lightness(gui_ph_mouse_color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1949 - gui_get_lightness(gui.back_pixel);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1950
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1951 if (abs(color_diff) < 64)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1952 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1953 short r, g, b;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
1954 // not a great algorithm...
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1955 r = PgRedValue(gui_ph_mouse_color) ^ 255;
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1956 g = PgGreenValue(gui_ph_mouse_color) ^ 255;
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1957 b = PgBlueValue(gui_ph_mouse_color) ^ 255;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1958
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1959 #ifndef FEAT_MOUSESHAPE
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1960 gui_ph_mouse_color = PgRGB(r, g, b);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1961 PtSetResource(gui.vimTextArea, Pt_ARG_CURSOR_COLOR,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1962 gui_ph_mouse_color, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1963 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1964 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1965 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1966
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1967 PtSetResource(gui.vimTextArea, Pt_ARG_FILL_COLOR, gui.back_pixel, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1968 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1969
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1970 /*
1214
a91a2e0c4108 updated for version 7.1b
vimboss
parents: 834
diff changeset
1971 * This should be split out into a separate file,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1972 * every port does basically the same thing.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1973 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1974 * This is the gui_w32.c version (i think..)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1975 * Return INVALCOLOR when failed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1976 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1977
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1978 guicolor_T
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1979 gui_mch_get_color(char_u *name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1980 {
9013
22c29a515b53 commit https://github.com/vim/vim/commit/ab3022196ea4f1496e79b8ee85996e31c45d02f1
Christian Brabandt <cb@256bit.org>
parents: 7823
diff changeset
1981 return gui_get_color_cmn(name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1982 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1983
11745
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1984 guicolor_T
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1985 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: 10042
diff changeset
1986 {
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1987 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: 10042
diff changeset
1988 }
5a5709918a98 patch 8.0.0755: terminal window does not have colors in the GUI
Christian Brabandt <cb@256bit.org>
parents: 10042
diff changeset
1989
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1990 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1991 gui_mch_set_fg_color(guicolor_T color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1992 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1993 PgSetTextColor(color);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1994 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1995
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1996 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1997 gui_mch_set_bg_color(guicolor_T color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1998 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
1999 PgSetFillColor(color);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2000 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2001
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2002 void
205
d292c40ca788 updated for version 7.0060
vimboss
parents: 95
diff changeset
2003 gui_mch_set_sp_color(guicolor_T color)
d292c40ca788 updated for version 7.0060
vimboss
parents: 95
diff changeset
2004 {
d292c40ca788 updated for version 7.0060
vimboss
parents: 95
diff changeset
2005 }
d292c40ca788 updated for version 7.0060
vimboss
parents: 95
diff changeset
2006
d292c40ca788 updated for version 7.0060
vimboss
parents: 95
diff changeset
2007 void
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2008 gui_mch_invert_rectangle(int row, int col, int nr, int nc)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2009 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2010 PhRect_t rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2011
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2012 rect.ul.x = FILL_X(col);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2013 rect.ul.y = FILL_Y(row);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2014
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2015 // FIXME: This has an off by one pixel problem
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2016 rect.lr.x = rect.ul.x + nc * gui.char_width;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2017 rect.lr.y = rect.ul.y + nr * gui.char_height;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2018 if (nc > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2019 rect.lr.x -= 1;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2020 if (nr > 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2021 rect.lr.y -= 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2022
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2023 DRAW_START;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2024 PgSetDrawMode(Pg_DrawModeDSTINVERT);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2025 PgDrawRect(&rect, Pg_DRAW_FILL);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2026 PgSetDrawMode(Pg_DrawModeSRCCOPY);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2027 DRAW_END;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2028 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2029
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2030 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2031 gui_mch_clear_block(int row1, int col1, int row2, int col2)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2032 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2033 PhRect_t block = {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2034 { FILL_X(col1), FILL_Y(row1) },
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2035 { FILL_X(col2 + 1) - 1, FILL_Y(row2 + 1) - 1}
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2036 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2037
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2038 DRAW_START;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2039 gui_mch_set_bg_color(gui.back_pixel);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2040 PgDrawRect(&block, Pg_DRAW_FILL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2041 DRAW_END;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2042 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2043
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2044 void
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 4352
diff changeset
2045 gui_mch_clear_all(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2046 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2047 PhRect_t text_rect = {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2048 { gui.border_width, gui.border_width },
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2049 { Columns * gui.char_width + gui.border_width - 1 ,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2050 Rows * gui.char_height + gui.border_width - 1 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2051 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2052
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2053 if (is_ignore_draw == TRUE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2054 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2055
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2056 DRAW_START;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2057 gui_mch_set_bg_color(gui.back_pixel);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2058 PgDrawRect(&text_rect, Pg_DRAW_FILL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2059 DRAW_END;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2060 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2061
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2062 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2063 gui_mch_delete_lines(int row, int num_lines)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2064 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2065 PhRect_t rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2066 PhPoint_t delta;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2067
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2068 rect.ul.x = FILL_X(gui.scroll_region_left);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2069 rect.ul.y = FILL_Y(row + num_lines);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2070
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2071 rect.lr.x = FILL_X(gui.scroll_region_right + 1) - 1;
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2072 rect.lr.y = FILL_Y(gui.scroll_region_bot + 1) - 1;
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2073
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2074 PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2075 PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL));
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2076 PhTranslateRect(&rect, &gui_ph_raw_offset);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2077
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2078 delta.x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2079 delta.y = -num_lines * gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2080
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2081 PgFlush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2082
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2083 PhBlit(PtWidgetRid(PtFindDisjoint(gui.vimTextArea)), &rect, &delta);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2084
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2085 gui_clear_block(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2086 gui.scroll_region_bot - num_lines + 1,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2087 gui.scroll_region_left,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2088 gui.scroll_region_bot,
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2089 gui.scroll_region_right);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2090 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2091
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2092 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2093 gui_mch_insert_lines(int row, int num_lines)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2094 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2095 PhRect_t rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2096 PhPoint_t delta;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2097
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2098 rect.ul.x = FILL_X(gui.scroll_region_left);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2099 rect.ul.y = FILL_Y(row);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2100
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2101 rect.lr.x = FILL_X(gui.scroll_region_right + 1) - 1;
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2102 rect.lr.y = FILL_Y(gui.scroll_region_bot - num_lines + 1) - 1;
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2103
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2104 PtWidgetOffset(gui.vimTextArea, &gui_ph_raw_offset);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2105 PhTranslatePoint(&gui_ph_raw_offset, PtWidgetPos(gui.vimTextArea, NULL));
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2106 PhTranslateRect(&rect, &gui_ph_raw_offset);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2108 delta.x = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2109 delta.y = num_lines * gui.char_height;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2111 PgFlush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2112
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2113 PhBlit(PtWidgetRid(PtFindDisjoint(gui.vimTextArea)) , &rect, &delta);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2114
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2115 gui_clear_block(row, gui.scroll_region_left,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2116 row + num_lines - 1, gui.scroll_region_right);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2117 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2118
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2119 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2120 gui_mch_draw_string(int row, int col, char_u *s, int len, int flags)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2121 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2122 static char *utf8_buffer = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2123 static int utf8_len = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2124
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2125 PhPoint_t pos = { TEXT_X(col), TEXT_Y(row) };
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2126 PhRect_t rect;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2127
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2128 if (is_ignore_draw == TRUE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2129 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2130
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2131 DRAW_START;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2132
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2133 if (!(flags & DRAW_TRANSP))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2134 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2135 PgDrawIRect(
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2136 FILL_X(col), FILL_Y(row),
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2137 FILL_X(col + len) - 1, FILL_Y(row + 1) - 1,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2138 Pg_DRAW_FILL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2139 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2140
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2141 if (flags & DRAW_UNDERL)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2142 PgSetUnderline(gui.norm_pixel, Pg_TRANSPARENT, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2143
15595
1ec942f1b648 patch 8.1.0805: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents: 15470
diff changeset
2144 if (charset_translate != NULL && enc_utf8 == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2145 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2146 int src_taken, dst_made;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2147
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2148 // Use a static buffer to avoid large amounts of de/allocations
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2149 if (utf8_len < len)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2150 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2151 utf8_buffer = realloc(utf8_buffer, len * MB_LEN_MAX);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2152 utf8_len = len;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2153 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2154
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2155 PxTranslateToUTF(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2156 charset_translate,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2157 s,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2158 len,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2159 &src_taken,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2160 utf8_buffer,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2161 utf8_len,
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2162 &dst_made);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2163 s = utf8_buffer;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2164 len = dst_made;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2165 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2166
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2167 PgDrawText(s, len, &pos, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2168
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2169 if (flags & DRAW_BOLD)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2170 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2171 // FIXME: try and only calculate these values once...
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2172 rect.ul.x = FILL_X(col) + 1;
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2173 rect.ul.y = FILL_Y(row);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2174 rect.lr.x = FILL_X(col + len) - 1;
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2175 rect.lr.y = FILL_Y(row + 1) - 1;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2176 // PgSetUserClip(NULL) causes the scrollbar to not redraw...
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2177 #if 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2178 pos.x++;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2179
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2180 PgSetUserClip(&rect);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2181 PgDrawText(s, len, &pos, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2182 PgSetUserClip(NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2183 #else
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2184 rect.lr.y -= (p_linespace + 1) / 2;
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2185 // XXX: DrawTextArea doesn't work with phditto
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2186 PgDrawTextArea(s, len, &rect, Pg_TEXT_BOTTOM);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2187 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2188 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2189
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2190 if (flags & DRAW_UNDERL)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2191 PgSetUnderline(Pg_TRANSPARENT, Pg_TRANSPARENT, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2192
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2193 DRAW_END;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2194 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2195
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2196 ////////////////////////////////////////////////////////////////////////////
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2197 // Cursor
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2198
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2199 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2200 gui_mch_draw_hollow_cursor(guicolor_T color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2201 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2202 PhRect_t r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2203
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2204 // FIXME: Double width characters
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2205
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2206 r.ul.x = FILL_X(gui.col);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2207 r.ul.y = FILL_Y(gui.row);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2208 r.lr.x = r.ul.x + gui.char_width - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2209 r.lr.y = r.ul.y + gui.char_height - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2210
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2211 DRAW_START;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2212 PgSetStrokeColor(color);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2213 PgDrawRect(&r, Pg_DRAW_STROKE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2214 DRAW_END;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2215 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2216
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2217 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2218 gui_mch_draw_part_cursor(int w, int h, guicolor_T color)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2219 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2220 PhRect_t r;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2221
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2222 r.ul.x = FILL_X(gui.col);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2223 r.ul.y = FILL_Y(gui.row) + gui.char_height - h;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2224 r.lr.x = r.ul.x + w - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2225 r.lr.y = r.ul.y + h - 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2226
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2227 DRAW_START;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2228 gui_mch_set_bg_color(color);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2229 PgDrawRect(&r, Pg_DRAW_FILL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2230 DRAW_END;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2231 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2232
9213
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9013
diff changeset
2233 int
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9013
diff changeset
2234 gui_mch_is_blinking(void)
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9013
diff changeset
2235 {
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9013
diff changeset
2236 return blink_state != BLINK_NONE;
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9013
diff changeset
2237 }
bb86514cad15 commit https://github.com/vim/vim/commit/703a8044b5393d37d355b0b1054a9a5a13912a3f
Christian Brabandt <cb@256bit.org>
parents: 9013
diff changeset
2238
9428
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9213
diff changeset
2239 int
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9213
diff changeset
2240 gui_mch_is_blink_off(void)
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9213
diff changeset
2241 {
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9213
diff changeset
2242 return blink_state == BLINK_OFF;
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9213
diff changeset
2243 }
0c7f47088e55 commit https://github.com/vim/vim/commit/9d5d3c9c4468ad76f16b50eabd3d9e7eab2ed44d
Christian Brabandt <cb@256bit.org>
parents: 9213
diff changeset
2244
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2245 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2246 gui_mch_set_blinking(long wait, long on, long off)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2247 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2248 blink_waittime = wait;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2249 blink_ontime = on;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2250 blink_offtime = off;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2251 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2252
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2253 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2254 gui_mch_start_blink(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2255 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2256 // Only turn on the timer on if none of the times are zero
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2257 if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2258 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2259 PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2260 blink_waittime, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2261 blink_state = BLINK_ON;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2262 gui_update_cursor(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2263 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2264 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2265
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2266 void
13152
f4c3a7f410f4 patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
2267 gui_mch_stop_blink(int may_call_gui_update_cursor)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2268 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2269 PtSetResource(gui_ph_timer_cursor, Pt_ARG_TIMER_INITIAL, 0, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2270
13152
f4c3a7f410f4 patch 8.0.1450: GUI: endless loop when stopping cursor blinking
Christian Brabandt <cb@256bit.org>
parents: 11745
diff changeset
2271 if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2272 gui_update_cursor(TRUE, FALSE);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2273
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2274 blink_state = BLINK_NONE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2275 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2276
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2277 ////////////////////////////////////////////////////////////////////////////
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2278 // miscellaneous functions
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2279
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2280 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2281 gui_mch_beep(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2282 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2283 PtBeep();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2284 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2285
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2286 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2287 gui_mch_flash(int msec)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2288 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2289 PgSetFillXORColor(Pg_BLACK, Pg_WHITE);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2290 PgSetDrawMode(Pg_DRAWMODE_XOR);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2291 gui_mch_clear_all();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2292 gui_mch_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2293
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2294 ui_delay((long) msec, TRUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2295
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2296 gui_mch_clear_all();
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2297 PgSetDrawMode(Pg_DRAWMODE_OPAQUE);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2298 gui_mch_flush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2299 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2300
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2301 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2302 gui_mch_flush(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2303 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2304 PgFlush();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2305 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2306
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2307 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2308 gui_mch_set_text_area_pos(int x, int y, int w, int h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2309 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2310 PhArea_t area = {{x, y}, {w, h}};
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2311
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2312 PtSetResource(gui.vimTextArea, Pt_ARG_AREA, &area, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2313 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2314
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2315 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2316 gui_mch_haskey(char_u *name)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2317 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2318 int i;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2319
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2320 for (i = 0; special_keys[i].key_sym != 0; i++)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2321 if (name[0] == special_keys[i].vim_code0 &&
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2322 name[1] == special_keys[i].vim_code1)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2323 return OK;
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2324 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2325 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2326
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2327 ////////////////////////////////////////////////////////////////////////////
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2328 // Menu
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2329
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2330 #ifdef FEAT_TOOLBAR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2331 #include "toolbar.phi"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2332
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2333 static PhImage_t *gui_ph_toolbar_images[] = {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2334 &tb_new_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2335 &tb_open_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2336 &tb_save_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2337 &tb_undo_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2338 &tb_redo_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2339 &tb_cut_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2340 &tb_copy_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2341 &tb_paste_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2342 &tb_print_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2343 &tb_help_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2344 &tb_find_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2345 &tb_save_all_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2346 &tb_save_session_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2347 &tb_new_session_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2348 &tb_load_session_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2349 &tb_macro_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2350 &tb_replace_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2351 &tb_close_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2352 &tb_maximize_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2353 &tb_minimize_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2354 &tb_split_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2355 &tb_shell_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2356 &tb_find_prev_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2357 &tb_find_next_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2358 &tb_find_help_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2359 &tb_make_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2360 &tb_jump_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2361 &tb_ctags_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2362 &tb_vsplit_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2363 &tb_maxwidth_phi,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2364 &tb_minwidth_phi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2365 };
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2366
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2367 static PhImage_t *
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2368 gui_ph_toolbar_load_icon(char_u *iconfile)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2369 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2370 static PhImage_t external_icon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2371 PhImage_t *temp_phi = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2372
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2373 temp_phi = PxLoadImage(iconfile, NULL);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2374 if (temp_phi != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2375 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2376 // The label widget will free the image/palette/etc. for us when
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2377 // it's destroyed
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2378 temp_phi->flags |= Ph_RELEASE_IMAGE_ALL;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2379 memcpy(&external_icon, temp_phi, sizeof(external_icon));
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2380 free(temp_phi);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2381
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2382 temp_phi = &external_icon;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2383 }
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2384 return temp_phi;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2385 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2386
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2387 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2388 * This returns either a builtin icon image, an external image or NULL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2389 * if it can't find either. The caller can't and doesn't need to try and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2390 * free() the returned image, and it can't store the image pointer.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2391 * (When setting the Pt_ARG_LABEL_IMAGE resource, the contents of the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2392 * PhImage_t are copied, and the original PhImage_t aren't needed anymore).
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2393 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2394 static PhImage_t *
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2395 gui_ph_toolbar_find_icon(vimmenu_T *menu)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2396 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2397 char_u full_pathname[ MAXPATHL + 1 ];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2398 PhImage_t *icon = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2399
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2400 if (menu->icon_builtin == FALSE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2401 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2402 if (menu->iconfile != NULL)
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2403 // TODO: use gui_find_iconfile()
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2404 icon = gui_ph_toolbar_load_icon(menu->iconfile);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2405
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2406 // TODO: Restrict loading to just .png? Search for any format?
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2407 if ((icon == NULL) &&
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2408 ((gui_find_bitmap(menu->name, full_pathname, "gif") == OK) ||
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2409 (gui_find_bitmap(menu->name, full_pathname, "png") == OK)))
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2410 icon = gui_ph_toolbar_load_icon(full_pathname);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2411
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2412 if (icon != NULL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2413 return icon;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2414 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2415
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2416 if (menu->iconidx >= 0 &&
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2417 (menu->iconidx < ARRAY_LENGTH(gui_ph_toolbar_images)))
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2418 return gui_ph_toolbar_images[menu->iconidx];
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2419
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2420 return NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2421 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2422 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2423
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2424 #if defined(FEAT_MENU) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2425 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2426 gui_mch_enable_menu(int flag)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2427 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2428 if (flag != 0)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2429 PtRealizeWidget(gui.vimMenuBar);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2430 else
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2431 PtUnrealizeWidget(gui.vimMenuBar);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2432 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2433
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2434 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2435 gui_mch_set_menu_pos(int x, int y, int w, int h)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2436 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2437 // Nothing
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2438 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2439
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2440 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2441 * Change the position of a menu button in the parent
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2442 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2443 static void
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2444 gui_ph_position_menu(PtWidget_t *widget, int priority)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2445 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2446 PtWidget_t *traverse;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2447 vimmenu_T *menu;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2448
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2449 traverse = PtWidgetChildBack(PtWidgetParent(widget));
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2450
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2451 // Iterate through the list of widgets in traverse, until
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2452 // we find the position we want to insert our widget into
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2453 // TODO: traverse from front to back, possible speedup?
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2454 while (traverse != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2455 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2456 PtGetResource(traverse, Pt_ARG_POINTER, &menu, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2457
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2458 if (menu != NULL &&
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2459 priority < menu->priority &&
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2460 widget != traverse)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2461 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2462 // Insert the widget before the current traverse widget
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2463 PtWidgetInsert(widget, traverse, 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2464 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2465 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2466
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2467 traverse = PtWidgetBrotherInFront(traverse);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2468 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2469 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2470
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2471 /*
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2472 * the index is ignored because it's not useful for our purposes
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2473 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2474 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2475 gui_mch_add_menu(vimmenu_T *menu, int index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2476 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2477 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2478 char_u *accel_key;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2479 char_u mnemonic_str[MB_LEN_MAX];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2480 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2481 PtArg_t args[5];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2482
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2483 menu->submenu_id = menu->id = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2484
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2485 if (menu_is_menubar(menu->name))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2486 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2487
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2488 accel_key = vim_strchr(menu->name, '&');
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2489 if (accel_key != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2490 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2491 mnemonic_str[0] = accel_key[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2492 mnemonic_str[1] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2493 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2494
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2495 // Create the menu button
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2496 n = 0;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2497 PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2498 PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2499 if (accel_key != NULL)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2500 PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_KEY, mnemonic_str, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2501 PtSetArg(&args[ n++ ], Pt_ARG_POINTER, menu, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2502
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2503 if (parent != NULL)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2504 PtSetArg(&args[ n++ ], Pt_ARG_BUTTON_TYPE, Pt_MENU_RIGHT, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2505
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2506 menu->id = PtCreateWidget(PtMenuButton,
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2507 (parent == NULL) ? gui.vimMenuBar : parent->submenu_id,
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2508 n, args);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2509
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2510 PtAddCallback(menu->id, Pt_CB_ARM, gui_ph_handle_pulldown_menu, menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2511
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2512 // Create the actual menu
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2513 n = 0;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2514 if (parent != NULL)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2515 PtSetArg(&args[ n++ ], Pt_ARG_MENU_FLAGS, Pt_TRUE, Pt_MENU_CHILD);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2516
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2517 menu->submenu_id = PtCreateWidget(PtMenu, menu->id, n, args);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2518
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2519 if (parent == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2520 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2521 PtAddCallback(menu->submenu_id, Pt_CB_UNREALIZED,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2522 gui_ph_handle_menu_unrealized, menu);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2523
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2524 if (menu->mnemonic != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2525 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2526 PtAddHotkeyHandler(gui.vimWindow, tolower(menu->mnemonic),
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2527 Pk_KM_Alt, 0, menu, gui_ph_handle_pulldown_menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2528 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2529 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2530
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2531 gui_ph_position_menu(menu->id, menu->priority);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2532
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2533 // Redraw menubar here instead of gui_mch_draw_menubar
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2534 if (gui.menu_is_active)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2535 PtRealizeWidget(menu->id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2536 }
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2537 else if (menu_is_popup(menu->name))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2538 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2539 menu->submenu_id = PtCreateWidget(PtMenu, gui.vimWindow, 0, NULL);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2540 PtAddCallback(menu->submenu_id, Pt_CB_UNREALIZED,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2541 gui_ph_handle_menu_unrealized, menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2542 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2543 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2544
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2545 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2546 gui_mch_add_menu_item(vimmenu_T *menu, int index)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2547 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2548 vimmenu_T *parent = menu->parent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2549 char_u *accel_key;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2550 char_u mnemonic_str[MB_LEN_MAX];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2551 int n;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2552 PtArg_t args[13];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2553
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2554 n = 0;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2555 PtSetArg(&args[ n++ ], Pt_ARG_POINTER, menu, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2556
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2557 #ifdef FEAT_TOOLBAR
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2558 if (menu_is_toolbar(parent->name))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2559 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2560 if (menu_is_separator(menu->name))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2561 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2562 PtSetArg(&args[ n++ ], Pt_ARG_SEP_FLAGS,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2563 Pt_SEP_VERTICAL, Pt_SEP_ORIENTATION);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2564 PtSetArg(&args[ n++ ], Pt_ARG_SEP_TYPE, Pt_ETCHED_IN, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2565 PtSetArg(&args[ n++ ], Pt_ARG_ANCHOR_FLAGS,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2566 Pt_TRUE, Pt_ANCHOR_TOP_BOTTOM);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2567 PtSetArg(&args[ n++ ], Pt_ARG_WIDTH, 2, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2568 menu->id = PtCreateWidget(PtSeparator, gui.vimToolBar, n, args);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2569 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2570 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2571 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2572 if (strstr((const char *) p_toolbar, "text") != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2573 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2574 PtSetArg(&args[ n++ ], Pt_ARG_BALLOON_POSITION,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2575 Pt_BALLOON_BOTTOM, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2576 PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2577 PtSetArg(&args[ n++ ], Pt_ARG_TEXT_FONT, "TextFont08", 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2578 }
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2579 if ((strstr((const char *) p_toolbar, "icons") != NULL) &&
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2580 (gui_ph_toolbar_images != NULL))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2581 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2582 PtSetArg(&args[ n++ ], Pt_ARG_LABEL_IMAGE,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2583 gui_ph_toolbar_find_icon(menu), 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2584 PtSetArg(&args[ n++ ], Pt_ARG_LABEL_TYPE, Pt_TEXT_IMAGE, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2585 PtSetArg(&args[ n++ ], Pt_ARG_TEXT_IMAGE_SPACING, 0, 0);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2586 }
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2587 if (strstr((const char *) p_toolbar, "tooltips") != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2588 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2589 PtSetArg(&args[ n++ ], Pt_ARG_LABEL_BALLOON,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2590 gui_ph_show_tooltip, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2591 PtSetArg(&args[ n++ ], Pt_ARG_LABEL_FLAGS,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2592 Pt_TRUE, Pt_SHOW_BALLOON);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2593 }
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2594 PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_HEIGHT, 1, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2595 PtSetArg(&args[ n++ ], Pt_ARG_MARGIN_WIDTH, 1, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2596 PtSetArg(&args[ n++ ], Pt_ARG_FLAGS, Pt_FALSE,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2597 Pt_HIGHLIGHTED | Pt_GETS_FOCUS);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2598 PtSetArg(&args[ n++ ], Pt_ARG_FILL_COLOR, Pg_TRANSPARENT, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2599 menu->id = PtCreateWidget(PtButton, gui.vimToolBar, n, args);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2600
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2601 PtAddCallback(menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2602 }
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2603 // Update toolbar if it's open
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2604 if (PtWidgetIsRealized(gui.vimToolBar))
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2605 PtRealizeWidget(menu->id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2606 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2607 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2608 #endif
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2609 if (menu_is_separator(menu->name))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2610 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2611 menu->id = PtCreateWidget(PtSeparator, parent->submenu_id, n, args);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2612 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2613 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2614 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2615 accel_key = vim_strchr(menu->name, '&');
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2616 if (accel_key != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2617 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2618 mnemonic_str[0] = accel_key[1];
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2619 mnemonic_str[1] = NUL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2620 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2621
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2622 PtSetArg(&args[ n++ ], Pt_ARG_TEXT_STRING, menu->dname, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2623 if (accel_key != NULL)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2624 PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_KEY, mnemonic_str,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2625 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2626
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2627 PtSetArg(&args[ n++ ], Pt_ARG_ACCEL_TEXT, menu->actext, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2628
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2629 menu->id = PtCreateWidget(PtMenuButton, parent->submenu_id, n, args);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2630
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2631 PtAddCallback(menu->id, Pt_CB_ACTIVATE, gui_ph_handle_menu, menu);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2632
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2633 #ifdef USE_PANEL_GROUP
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2634 if (gui_ph_is_buffer_item(menu, parent) == TRUE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2635 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2636 PtAddCallback(menu->id, Pt_CB_DESTROYED,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2637 gui_ph_handle_buffer_remove, menu);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2638 gui_ph_pg_add_buffer(menu->dname);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2639 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2640 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2641 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2642
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2643 gui_ph_position_menu(menu->id, menu->priority);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2644 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2645
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2646 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2647 gui_mch_destroy_menu(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2648 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2649 if (menu->submenu_id != NULL)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2650 PtDestroyWidget(menu->submenu_id);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2651 if (menu->id != NULL)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2652 PtDestroyWidget(menu->id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2653
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2654 menu->submenu_id = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2655 menu->id = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2656 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2657
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2658 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2659 gui_mch_menu_grey(vimmenu_T *menu, int grey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2660 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2661 long flags, mask, fields;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2662
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2663 if (menu->id == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2664 return;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2665
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2666 flags = PtWidgetFlags(menu->id);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2667 if (PtWidgetIsClass(menu->id, PtMenuButton) &&
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2668 PtWidgetIsClass(PtWidgetParent(menu->id), PtMenu))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2669 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2670 fields = Pt_FALSE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2671 mask = Pt_SELECTABLE | Pt_HIGHLIGHTED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2672 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2673 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2674 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2675 fields = Pt_TRUE;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2676 mask = Pt_BLOCKED | Pt_GHOST;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2677 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2678
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2679 if (! grey)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2680 fields = ~fields;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2681
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2682 PtSetResource(menu->id, Pt_ARG_FLAGS, fields,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2683 mask);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2684 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2685
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2686 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2687 gui_mch_menu_hidden(vimmenu_T *menu, int hidden)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2688 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2689 // TODO: [un]realize the widget?
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2690 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2691
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2692 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2693 gui_mch_draw_menubar(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2694 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2695 // The only time a redraw is needed is when a menu button
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2696 // is added to the menubar, and that is detected and the bar
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2697 // redrawn in gui_mch_add_menu_item
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2698 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2699
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2700 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2701 gui_mch_show_popupmenu(vimmenu_T *menu)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2702 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2703 PtSetResource(menu->submenu_id, Pt_ARG_POS, &abs_mouse, 0);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2704 PtRealizeWidget(menu->submenu_id);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2705 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2706
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2707 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2708 gui_mch_toggle_tearoffs(int enable)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2709 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2710 // No tearoffs yet
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2711 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2712
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2713 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2714
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2715 #if defined(FEAT_TOOLBAR) || defined(PROTO)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2716 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2717 gui_mch_show_toolbar(int showit)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2718 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2719 if (showit)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2720 PtRealizeWidget(gui.vimToolBar);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2721 else
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2722 PtUnrealizeWidget(gui.vimToolBar);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2723 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2724 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2725
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2726 ////////////////////////////////////////////////////////////////////////////
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2727 // Fonts
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2728
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2729 static GuiFont
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2730 gui_ph_get_font(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2731 char_u *font_name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2732 int_u font_flags,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2733 int_u font_size,
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2734 // Check whether the resulting font has the font flags and size that
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2735 // was asked for
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2736 int_u enforce
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2737 )
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2738 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2739 char_u *font_tag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2740 FontQueryInfo info;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2741 int_u style;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2742
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2743 font_tag = alloc(MAX_FONT_TAG);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2744 if (font_tag != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2745 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2746 if (PfGenerateFontName(font_name, font_flags, font_size,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2747 font_tag) != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2748 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2749 // Enforce some limits on the font used
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2750 style = PHFONT_INFO_FIXED;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2751
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2752 if (enforce & PF_STYLE_BOLD)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2753 style |= PHFONT_INFO_BOLD;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2754 if (enforce & PF_STYLE_ANTIALIAS)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2755 style |= PHFONT_INFO_ALIAS;
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2756 if (enforce & PF_STYLE_ITALIC)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2757 style |= PHFONT_INFO_ITALIC;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2758
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2759 PfQueryFontInfo(font_tag, &info);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2760
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2761 if (info.size == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2762 font_size = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2763
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2764 // Make sure font size matches, and that the font style
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2765 // at least has the bits we're checking for
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2766 if (font_size == info.size &&
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2767 style == (info.style & style))
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2768 return (GuiFont)font_tag;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2769 }
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2770 vim_free(font_tag);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2771 }
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2772 return NULL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2773 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2774
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2775 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2776 * Split up the vim font name
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2777 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2778 * vim_font is in the form of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2779 * <name>:s<height>:a:b:i
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2780 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2781 * a = antialias
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2782 * b = bold
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2783 * i = italic
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2784 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2785 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2786
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2787 static int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2788 gui_ph_parse_font_name(
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2789 char_u *vim_font,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2790 char_u **font_name,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2791 int_u *font_flags,
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2792 int_u *font_size)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2793 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2794 char_u *mark;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2795 int_u name_len, size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2796
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2797 mark = vim_strchr(vim_font, ':');
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2798 if (mark == NULL)
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2799 name_len = STRLEN(vim_font);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2800 else
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2801 name_len = (int_u) (mark - vim_font);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2802
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2803 *font_name = vim_strnsave(vim_font, name_len);
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
2804 if (*font_name != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2805 {
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
2806 if (mark != NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2807 {
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
2808 while (*mark != NUL && *mark++ == ':')
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2809 {
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
2810 switch (tolower(*mark++))
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2811 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2812 case 'a': *font_flags |= PF_STYLE_ANTIALIAS; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2813 case 'b': *font_flags |= PF_STYLE_BOLD; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2814 case 'i': *font_flags |= PF_STYLE_ITALIC; break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2815
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2816 case 's':
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2817 size = getdigits(&mark);
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2818 // Restrict the size to some vague limits
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
2819 if (size < 1 || size > 100)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2820 size = 8;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2821
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2822 *font_size = size;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2823 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2824
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2825 default:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2826 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2827 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2828 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2829 }
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2830 return TRUE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2831 }
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2832 return FALSE;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2833 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2834
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2835 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2836 gui_mch_init_font(char_u *vim_font_name, int fontset)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2837 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2838 char_u *font_tag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2839 char_u *font_name = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2840 int_u font_flags = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2841 int_u font_size = 12;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2842
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2843 FontQueryInfo info;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2844 PhRect_t extent;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2845
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
2846 if (vim_font_name == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2847 {
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2848 // Default font
1922
e65e50609469 updated for version 7.2-219
vimboss
parents: 1214
diff changeset
2849 vim_font_name = "PC Terminal";
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2850 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2851
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2852 if (STRCMP(vim_font_name, "*") == 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2853 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2854 font_tag = PtFontSelection(gui.vimWindow, NULL, NULL,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2855 "pcterm12", -1, PHFONT_FIXED, NULL);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2856
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
2857 if (font_tag == NULL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2858 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2859
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2860 gui_mch_free_font(gui.norm_font);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2861 gui.norm_font = font_tag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2862
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2863 PfQueryFontInfo(font_tag, &info);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2864 font_name = vim_strsave(info.font);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2865 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2866 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2867 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2868 if (gui_ph_parse_font_name(vim_font_name, &font_name, &font_flags,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2869 &font_size) == FALSE)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2870 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2871
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2872 font_tag = gui_ph_get_font(font_name, font_flags, font_size, 0);
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
2873 if (font_tag == NULL)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2874 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2875 vim_free(font_name);
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2876 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2877 }
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
2878
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2879 gui_mch_free_font(gui.norm_font);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2880 gui.norm_font = font_tag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2881 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2882
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2883 gui_mch_free_font(gui.bold_font);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2884 gui.bold_font = gui_ph_get_font(font_name, font_flags | PF_STYLE_BOLD,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2885 font_size, PF_STYLE_BOLD);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2886
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2887 gui_mch_free_font(gui.ital_font);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2888 gui.ital_font = gui_ph_get_font(font_name, font_flags | PF_STYLE_ITALIC,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2889 font_size, PF_STYLE_ITALIC);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2890
18788
e1f4e9d78a6a patch 8.1.2383: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents: 16825
diff changeset
2891 // This extent was brought to you by the letter 'g'
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2892 PfExtentText(&extent, NULL, font_tag, "g", 1);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2893
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2894 gui.char_width = extent.lr.x - extent.ul.x + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2895 gui.char_height = (- extent.ul.y) + extent.lr.y + 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2896 gui.char_ascent = - extent.ul.y;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2897
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2898 vim_free(font_name);
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2899 return OK;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2900 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2901
444
d0d15b184c56 updated for version 7.0116
vimboss
parents: 205
diff changeset
2902 /*
d0d15b184c56 updated for version 7.0116
vimboss
parents: 205
diff changeset
2903 * Adjust gui.char_height (after 'linespace' was changed).
d0d15b184c56 updated for version 7.0116
vimboss
parents: 205
diff changeset
2904 */
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2905 int
444
d0d15b184c56 updated for version 7.0116
vimboss
parents: 205
diff changeset
2906 gui_mch_adjust_charheight(void)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2907 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2908 FontQueryInfo info;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2909
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2910 PfQueryFontInfo(gui.norm_font, &info);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2911
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2912 gui.char_height = - info.ascender + info.descender + p_linespace;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2913 gui.char_ascent = - info.ascender + p_linespace / 2;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2914
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2915 return OK;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2916 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2917
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2918 GuiFont
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2919 gui_mch_get_font(char_u *vim_font_name, int report_error)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2920 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2921 char_u *font_name;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2922 char_u *font_tag;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2923 int_u font_size = 12;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2924 int_u font_flags = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2925
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2926 if (gui_ph_parse_font_name(vim_font_name, &font_name, &font_flags,
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2927 &font_size) != FALSE)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2928 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2929 font_tag = gui_ph_get_font(font_name, font_flags, font_size, -1);
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2930 vim_free(font_name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2931
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
2932 if (font_tag != NULL)
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2933 return (GuiFont)font_tag;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2934 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2935
2998
32a52f06f33b updated for version 7.3.271
Bram Moolenaar <bram@vim.org>
parents: 2980
diff changeset
2936 if (report_error)
15470
55ccc2d353bd patch 8.1.0743: giving error messages is not flexible
Bram Moolenaar <Bram@vim.org>
parents: 14862
diff changeset
2937 semsg(e_font, vim_font_name);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2938
2980
847733973bfd updated for version 7.3.262
Bram Moolenaar <bram@vim.org>
parents: 2684
diff changeset
2939 return FAIL;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2940 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2941
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents: 37
diff changeset
2942 #if defined(FEAT_EVAL) || defined(PROTO)
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
2943 /*
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
2944 * Return the name of font "font" in allocated memory.
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
2945 * Don't know how to get the actual name, thus use the provided name.
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
2946 */
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
2947 char_u *
7823
bcef391c101c commit https://github.com/vim/vim/commit/68c2f638e65d914dc6e84eb7ce2624f08af525c0
Christian Brabandt <cb@256bit.org>
parents: 4352
diff changeset
2948 gui_mch_get_fontname(GuiFont font, char_u *name)
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
2949 {
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
2950 if (name == NULL)
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
2951 return NULL;
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
2952 return vim_strsave(name);
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
2953 }
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents: 37
diff changeset
2954 #endif
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 7
diff changeset
2955
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2956 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2957 gui_mch_set_font(GuiFont font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2958 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2959 PgSetFont(font);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2960 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2961
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2962 void
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2963 gui_mch_free_font(GuiFont font)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2964 {
3076
51ce22ba89d1 updated for version 7.3.310
Bram Moolenaar <bram@vim.org>
parents: 3054
diff changeset
2965 vim_free(font);
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2966 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2967