annotate src/gui_photon.c @ 1130:04dbdca9c34c

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