Mercurial > vim
comparison src/gui_kde_wid.cc @ 42:c75153d791d0
updated for version 7.0026
author | vimboss |
---|---|
date | Wed, 29 Dec 2004 20:58:21 +0000 |
parents | 8ff7fd162d3c |
children | 1154524da1cd |
comparison
equal
deleted
inserted
replaced
41:f529edb9bab3 | 42:c75153d791d0 |
---|---|
67 int qtkey; | 67 int qtkey; |
68 char_u code0; | 68 char_u code0; |
69 char_u code1; | 69 char_u code1; |
70 } special_keys[] = | 70 } special_keys[] = |
71 { | 71 { |
72 { Qt::Key_Up, 'k', 'u' }, | 72 {Qt::Key_Up, 'k', 'u'}, |
73 { Qt::Key_Down, 'k', 'd' }, | 73 {Qt::Key_Down, 'k', 'd'}, |
74 { Qt::Key_Left, 'k', 'l' }, | 74 {Qt::Key_Left, 'k', 'l'}, |
75 { Qt::Key_Right, 'k', 'r' }, | 75 {Qt::Key_Right, 'k', 'r'}, |
76 { Qt::Key_F1, 'k', '1' }, | 76 {Qt::Key_F1, 'k', '1'}, |
77 { Qt::Key_F2, 'k', '2' }, | 77 {Qt::Key_F2, 'k', '2'}, |
78 { Qt::Key_F3, 'k', '3' }, | 78 {Qt::Key_F3, 'k', '3'}, |
79 { Qt::Key_F4, 'k', '4' }, | 79 {Qt::Key_F4, 'k', '4'}, |
80 { Qt::Key_F5, 'k', '5' }, | 80 {Qt::Key_F5, 'k', '5'}, |
81 { Qt::Key_F6, 'k', '6' }, | 81 {Qt::Key_F6, 'k', '6'}, |
82 { Qt::Key_F7, 'k', '7' }, | 82 {Qt::Key_F7, 'k', '7'}, |
83 { Qt::Key_F8, 'k', '8' }, | 83 {Qt::Key_F8, 'k', '8'}, |
84 { Qt::Key_F9, 'k', '9' }, | 84 {Qt::Key_F9, 'k', '9'}, |
85 { Qt::Key_F10, 'k', ';' }, | 85 {Qt::Key_F10, 'k', ';'}, |
86 { Qt::Key_F11, 'F', '1' }, | 86 {Qt::Key_F11, 'F', '1'}, |
87 { Qt::Key_F12, 'F', '2' }, | 87 {Qt::Key_F12, 'F', '2'}, |
88 { Qt::Key_F13, 'F', '3' }, | 88 {Qt::Key_F13, 'F', '3'}, |
89 { Qt::Key_F14, 'F', '4' }, | 89 {Qt::Key_F14, 'F', '4'}, |
90 { Qt::Key_F15, 'F', '5' }, | 90 {Qt::Key_F15, 'F', '5'}, |
91 { Qt::Key_F16, 'F', '6' }, | 91 {Qt::Key_F16, 'F', '6'}, |
92 { Qt::Key_F17, 'F', '7' }, | 92 {Qt::Key_F17, 'F', '7'}, |
93 { Qt::Key_F18, 'F', '8' }, | 93 {Qt::Key_F18, 'F', '8'}, |
94 { Qt::Key_F19, 'F', '9' }, | 94 {Qt::Key_F19, 'F', '9'}, |
95 { Qt::Key_F20, 'F', 'A' }, | 95 {Qt::Key_F20, 'F', 'A'}, |
96 { Qt::Key_F21, 'F', 'B' }, | 96 {Qt::Key_F21, 'F', 'B'}, |
97 { Qt::Key_F22, 'F', 'C' }, | 97 {Qt::Key_F22, 'F', 'C'}, |
98 { Qt::Key_F23, 'F', 'D' }, | 98 {Qt::Key_F23, 'F', 'D'}, |
99 { Qt::Key_F24, 'F', 'E' }, | 99 {Qt::Key_F24, 'F', 'E'}, |
100 { Qt::Key_F25, 'F', 'F' }, | 100 {Qt::Key_F25, 'F', 'F'}, |
101 { Qt::Key_F26, 'F', 'G' }, | 101 {Qt::Key_F26, 'F', 'G'}, |
102 { Qt::Key_F27, 'F', 'H' }, | 102 {Qt::Key_F27, 'F', 'H'}, |
103 { Qt::Key_F28, 'F', 'I' }, | 103 {Qt::Key_F28, 'F', 'I'}, |
104 { Qt::Key_F29, 'F', 'J' }, | 104 {Qt::Key_F29, 'F', 'J'}, |
105 { Qt::Key_F30, 'F', 'K' }, | 105 {Qt::Key_F30, 'F', 'K'}, |
106 { Qt::Key_F31, 'F', 'L' }, | 106 {Qt::Key_F31, 'F', 'L'}, |
107 { Qt::Key_F32, 'F', 'M' }, | 107 {Qt::Key_F32, 'F', 'M'}, |
108 { Qt::Key_F33, 'F', 'N' }, | 108 {Qt::Key_F33, 'F', 'N'}, |
109 { Qt::Key_F34, 'F', 'O' }, | 109 {Qt::Key_F34, 'F', 'O'}, |
110 { Qt::Key_F35, 'F', 'P' }, | 110 {Qt::Key_F35, 'F', 'P'}, |
111 { Qt::Key_Help, '%', '1' }, | 111 {Qt::Key_Help, '%', '1'}, |
112 // { Qt::Key_Undo, '&', '8' }, <= hmmm ? | 112 // { Qt::Key_Undo, '&', '8'}, <= hmmm ? |
113 { Qt::Key_BackSpace, 'k', 'b' }, | 113 {Qt::Key_BackSpace, 'k', 'b'}, |
114 { Qt::Key_Insert, KS_EXTRA, KE_KINS }, | 114 {Qt::Key_Insert, KS_EXTRA, KE_KINS }, |
115 { Qt::Key_Delete, KS_EXTRA, KE_KDEL }, | 115 {Qt::Key_Delete, KS_EXTRA, KE_KDEL }, |
116 { Qt::Key_Home, 'K', '1' }, | 116 {Qt::Key_Home, 'K', '1'}, |
117 { Qt::Key_End, 'K', '4' }, | 117 {Qt::Key_End, 'K', '4'}, |
118 { Qt::Key_Prior, 'K', '3' }, | 118 {Qt::Key_Prior, 'K', '3'}, |
119 { Qt::Key_Next, 'K', '5' }, | 119 {Qt::Key_Next, 'K', '5'}, |
120 { Qt::Key_Print, '%', '9' }, | 120 {Qt::Key_Print, '%', '9'}, |
121 | 121 |
122 { Qt::Key_Plus, 'K', '6'}, | 122 {Qt::Key_Plus, 'K', '6'}, |
123 { Qt::Key_Minus, 'K', '7'}, | 123 {Qt::Key_Minus, 'K', '7'}, |
124 { Qt::Key_Slash, 'K', '8'}, | 124 {Qt::Key_Slash, 'K', '8'}, |
125 { Qt::Key_multiply, 'K', '9'}, | 125 {Qt::Key_multiply, 'K', '9'}, |
126 { Qt::Key_Enter, 'K', 'A'}, | 126 {Qt::Key_Enter, 'K', 'A'}, |
127 { Qt::Key_Period, 'K', 'B'}, | 127 {Qt::Key_Period, 'K', 'B'}, |
128 | 128 |
129 { Qt::Key_0, 'K', 'C'}, | 129 {Qt::Key_0, 'K', 'C'}, |
130 { Qt::Key_1, 'K', 'D'}, | 130 {Qt::Key_1, 'K', 'D'}, |
131 { Qt::Key_2, 'K', 'E'}, | 131 {Qt::Key_2, 'K', 'E'}, |
132 { Qt::Key_3, 'K', 'F'}, | 132 {Qt::Key_3, 'K', 'F'}, |
133 { Qt::Key_4, 'K', 'G'}, | 133 {Qt::Key_4, 'K', 'G'}, |
134 { Qt::Key_5, 'K', 'H'}, | 134 {Qt::Key_5, 'K', 'H'}, |
135 { Qt::Key_6, 'K', 'I'}, | 135 {Qt::Key_6, 'K', 'I'}, |
136 { Qt::Key_7, 'K', 'J'}, | 136 {Qt::Key_7, 'K', 'J'}, |
137 { Qt::Key_8, 'K', 'K'}, | 137 {Qt::Key_8, 'K', 'K'}, |
138 { Qt::Key_9, 'K', 'L'}, | 138 {Qt::Key_9, 'K', 'L'}, |
139 | |
139 /* End of list marker: */ | 140 /* End of list marker: */ |
140 { 0, 0, 0 } | 141 {0, 0, 0} |
141 };//}}} | 142 };//}}} |
142 | 143 |
143 #ifdef FEAT_CLIENTSERVER | 144 #ifdef FEAT_CLIENTSERVER |
144 typedef int (*QX11EventFilter) (XEvent*); | 145 typedef int (*QX11EventFilter)(XEvent*); |
145 extern QX11EventFilter qt_set_x11_event_filter (QX11EventFilter filter); | 146 extern QX11EventFilter qt_set_x11_event_filter(QX11EventFilter filter); |
146 static QX11EventFilter oldFilter = 0; | 147 static QX11EventFilter oldFilter = 0; |
147 static int kvim_x11_event_filter( XEvent* e); | 148 static int kvim_x11_event_filter(XEvent* e); |
148 #endif | 149 #endif |
149 void gui_keypress(QKeyEvent *e); | 150 void gui_keypress(QKeyEvent *e); |
150 | 151 |
151 /* | 152 /* |
152 * Return OK if the key with the termcap name "name" is supported. | 153 * Return OK if the key with the termcap name "name" is supported. |
153 */ | 154 */ |
154 int | 155 int |
162 }//}}} | 163 }//}}} |
163 | 164 |
164 /* | 165 /* |
165 * custom Frame for drawing ... | 166 * custom Frame for drawing ... |
166 */ | 167 */ |
167 void VimWidget::paintEvent(QPaintEvent *e)//{{{ | 168 void |
169 VimWidget::paintEvent(QPaintEvent *e)//{{{ | |
168 { | 170 { |
169 QRect r = e->rect(); | 171 QRect r = e->rect(); |
170 gui_redraw(r.x(), r.y(), r.width(), r.height()); | 172 gui_redraw(r.x(), r.y(), r.width(), r.height()); |
171 }//}}} | 173 }//}}} |
172 | 174 |
173 void VimWidget::draw_string(int x, int y, QString s, int len, int flags)//{{{ | 175 void |
176 VimWidget::draw_string(int x, int y, QString s, int len, int flags)//{{{ | |
174 { | 177 { |
175 gui.current_font->setBold(flags & DRAW_BOLD); | 178 gui.current_font->setBold(flags & DRAW_BOLD); |
176 gui.current_font->setUnderline(flags & DRAW_UNDERL); | 179 gui.current_font->setUnderline(flags & DRAW_UNDERL); |
177 gui.current_font->setItalic(flags & DRAW_ITALIC); | 180 gui.current_font->setItalic(flags & DRAW_ITALIC); |
178 painter->setBackgroundMode(flags & DRAW_TRANSP ? Qt::TransparentMode : Qt::OpaqueMode); | 181 painter->setBackgroundMode(flags & DRAW_TRANSP |
182 ? Qt::TransparentMode : Qt::OpaqueMode); | |
179 painter->setFont(*(gui.current_font)); | 183 painter->setFont(*(gui.current_font)); |
180 painter->drawText(x, y, s, len); | 184 painter->drawText(x, y, s, len); |
181 }//}}} | 185 }//}}} |
182 | 186 |
183 void VimWidget::mousePressEvent(QMouseEvent *event)//{{{ | 187 void |
184 { | 188 VimWidget::mousePressEvent(QMouseEvent *event)//{{{ |
185 int button=0; | 189 { |
186 int modifiers=0; | 190 int button = 0; |
191 int modifiers = 0; | |
187 ButtonState state = event->state(); | 192 ButtonState state = event->state(); |
188 ButtonState buttons = event->button(); | 193 ButtonState buttons = event->button(); |
189 | 194 |
190 //Look at button states | 195 //Look at button states |
191 if (buttons & QMouseEvent::LeftButton) | 196 if (buttons & QMouseEvent::LeftButton) |
199 modifiers |= MOUSE_SHIFT; | 204 modifiers |= MOUSE_SHIFT; |
200 if (state & QMouseEvent::ControlButton) | 205 if (state & QMouseEvent::ControlButton) |
201 modifiers |= MOUSE_CTRL; | 206 modifiers |= MOUSE_CTRL; |
202 if (state & QMouseEvent::AltButton) | 207 if (state & QMouseEvent::AltButton) |
203 modifiers |= MOUSE_ALT; | 208 modifiers |= MOUSE_ALT; |
204 gui_send_mouse_event(button,event->x(),event->y(),FALSE,modifiers); | 209 gui_send_mouse_event(button, event->x(), event->y(), FALSE, modifiers); |
205 #if QT_VERSION>=300 | 210 #if QT_VERSION>=300 |
206 QByteArray params; | 211 QByteArray params; |
207 QDataStream stream(params, IO_WriteOnly); | 212 QDataStream stream(params, IO_WriteOnly); |
208 stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col; | 213 stream << kapp->dcopClient()->appId() << button << modifiers |
209 kapp->dcopClient()->emitDCOPSignal("mousePEvent(QCString,int,int,int,int)", params); | 214 << gui.row << gui.col; |
215 kapp->dcopClient()->emitDCOPSignal( | |
216 "mousePEvent(QCString, int, int, int, int)", params); | |
210 #endif | 217 #endif |
211 event->accept(); | 218 event->accept(); |
212 }//}}} | 219 }//}}} |
213 | 220 |
214 #if defined(FEAT_SESSION) | 221 #if defined(FEAT_SESSION) |
215 void VimMainWindow::saveGlobalProperties (KConfig *conf) | 222 void |
223 VimMainWindow::saveGlobalProperties(KConfig *conf) | |
216 { | 224 { |
217 //we write a mksession file to a file written in the user's ~/.kde/share/config/ | 225 //we write a mksession file to a file written in the user's ~/.kde/share/config/ |
218 //the name of the file in saved in 'conf' | 226 //the name of the file in saved in 'conf' |
219 //when restoring app, we source this file | 227 //when restoring app, we source this file |
220 #if 0 //disabled for release | 228 #if 0 //disabled for release |
225 conf->writePathEntry("sessionfile", filename); | 233 conf->writePathEntry("sessionfile", filename); |
226 conf->sync(); | 234 conf->sync(); |
227 #endif | 235 #endif |
228 } | 236 } |
229 | 237 |
230 void VimMainWindow::readGlobalProperties (KConfig *conf) | 238 void |
239 VimMainWindow::readGlobalProperties (KConfig *conf) | |
231 { | 240 { |
232 #if 0 | 241 #if 0 |
233 QString filename = conf->readPathEntry("sessionfile"); | 242 QString filename = conf->readPathEntry("sessionfile"); |
234 if (filename.isNull()) return; | 243 if (filename.isNull()) return; |
235 QString cmd("source "); | 244 QString cmd("source "); |
237 do_cmdline_cmd((char_u*)cmd.latin1()); | 246 do_cmdline_cmd((char_u*)cmd.latin1()); |
238 #endif | 247 #endif |
239 } | 248 } |
240 #endif | 249 #endif |
241 | 250 |
242 void VimMainWindow::wheelEvent (QWheelEvent *event)//{{{ | 251 void |
252 VimMainWindow::wheelEvent (QWheelEvent *event)//{{{ | |
243 { | 253 { |
244 ButtonState state = event->state(); | 254 ButtonState state = event->state(); |
245 int button=0; | 255 int button = 0; |
246 int modifiers=0; | 256 int modifiers = 0; |
247 | 257 |
248 if (event->delta()>0) | 258 if (event->delta() > 0) |
249 button|=MOUSE_4; | 259 button |= MOUSE_4; |
250 else button|=MOUSE_5; | 260 else button |= MOUSE_5; |
251 | 261 |
252 if (state & ShiftButton) | 262 if (state & ShiftButton) |
253 modifiers|=MOUSE_SHIFT; | 263 modifiers |= MOUSE_SHIFT; |
254 if (state & ControlButton) | 264 if (state & ControlButton) |
255 modifiers|=MOUSE_CTRL; | 265 modifiers |= MOUSE_CTRL; |
256 if (state & AltButton) | 266 if (state & AltButton) |
257 modifiers|=MOUSE_ALT; | 267 modifiers |= MOUSE_ALT; |
258 | 268 |
259 gui_send_mouse_event(button,event->x(),event->y(),FALSE,modifiers); | 269 gui_send_mouse_event(button, event->x(), event->y(), FALSE, modifiers); |
260 #if QT_VERSION>=300 | 270 #if QT_VERSION>=300 |
261 QByteArray params; | 271 QByteArray params; |
262 QDataStream stream(params, IO_WriteOnly); | 272 QDataStream stream(params, IO_WriteOnly); |
263 stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col; | 273 stream << kapp->dcopClient()->appId() << button << modifiers |
264 kapp->dcopClient()->emitDCOPSignal("mouseWhlEvent(QCString, int, int,int,int)", params); | 274 << gui.row << gui.col; |
275 kapp->dcopClient()->emitDCOPSignal( | |
276 "mouseWhlEvent(QCString, int, int, int, int)", params); | |
265 #endif | 277 #endif |
266 event->accept(); | 278 event->accept(); |
267 }//}}} | 279 }//}}} |
268 | 280 |
269 void VimWidget::mouseDoubleClickEvent(QMouseEvent *event)//{{{ | 281 void |
282 VimWidget::mouseDoubleClickEvent(QMouseEvent *event)//{{{ | |
270 { | 283 { |
271 ButtonState state = event->state(); | 284 ButtonState state = event->state(); |
272 ButtonState buttons = event->button(); | 285 ButtonState buttons = event->button(); |
273 int modifiers=0; | 286 int modifiers = 0; |
274 int button=0; | 287 int button = 0; |
275 | 288 |
276 //Look at button states | 289 //Look at button states |
277 if (buttons & LeftButton) | 290 if (buttons & LeftButton) |
278 button|=MOUSE_LEFT; | 291 button |= MOUSE_LEFT; |
279 if (buttons & RightButton) | 292 if (buttons & RightButton) |
280 button|=MOUSE_RIGHT; | 293 button |= MOUSE_RIGHT; |
281 if (buttons & MidButton) | 294 if (buttons & MidButton) |
282 button|=MOUSE_MIDDLE; | 295 button |= MOUSE_MIDDLE; |
283 | 296 |
284 //Look for keyboard modifiers | 297 //Look for keyboard modifiers |
285 if (state & ShiftButton) | 298 if (state & ShiftButton) |
286 modifiers|=MOUSE_SHIFT; | 299 modifiers |= MOUSE_SHIFT; |
287 if (state & ControlButton) | 300 if (state & ControlButton) |
288 modifiers|=MOUSE_CTRL; | 301 modifiers |= MOUSE_CTRL; |
289 if (state & AltButton) | 302 if (state & AltButton) |
290 modifiers|=MOUSE_ALT; | 303 modifiers |= MOUSE_ALT; |
291 | 304 |
292 gui_send_mouse_event(button,event->x(),event->y(),TRUE,modifiers); | 305 gui_send_mouse_event(button, event->x(), event->y(), TRUE, modifiers); |
293 #if QT_VERSION>=300 | 306 #if QT_VERSION>=300 |
294 QByteArray params; | 307 QByteArray params; |
295 QDataStream stream(params, IO_WriteOnly); | 308 QDataStream stream(params, IO_WriteOnly); |
296 stream << kapp->dcopClient()->appId() << button << modifiers << gui.row << gui.col; | 309 stream << kapp->dcopClient()->appId() << button << modifiers |
297 kapp->dcopClient()->emitDCOPSignal("mouseDblClickEvent(QCString, int, int,int,int)", params); | 310 << gui.row << gui.col; |
311 kapp->dcopClient()->emitDCOPSignal( | |
312 "mouseDblClickEvent(QCString, int, int, int, int)", params); | |
298 #endif | 313 #endif |
299 event->accept(); | 314 event->accept(); |
300 }//}}} | 315 }//}}} |
301 | 316 |
302 void VimWidget::mouseMoveEvent(QMouseEvent *event){//{{{ | 317 void |
318 VimWidget::mouseMoveEvent(QMouseEvent *event)//{{{ | |
319 { | |
303 ButtonState state = event->state(); | 320 ButtonState state = event->state(); |
304 int modifiers=0; | 321 int modifiers = 0; |
305 int button=0; | 322 int button = 0; |
306 | 323 |
307 gui_mch_mousehide(FALSE); | 324 gui_mch_mousehide(FALSE); |
308 | 325 |
309 //Look at button states | 326 //Look at button states |
310 //warning: we use state here, this is important ! | 327 //warning: we use state here, this is important ! |
311 if (state & QMouseEvent::LeftButton || state & QMouseEvent::RightButton || state & QMouseEvent::MidButton) | 328 if (state & QMouseEvent::LeftButton |
312 button|=MOUSE_DRAG; | 329 || state & QMouseEvent::RightButton |
330 || state & QMouseEvent::MidButton) | |
331 button |= MOUSE_DRAG; | |
313 | 332 |
314 //Look for keyboard modifiers | 333 //Look for keyboard modifiers |
315 if (state & ShiftButton) | 334 if (state & ShiftButton) |
316 modifiers|=MOUSE_SHIFT; | 335 modifiers |= MOUSE_SHIFT; |
317 if (state & ControlButton) | 336 if (state & ControlButton) |
318 modifiers|=MOUSE_CTRL; | 337 modifiers |= MOUSE_CTRL; |
319 if (state & AltButton) | 338 if (state & AltButton) |
320 modifiers|=MOUSE_ALT; | 339 modifiers |= MOUSE_ALT; |
321 if (button!=MOUSE_DRAG) | 340 if (button != MOUSE_DRAG) |
322 gui_mouse_moved(event->x(),event->y()); | 341 gui_mouse_moved(event->x(), event->y()); |
323 else | 342 else |
324 gui_send_mouse_event(MOUSE_DRAG,event->x(),event->y(),FALSE,modifiers); | 343 gui_send_mouse_event(MOUSE_DRAG, event->x(), event->y(), |
325 }//}}} | 344 FALSE, modifiers); |
326 | 345 }//}}} |
327 void VimWidget::mouseReleaseEvent(QMouseEvent *event)//{{{ | 346 |
347 void | |
348 VimWidget::mouseReleaseEvent(QMouseEvent *event)//{{{ | |
328 { | 349 { |
329 ButtonState state = event->state(); | 350 ButtonState state = event->state(); |
330 int modifiers=0; | 351 int modifiers = 0; |
331 | 352 |
332 //Look for keyboard modifiers | 353 //Look for keyboard modifiers |
333 if (state & ShiftButton) | 354 if (state & ShiftButton) |
334 modifiers|=MOUSE_SHIFT; | 355 modifiers |= MOUSE_SHIFT; |
335 if (state & ControlButton) | 356 if (state & ControlButton) |
336 modifiers|=MOUSE_CTRL; | 357 modifiers |= MOUSE_CTRL; |
337 if (state & AltButton) | 358 if (state & AltButton) |
338 modifiers|=MOUSE_ALT; | 359 modifiers |= MOUSE_ALT; |
339 | 360 |
340 gui_send_mouse_event(MOUSE_RELEASE,event->x(),event->y(),FALSE,modifiers); | 361 gui_send_mouse_event(MOUSE_RELEASE, event->x(), event->y(), |
362 FALSE, modifiers); | |
341 event->accept(); | 363 event->accept(); |
342 }//}}} | 364 }//}}} |
343 | 365 |
344 /* | 366 /* |
345 * The main widget (everything but toolbar/menubar) | 367 * The main widget (everything but toolbar/menubar) |
346 */ | 368 */ |
347 VimWidget::VimWidget( QWidget *parent, const char *name, WFlags f )//{{{ | 369 VimWidget::VimWidget(QWidget *parent, const char *name, WFlags f)//{{{ |
348 :QWidget(parent, name, f) | 370 :QWidget(parent, name, f) |
349 ,DCOPObject("KVim") | 371 , DCOPObject("KVim") |
350 #ifdef FEAT_MZSCHEME | 372 #ifdef FEAT_MZSCHEME |
351 ,mzscheme_timer_id(-1) | 373 , mzscheme_timer_id(-1) |
352 #endif | 374 #endif |
353 { | 375 { |
354 //to be able to show/hide the cursor when moving the mouse | 376 //to be able to show/hide the cursor when moving the mouse |
355 setMouseTracking(true); | 377 setMouseTracking(true); |
356 painter=new QPainter(this); | 378 painter = new QPainter(this); |
357 | 379 |
358 setKeyCompression(true); | 380 setKeyCompression(true); |
359 setFocusPolicy( QWidget::StrongFocus ); | 381 setFocusPolicy(QWidget::StrongFocus); |
360 setAcceptDrops(TRUE); // DND | 382 setAcceptDrops(TRUE); // DND |
361 blink_state = BLINK_NONE; | 383 blink_state = BLINK_NONE; |
362 blink_on_time = 700; | 384 blink_on_time = 700; |
363 blink_off_time = 400; | 385 blink_off_time = 400; |
364 blink_wait_time = 250; | 386 blink_wait_time = 250; |
365 connect( &blink_timer, SIGNAL( timeout() ), SLOT( blink_cursor() )); | 387 connect( &blink_timer, SIGNAL(timeout()), SLOT(blink_cursor())); |
366 connect( &wait_timer, SIGNAL( timeout() ), SLOT ( wait_timeout() )); | 388 connect( &wait_timer, SIGNAL(timeout()), SLOT(wait_timeout())); |
367 }//}}} | 389 setInputMethodEnabled(true); |
368 | 390 }//}}} |
369 void VimWidget::execNormal(QString command)//{{{ | 391 |
392 void | |
393 VimWidget::execNormal(QString command)//{{{ | |
370 { | 394 { |
371 QString cmd("execute 'normal "); | 395 QString cmd("execute 'normal "); |
372 cmd+=command; | 396 cmd += command; |
373 cmd+="'"; | 397 cmd += "'"; |
374 QCString unistring = vmw->codec->fromUnicode(cmd); | 398 QCString unistring = vmw->codec->fromUnicode(cmd); |
375 do_cmdline_cmd((char_u *)(const char*)unistring); | 399 do_cmdline_cmd((char_u *)(const char*)unistring); |
376 gui_update_screen(); | 400 gui_update_screen(); |
377 }//}}} | 401 }//}}} |
378 | 402 |
379 void VimWidget::execInsert(QString command)//{{{ | 403 void |
404 VimWidget::execInsert(QString command)//{{{ | |
380 { | 405 { |
381 QString cmd("execute 'normal i"); | 406 QString cmd("execute 'normal i"); |
382 cmd+=command; | 407 cmd += command; |
383 cmd+="'"; | 408 cmd += "'"; |
384 QCString unistring = vmw->codec->fromUnicode(cmd); | 409 QCString unistring = vmw->codec->fromUnicode(cmd); |
385 do_cmdline_cmd((char_u *)(const char*)unistring); | 410 do_cmdline_cmd((char_u *)(const char*)unistring); |
386 gui_update_screen(); | 411 gui_update_screen(); |
387 }//}}} | 412 }//}}} |
388 | 413 |
389 void VimWidget::execRaw(QString command)//{{{ | 414 void |
415 VimWidget::execRaw(QString command)//{{{ | |
390 { | 416 { |
391 QString cmd("execute '"); | 417 QString cmd("execute '"); |
392 cmd+=command; | 418 cmd += command; |
393 cmd+="'"; | 419 cmd += "'"; |
394 QCString unistring = vmw->codec->fromUnicode(cmd); | 420 QCString unistring = vmw->codec->fromUnicode(cmd); |
395 do_cmdline_cmd((char_u *)(const char*)unistring); | 421 do_cmdline_cmd((char_u *)(const char*)unistring); |
396 gui_update_screen(); | 422 gui_update_screen(); |
397 }//}}} | 423 }//}}} |
398 | 424 |
399 void VimWidget::execCmd(QString command)//{{{ | 425 void |
426 VimWidget::execCmd(QString command)//{{{ | |
400 { | 427 { |
401 QCString unistring = vmw->codec->fromUnicode(command); | 428 QCString unistring = vmw->codec->fromUnicode(command); |
402 do_cmdline_cmd((char_u *)(const char*)unistring); | 429 do_cmdline_cmd((char_u *)(const char*)unistring); |
403 gui_update_screen(); | 430 gui_update_screen(); |
404 }//}}} | 431 }//}}} |
405 | 432 |
406 QString VimWidget::eval(QString expr)//{{{ | 433 QString |
434 VimWidget::eval(QString expr)//{{{ | |
407 { | 435 { |
408 #ifdef FEAT_EVAL | 436 #ifdef FEAT_EVAL |
409 QCString unistring = vmw->codec->fromUnicode(expr); | 437 QCString unistring = vmw->codec->fromUnicode(expr); |
410 QString val((const char *)eval_to_string((char_u *)(const char*)unistring,NULL)); | 438 QString val((const char *)eval_to_string( |
439 (char_u *)(const char*)unistring, NULL)); | |
411 return val; | 440 return val; |
412 #else | 441 #else |
413 return QString::null; | 442 return QString::null; |
414 #endif | 443 #endif |
415 }//}}} | 444 }//}}} |
416 | 445 |
417 void VimWidget::wait(long wtime)//{{{ | 446 void |
418 { | 447 VimWidget::wait(long wtime)//{{{ |
419 if ( wait_timer.isActive() ) wait_timer.stop(); | 448 { |
449 if (wait_timer.isActive()) | |
450 wait_timer.stop(); | |
420 wait_done = false; | 451 wait_done = false; |
421 wait_timer.start( wtime, true); | 452 wait_timer.start( wtime, true); |
422 }//}}} | 453 }//}}} |
423 | 454 |
424 void VimWidget::wait_timeout() //{{{ | 455 void |
456 VimWidget::wait_timeout() //{{{ | |
425 { | 457 { |
426 wait_done = true; | 458 wait_done = true; |
427 }//}}} | 459 }//}}} |
428 | 460 |
429 void VimWidget::dragEnterEvent (QDragEnterEvent *e)//{{{ | 461 void |
462 VimWidget::dragEnterEvent (QDragEnterEvent *e)//{{{ | |
430 { | 463 { |
431 #if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO) | 464 #if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO) |
432 e->accept(QUriDrag::canDecode(e)); | 465 e->accept(QUriDrag::canDecode(e)); |
433 #else | 466 #else |
434 e->ignore(); | 467 e->ignore(); |
435 #endif | 468 #endif |
436 }//}}} | 469 }//}}} |
437 | 470 |
438 void VimWidget::dropEvent (QDropEvent *e) // {{{ | 471 void |
472 VimWidget::dropEvent(QDropEvent *e) // {{{ | |
439 { | 473 { |
440 #if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO) | 474 #if (defined(FEAT_WINDOWS) && defined(HAVE_DROP_FILE)) || defined(PROTO) |
441 QStrList urls; | 475 QStrList urls; |
442 | 476 |
443 char_u **fnames; | 477 char_u **fnames; |
444 int redo_dirs = FALSE; | 478 int redo_dirs = FALSE; |
445 int i; | 479 int i; |
446 int n; | 480 int n; |
450 /* Count how many items there may be and normalize delimiters. */ | 484 /* Count how many items there may be and normalize delimiters. */ |
451 | 485 |
452 if (QUriDrag::decode(e, urls)) | 486 if (QUriDrag::decode(e, urls)) |
453 { | 487 { |
454 n = urls.count(); | 488 n = urls.count(); |
455 fnames = (char_u **)lalloc((n+1) * sizeof(char_u *), TRUE); | 489 fnames = (char_u **)lalloc((n+1) * sizeof(char_u *), TRUE); |
456 nfiles = 0; | 490 nfiles = 0; |
457 #if QT_VERSION>=300 | 491 #if QT_VERSION>=300 |
458 QPtrListIterator<char> it(urls); | 492 QPtrListIterator<char> it(urls); |
459 for (; it.current(); ++it ) | 493 for (; it.current(); ++it) |
460 { | 494 { |
461 KURL u(*it); | 495 KURL u(*it); |
462 #else | 496 #else |
463 for (i=0;i<urls.count();++i) | 497 for (i = 0; i < urls.count(); ++i) |
464 { | 498 { |
465 KURL u(urls.at(i)); | 499 KURL u(urls.at(i)); |
466 #endif | 500 #endif |
467 if ( !u.isLocalFile() ) | 501 if (!u.isLocalFile()) |
468 url = TRUE; | 502 url = TRUE; |
469 else | 503 else |
470 { | 504 { |
471 fnames[nfiles] = (char_u *)strdup((const char *)u.path()); | 505 fnames[nfiles] = (char_u *)strdup((const char *)u.path()); |
472 ++nfiles; | 506 ++nfiles; |
509 } | 543 } |
510 else | 544 else |
511 { | 545 { |
512 char_u dirname[MAXPATHL]; | 546 char_u dirname[MAXPATHL]; |
513 char_u *s; | 547 char_u *s; |
548 | |
514 if (mch_dirname(dirname, MAXPATHL) == OK) | 549 if (mch_dirname(dirname, MAXPATHL) == OK) |
515 for (i = 0; i < nfiles; ++i) | 550 for (i = 0; i < nfiles; ++i) |
516 if (fnames[i] != NULL) | 551 if (fnames[i] != NULL) |
517 { | 552 { |
518 s = shorten_fname(fnames[i], dirname); | 553 s = shorten_fname(fnames[i], dirname); |
542 gui_update_cursor(FALSE, FALSE); | 577 gui_update_cursor(FALSE, FALSE); |
543 gui_mch_flush(); | 578 gui_mch_flush(); |
544 #endif | 579 #endif |
545 } // }}} | 580 } // }}} |
546 | 581 |
547 void VimWidget::keyPressEvent( QKeyEvent *e ) // {{{ | 582 void |
583 VimWidget::keyPressEvent(QKeyEvent *e) // {{{ | |
548 { | 584 { |
549 gui_keypress(e); | 585 gui_keypress(e); |
550 } // }}} | 586 } // }}} |
551 | 587 |
552 void gui_keypress(QKeyEvent *e) { // {{{ | 588 void |
553 int key = (int)e->key(); | 589 gui_keypress(QKeyEvent *e) // {{{ |
554 int modifiers = 0,i; | 590 { |
555 uchar string[256],string2[256]; | 591 int key = (int)e->key(); |
556 uchar *s,*d; | 592 int modifiers = 0, i; |
593 uchar string[256], string2[256]; | |
594 uchar *s, *d; | |
557 Qt::ButtonState state = e->state(); | 595 Qt::ButtonState state = e->state(); |
558 | 596 |
559 QCString unistring = vmw->codec->fromUnicode(e->text()); | 597 QCString unistring = vmw->codec->fromUnicode(e->text()); |
560 if (unistring.length()>0) | 598 if (unistring.length() > 0) |
561 strncpy((char*)string, (const char*)unistring,unistring.length()); | 599 strncpy((char*)string, (const char*)unistring, unistring.length()); |
562 string[unistring.length()] = 0; | 600 string[unistring.length()] = 0; |
563 int len=unistring.length(); | 601 int len = unistring.length(); |
564 | 602 |
565 // ignore certain keys | 603 // ignore certain keys |
566 if (key == Qt::Key_Shift || key == Qt::Key_Alt || key == Qt::Key_Control || key == Qt::Key_Meta | 604 if (key == Qt::Key_Shift |
567 || key == Qt::Key_CapsLock || key == Qt::Key_NumLock || key == Qt::Key_ScrollLock ) | 605 || key == Qt::Key_Alt |
606 || key == Qt::Key_Control | |
607 || key == Qt::Key_Meta | |
608 || key == Qt::Key_CapsLock | |
609 || key == Qt::Key_NumLock | |
610 || key == Qt::Key_ScrollLock) | |
568 { | 611 { |
569 e->ignore(); | 612 e->ignore(); |
570 return; | 613 return; |
571 } | 614 } |
572 | 615 |
593 } | 636 } |
594 len = d - string; | 637 len = d - string; |
595 | 638 |
596 | 639 |
597 // change shift-tab (backtab) into S_TAB | 640 // change shift-tab (backtab) into S_TAB |
598 if ( key == Qt::Key_BackTab && state & Qt::ShiftButton) | 641 if (key == Qt::Key_BackTab && state & Qt::ShiftButton) |
599 key = Qt::Key_Tab; | 642 key = Qt::Key_Tab; |
600 | 643 |
601 // Change C-@ and C-2 in NUL ? Gtk does this | 644 // Change C-@ and C-2 in NUL ? Gtk does this |
602 if ( (key == Qt::Key_2 || key == Qt::Key_At) | 645 if ((key == Qt::Key_2 || key == Qt::Key_At) && state & Qt::ControlButton) |
603 && state & Qt::ControlButton ) | |
604 { | 646 { |
605 string[0] = NUL; | 647 string[0] = NUL; |
606 len = 1; | 648 len = 1; |
607 } | 649 } |
608 else if (len == 0 && (key == Qt::Key_Space || key == Qt::Key_Tab)) | 650 else if (len == 0 && (key == Qt::Key_Space || key == Qt::Key_Tab)) |
640 } | 682 } |
641 | 683 |
642 /* Check for special keys, making sure BS and DEL are recognised. */ | 684 /* Check for special keys, making sure BS and DEL are recognised. */ |
643 if (len == 0 || key == Qt::Key_BackSpace || key == Qt::Key_Delete) | 685 if (len == 0 || key == Qt::Key_BackSpace || key == Qt::Key_Delete) |
644 { | 686 { |
645 while (special_keys[i].qtkey != 0 && special_keys[i].qtkey != key ) i++; | 687 while (special_keys[i].qtkey != 0 && special_keys[i].qtkey != key) |
688 i++; | |
646 if (special_keys[i].qtkey != 0) | 689 if (special_keys[i].qtkey != 0) |
647 { | 690 { |
648 string[0] = CSI; | 691 string[0] = CSI; |
649 string[1] = special_keys[i].code0; | 692 string[1] = special_keys[i].code0; |
650 string[2] = special_keys[i].code1; | 693 string[2] = special_keys[i].code1; |
651 len = -3; | 694 len = -3; |
652 } | 695 } |
653 /* | 696 /* |
654 for (i = 0; special_keys[i].qtkey != 0 ; i++) | 697 for (i = 0; special_keys[i].qtkey != 0 ; i++) |
655 { | 698 { |
656 if (special_keys[i].qtkey == key ) | 699 if (special_keys[i].qtkey == key ) |
672 return; | 715 return; |
673 } | 716 } |
674 | 717 |
675 | 718 |
676 /* Special keys (and a few others) may have modifiers */ | 719 /* Special keys (and a few others) may have modifiers */ |
677 if (len == -3 || key == Qt::Key_Space || key == Qt::Key_Tab || | 720 if (len == -3 |
678 key == Qt::Key_Return || key == Qt::Key_Enter || | 721 || key == Qt::Key_Space |
679 key == Qt::Key_Escape) | 722 || key == Qt::Key_Tab |
680 { | 723 || key == Qt::Key_Return |
681 | 724 || key == Qt::Key_Enter |
725 || key == Qt::Key_Escape) | |
726 { | |
682 modifiers = 0; | 727 modifiers = 0; |
683 if (state & Qt::ShiftButton) modifiers |= MOD_MASK_SHIFT; | 728 if (state & Qt::ShiftButton) |
684 if (state & Qt::ControlButton) modifiers |= MOD_MASK_CTRL; | 729 modifiers |= MOD_MASK_SHIFT; |
685 if (state & Qt::AltButton) modifiers |= MOD_MASK_ALT; | 730 if (state & Qt::ControlButton) |
731 modifiers |= MOD_MASK_CTRL; | |
732 if (state & Qt::AltButton) | |
733 modifiers |= MOD_MASK_ALT; | |
686 | 734 |
687 /* | 735 /* |
688 * For some keys a shift modifier is translated into another key | 736 * For some keys a shift modifier is translated into another key |
689 * code. Do we need to handle the case where len != 1 and | 737 * code. Do we need to handle the case where len != 1 and |
690 * string[0] != CSI? | 738 * string[0] != CSI? |
693 key = TO_SPECIAL(string[1], string[2]); | 741 key = TO_SPECIAL(string[1], string[2]); |
694 else | 742 else |
695 key = string[0]; | 743 key = string[0]; |
696 | 744 |
697 key = simplify_key(key, &modifiers); | 745 key = simplify_key(key, &modifiers); |
698 if (key == CSI) key=K_CSI; | 746 if (key == CSI) |
747 key = K_CSI; | |
699 | 748 |
700 if (IS_SPECIAL(key)) | 749 if (IS_SPECIAL(key)) |
701 { | 750 { |
702 string[0] = CSI; | 751 string[0] = CSI; |
703 string[1] = K_SECOND(key); | 752 string[1] = K_SECOND(key); |
708 { | 757 { |
709 string[0] = key; | 758 string[0] = key; |
710 len = 1; | 759 len = 1; |
711 } | 760 } |
712 | 761 |
713 | 762 if (modifiers != 0) |
714 if (modifiers!=0) | |
715 { | 763 { |
716 uchar string2[10]; | 764 uchar string2[10]; |
717 string2[0] = CSI; | 765 string2[0] = CSI; |
718 string2[1] = KS_MODIFIER; | 766 string2[1] = KS_MODIFIER; |
719 string2[2] = modifiers; | 767 string2[2] = modifiers; |
721 } | 769 } |
722 | 770 |
723 } /* special keys */ | 771 } /* special keys */ |
724 | 772 |
725 if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts) | 773 if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts) |
726 || (string[0] == intr_char && intr_char != Ctrl_C))) | 774 || (string[0] == intr_char && intr_char != Ctrl_C))) |
727 { | 775 { |
728 trash_input_buf(); | 776 trash_input_buf(); |
729 got_int = TRUE; | 777 got_int = TRUE; |
730 } | 778 } |
731 | 779 |
746 // i'll do the same for mouseEvents | 794 // i'll do the same for mouseEvents |
747 #if QT_VERSION>=300 | 795 #if QT_VERSION>=300 |
748 QByteArray params; | 796 QByteArray params; |
749 QDataStream stream(params, IO_WriteOnly); | 797 QDataStream stream(params, IO_WriteOnly); |
750 stream << kapp->dcopClient()->appId() << unistring << gui.row << gui.col; | 798 stream << kapp->dcopClient()->appId() << unistring << gui.row << gui.col; |
751 kapp->dcopClient()->emitDCOPSignal("keyboardEvent(QCString, QCString,int,int)", params); | 799 kapp->dcopClient()->emitDCOPSignal( |
800 "keyboardEvent(QCString, QCString, int, int)", params); | |
752 #endif | 801 #endif |
753 e->ignore(); | 802 e->ignore(); |
754 } // }}} | 803 } // }}} |
755 | 804 |
756 #ifdef FEAT_CLIENTSERVER | 805 #ifdef FEAT_CLIENTSERVER |
757 void VimWidget::serverActivate(WId id) //{{{ | 806 void |
807 VimWidget::serverActivate(WId id) //{{{ | |
758 { | 808 { |
759 if (serverName == NULL && serverDelayedStartName != NULL) | 809 if (serverName == NULL && serverDelayedStartName != NULL) |
760 { | 810 { |
761 commWindow = id; | 811 commWindow = id; |
762 (void)serverRegisterName(qt_xdisplay(), serverDelayedStartName); | 812 (void)serverRegisterName(qt_xdisplay(), serverDelayedStartName); |
765 serverChangeRegisteredWindow( qt_xdisplay(), id); | 815 serverChangeRegisteredWindow( qt_xdisplay(), id); |
766 }//}}} | 816 }//}}} |
767 #endif | 817 #endif |
768 | 818 |
769 #ifdef FEAT_XIM | 819 #ifdef FEAT_XIM |
770 void VimWidget::imStartEvent(QIMEvent *e) | 820 |
771 { | 821 static int preedit_buf_len = 0; |
822 static int im_preedit_cursor = 0; | |
823 static int im_preedit_trailing = 0; | |
824 | |
825 static void | |
826 im_delete_preedit(void) | |
827 { | |
828 char_u bskey[] = {CSI, 'k', 'b'}; | |
829 char_u delkey[] = {CSI, 'k', 'D'}; | |
830 | |
831 if (State & NORMAL) | |
832 { | |
833 im_preedit_cursor = 0; | |
834 return; | |
835 } | |
836 for (; im_preedit_cursor > 0; --im_preedit_cursor) | |
837 add_to_input_buf(bskey, (int)sizeof(bskey)); | |
838 | |
839 for (; im_preedit_trailing > 0; --im_preedit_trailing) | |
840 add_to_input_buf(delkey, (int)sizeof(delkey)); | |
841 } | |
842 | |
843 void | |
844 im_set_position(int row, int col) | |
845 { | |
846 vmw->w->setMicroFocusHint( | |
847 TEXT_X(gui.col), | |
848 TEXT_Y(gui.row), 0, 0, TRUE, &vmw->w->font()); | |
849 } | |
850 | |
851 int | |
852 im_is_preediting() | |
853 { | |
854 return (preedit_start_col != MAXCOL); | |
855 } | |
856 | |
857 int | |
858 im_get_feedback_attr(int col) | |
859 { | |
860 if (draw_feedback != NULL && col < preedit_buf_len) | |
861 { | |
862 if (draw_feedback[col] & XIMReverse) | |
863 return HL_INVERSE; | |
864 else if (draw_feedback[col] & XIMUnderline) | |
865 return HL_UNDERLINE; | |
866 else | |
867 return hl_attr(HLF_V); | |
868 } | |
869 | |
870 return -1; | |
871 } | |
872 | |
873 void | |
874 VimWidget::imStartEvent(QIMEvent *e) | |
875 { | |
876 if (State & CMDLINE) | |
877 preedit_start_col = cmdline_getvcol_cursor(); | |
878 else if (curwin != NULL) | |
879 getvcol(curwin, &curwin->w_cursor, &preedit_start_col, NULL, NULL); | |
880 xic = (XIC)!NULL; | |
772 e->accept(); | 881 e->accept(); |
773 } | 882 } |
774 | 883 |
775 void VimWidget::imEndEvent(QIMEvent *e) | 884 void |
885 VimWidget::imEndEvent(QIMEvent *e) | |
776 { | 886 { |
777 uchar string[256]; | 887 uchar string[256]; |
778 | 888 |
889 im_delete_preedit(); | |
890 | |
779 QCString unistring = vmw->codec->fromUnicode(e->text()); | 891 QCString unistring = vmw->codec->fromUnicode(e->text()); |
780 if (unistring.length()>0) | 892 if (unistring.length() > 0) |
893 strncpy((char*)string, (const char*)unistring, unistring.length()); | |
894 string[unistring.length()] = 0; | |
895 int len = unistring.length(); | |
896 | |
897 add_to_input_buf_csi(string, len); | |
898 im_preedit_cursor = 0; | |
899 im_preedit_trailing = 0; | |
900 preedit_start_col = MAXCOL; | |
901 preedit_buf_len = 0; | |
902 if (draw_feedback) | |
903 { | |
904 free(draw_feedback); | |
905 draw_feedback = NULL; | |
906 } | |
907 xic = 0; | |
908 e->accept(); | |
909 } | |
910 | |
911 void | |
912 VimWidget::imComposeEvent(QIMEvent *e) | |
913 { | |
914 uchar string[256]; | |
915 char_u backkey[] = {CSI, 'k', 'l'}; | |
916 | |
917 im_delete_preedit(); | |
918 | |
919 if (State & NORMAL) | |
920 { | |
921 im_preedit_cursor = 0; | |
922 return; | |
923 } | |
924 | |
925 QCString unistring = vmw->codec->fromUnicode(e->text()); | |
926 if (unistring.length() > 0) | |
781 strncpy((char*)string, (const char*)unistring,unistring.length()); | 927 strncpy((char*)string, (const char*)unistring,unistring.length()); |
782 string[unistring.length()] = 0; | 928 string[unistring.length()] = 0; |
783 int len=unistring.length(); | 929 int len = unistring.length(); |
784 | 930 add_to_input_buf_csi(string, len); |
785 add_to_input_buf(string, len); | 931 |
932 preedit_buf_len = e->text().length(); | |
933 if (draw_feedback == NULL) | |
934 draw_feedback = (char *)alloc(preedit_buf_len); | |
935 else | |
936 draw_feedback = (char *)realloc(draw_feedback, preedit_buf_len); | |
937 preedit_end_col = preedit_start_col; | |
938 | |
939 char_u *p = string; | |
940 for (int n = 0; n < preedit_buf_len; n++) | |
941 { | |
942 if (n < e->cursorPos() || n >= e->cursorPos() + e->selectionLength()) | |
943 draw_feedback[n] = XIMUnderline; | |
944 else | |
945 draw_feedback[n] = XIMReverse; | |
946 preedit_end_col += (*mb_ptr2cells)(p); | |
947 p += (*mb_ptr2len_check)(p); | |
948 } | |
949 im_preedit_cursor = e->cursorPos(); | |
950 im_preedit_trailing = preedit_buf_len - im_preedit_cursor; | |
951 | |
952 # ifdef FEAT_RIGHTLEFT | |
953 if ((State & CMDLINE) == 0 && curwin != NULL && curwin->w_p_rl) | |
954 backkey[2] = 'r'; | |
955 # endif | |
956 for (int n = 0; n < im_preedit_trailing; n++) | |
957 add_to_input_buf(backkey, (int)sizeof(backkey)); | |
958 | |
786 e->accept(); | 959 e->accept(); |
787 } | 960 } |
788 | 961 #endif |
789 void VimWidget::imComposeEvent(QIMEvent *e) | 962 |
790 { | 963 |
791 //i should do something here, displaying the text somewhere ... (status area ?) | 964 void |
792 e->accept(); | 965 VimMainWindow::lock() |
793 } | 966 { |
794 #endif | 967 locked = true; |
795 | 968 } |
796 | 969 |
797 void VimMainWindow::lock() | 970 void |
798 { | 971 VimMainWindow::unlock() |
799 locked=true; | 972 { |
800 } | 973 locked = false; |
801 | 974 } |
802 void VimMainWindow::unlock() | 975 |
803 { | 976 bool |
804 locked=false; | 977 VimMainWindow::isLocked() |
805 } | |
806 | |
807 bool VimMainWindow::isLocked() | |
808 { | 978 { |
809 return locked; | 979 return locked; |
810 } | 980 } |
811 | 981 |
812 // ->resize VimWidget if not locked | 982 // ->resize VimWidget if not locked |
813 // | 983 // |
814 void VimMainWindow::resizeEvent ( QResizeEvent *e ) //{{{ | 984 void |
815 { | 985 VimMainWindow::resizeEvent(QResizeEvent *e) //{{{ |
816 if ( vmw->isLocked() ) return; | 986 { |
987 if (vmw->isLocked()) | |
988 return; | |
817 //remove toolbar and menubar height | 989 //remove toolbar and menubar height |
818 int height = e->size().height(); | 990 int height = e->size().height(); |
819 int width = e->size().width(); | 991 int width = e->size().width(); |
820 | 992 |
821 if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled() | 993 if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled() |
823 && !vmw->menuBar()->isTopLevelMenu() | 995 && !vmw->menuBar()->isTopLevelMenu() |
824 #endif | 996 #endif |
825 ) | 997 ) |
826 height -= vmw->menuBar()->height(); | 998 height -= vmw->menuBar()->height(); |
827 #ifdef FEAT_TOOLBAR | 999 #ifdef FEAT_TOOLBAR |
828 if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() && | 1000 if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() |
829 (vmw->toolBar()->barPos()==KToolBar::Top || | 1001 && (vmw->toolBar()->barPos() == KToolBar::Top |
830 vmw->toolBar()->barPos()==KToolBar::Bottom)) | 1002 || vmw->toolBar()->barPos() == KToolBar::Bottom)) |
831 height -= vmw->toolBar()->height(); | 1003 height -= vmw->toolBar()->height(); |
832 | 1004 |
833 if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() && | 1005 if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled() |
834 (vmw->toolBar()->barPos()==KToolBar::Left || | 1006 && (vmw->toolBar()->barPos() == KToolBar::Left |
835 vmw->toolBar()->barPos()==KToolBar::Right)) | 1007 || vmw->toolBar()->barPos() == KToolBar::Right)) |
836 width -= vmw->toolBar()->width(); | 1008 width -= vmw->toolBar()->width(); |
837 #endif | 1009 #endif |
838 height = ( ((int)(height/gui.char_height))*gui.char_height ); | 1010 height = ((int)(height/gui.char_height))*gui.char_height; |
839 if (!vmw->isLocked()) gui_resize_shell(width,height); | 1011 if (!vmw->isLocked()) |
840 }//}}} | 1012 gui_resize_shell(width, height); |
841 | 1013 }//}}} |
842 void VimWidget::focusInEvent( QFocusEvent * fe ) // {{{ | 1014 |
1015 void | |
1016 VimWidget::focusInEvent(QFocusEvent *fe) // {{{ | |
843 { | 1017 { |
844 gui_focus_change(true); | 1018 gui_focus_change(true); |
845 | 1019 |
846 if (blink_state == BLINK_NONE) | 1020 if (blink_state == BLINK_NONE) |
847 gui_mch_start_blink(); | 1021 gui_mch_start_blink(); |
848 } // }}} | 1022 } // }}} |
849 | 1023 |
850 void VimWidget::focusOutEvent( QFocusEvent * fe )//{{{ | 1024 void |
1025 VimWidget::focusOutEvent(QFocusEvent *fe)//{{{ | |
851 { | 1026 { |
852 gui_focus_change(false); | 1027 gui_focus_change(false); |
853 | 1028 |
854 if (blink_state != BLINK_NONE) | 1029 if (blink_state != BLINK_NONE) |
855 gui_mch_stop_blink(); | 1030 gui_mch_stop_blink(); |
856 }//}}} | 1031 }//}}} |
857 | 1032 |
858 void VimWidget::set_blink_time( long wait, long on, long off)//{{{ | 1033 void |
1034 VimWidget::set_blink_time(long wait, long on, long off)//{{{ | |
859 { | 1035 { |
860 blink_wait_time = wait; | 1036 blink_wait_time = wait; |
861 blink_on_time = on; | 1037 blink_on_time = on; |
862 blink_off_time = off; | 1038 blink_off_time = off; |
863 }//}}} | 1039 }//}}} |
864 | 1040 |
865 void VimWidget::start_cursor_blinking()//{{{ | 1041 void |
866 { | 1042 VimWidget::start_cursor_blinking()//{{{ |
867 if (blink_timer.isActive()) blink_timer.stop(); | 1043 { |
1044 if (blink_timer.isActive()) | |
1045 blink_timer.stop(); | |
868 | 1046 |
869 /* Only switch blinking on if none of the times is zero */ | 1047 /* Only switch blinking on if none of the times is zero */ |
870 if (blink_wait_time && blink_on_time && blink_off_time && gui.in_focus) | 1048 if (blink_wait_time && blink_on_time && blink_off_time && gui.in_focus) |
871 { | 1049 { |
872 blink_state = BLINK_ON; | 1050 blink_state = BLINK_ON; |
874 // The first blink appears after wait_time | 1052 // The first blink appears after wait_time |
875 blink_timer.start( blink_wait_time, true); | 1053 blink_timer.start( blink_wait_time, true); |
876 } | 1054 } |
877 }//}}} | 1055 }//}}} |
878 | 1056 |
879 void VimWidget::blink_cursor()//{{{ | 1057 void |
1058 VimWidget::blink_cursor()//{{{ | |
880 { | 1059 { |
881 if (blink_state == BLINK_ON) | 1060 if (blink_state == BLINK_ON) |
882 { | 1061 { |
883 // set cursor off | 1062 // set cursor off |
884 gui_undraw_cursor(); | 1063 gui_undraw_cursor(); |
892 blink_state = BLINK_ON; | 1071 blink_state = BLINK_ON; |
893 blink_timer.start( blink_on_time, true); | 1072 blink_timer.start( blink_on_time, true); |
894 } | 1073 } |
895 }//}}} | 1074 }//}}} |
896 | 1075 |
897 void VimWidget::stop_cursor_blinking()//{{{ | 1076 void |
898 { | 1077 VimWidget::stop_cursor_blinking()//{{{ |
899 if (blink_timer.isActive()) blink_timer.stop(); | 1078 { |
1079 if (blink_timer.isActive()) | |
1080 blink_timer.stop(); | |
900 | 1081 |
901 if (blink_state == BLINK_OFF) | 1082 if (blink_state == BLINK_OFF) |
902 gui_update_cursor(TRUE, FALSE); | 1083 gui_update_cursor(TRUE, FALSE); |
903 | 1084 |
904 blink_state = BLINK_NONE; | 1085 blink_state = BLINK_NONE; |
905 }//}}} | 1086 }//}}} |
906 | 1087 |
907 #ifdef FEAT_MZSCHEME | 1088 #ifdef FEAT_MZSCHEME |
908 void VimWidget::timerEvent( QTimerEvent * evnt)//{{{ | 1089 void |
1090 VimWidget::timerEvent(QTimerEvent * evnt)//{{{ | |
909 { | 1091 { |
910 if (evnt->timerId() == mzscheme_timer_id) | 1092 if (evnt->timerId() == mzscheme_timer_id) |
911 timer_proc(); | 1093 timer_proc(); |
912 }//}}} | 1094 }//}}} |
913 | 1095 |
914 void VimWidget::enable_mzscheme_threads()//{{{ | 1096 void |
1097 VimWidget::enable_mzscheme_threads()//{{{ | |
915 { | 1098 { |
916 mzscheme_timer_id = startTimer(p_mzq); | 1099 mzscheme_timer_id = startTimer(p_mzq); |
917 }//}}} | 1100 }//}}} |
918 | 1101 |
919 void VimWidget::disable_mzscheme_threads()//{{{ | 1102 void |
1103 VimWidget::disable_mzscheme_threads()//{{{ | |
920 { | 1104 { |
921 killTimer(mzscheme_timer_id); | 1105 killTimer(mzscheme_timer_id); |
922 }//}}} | 1106 }//}}} |
923 #endif | 1107 #endif |
924 | 1108 |
925 void VimWidget::flash()//{{{ | 1109 void |
1110 VimWidget::flash()//{{{ | |
926 { | 1111 { |
927 QPainter p(this); | 1112 QPainter p(this); |
928 | 1113 |
929 p.setRasterOp(Qt::XorROP); | 1114 p.setRasterOp(Qt::XorROP); |
930 p.fillRect(geometry(),QColor(0xFF,0xFF,0xFF)); | 1115 p.fillRect(geometry(), QColor(0xFF, 0xFF, 0xFF)); |
931 p.flush(); | 1116 p.flush(); |
932 //FIXME: Make this a little smarter. Maybe add a timer or something | 1117 //FIXME: Make this a little smarter. Maybe add a timer or something |
933 usleep(19000); | 1118 usleep(19000); |
934 p.fillRect(geometry(),QColor(0xFF,0xFF,0xFF)); | 1119 p.fillRect(geometry(), QColor(0xFF, 0xFF, 0xFF)); |
935 p.flush(); | 1120 p.flush(); |
936 p.end(); | 1121 p.end(); |
937 }//}}} | 1122 }//}}} |
938 | 1123 |
939 | 1124 |
940 /* | 1125 /* |
941 * The main Window | 1126 * The main Window |
942 */ | 1127 */ |
943 VimMainWindow::VimMainWindow ( const char *name , WFlags f)//{{{ | 1128 VimMainWindow::VimMainWindow(const char *name , WFlags f)//{{{ |
944 :KMainWindow(0L, name,f) | 1129 :KMainWindow(0L, name, f) |
945 { | 1130 { |
946 #ifdef FEAT_CLIENTSERVER | 1131 #ifdef FEAT_CLIENTSERVER |
947 oldFilter = qt_set_x11_event_filter( kvim_x11_event_filter ); | 1132 oldFilter = qt_set_x11_event_filter(kvim_x11_event_filter); |
948 #endif | 1133 #endif |
949 if (echo_wid_arg== 1) | 1134 if (echo_wid_arg == 1) |
950 { | 1135 { |
951 fprintf(stderr, "WID: %ld\n", (long)winId()); | 1136 fprintf(stderr, "WID: %ld\n", (long)winId()); |
952 fflush(stderr); | 1137 fflush(stderr); |
953 } | 1138 } |
954 | 1139 |
955 w = new VimWidget(this, "main vim widget"); | 1140 w = new VimWidget(this, "main vim widget"); |
956 gui.w = w; | 1141 gui.w = w; |
957 setFocusProxy(w); | 1142 setFocusProxy(w); |
958 w->setFocus(); | 1143 w->setFocus(); |
959 have_tearoff=0; | 1144 have_tearoff = 0; |
960 | 1145 |
961 finddlg=new KEdFind (this,0,false); | 1146 finddlg = new KEdFind(this, 0, false); |
962 repldlg=new KEdReplace (this,0,false); | 1147 repldlg = new KEdReplace(this, 0, false); |
963 QObject::connect( finddlg, SIGNAL(search()), this, SLOT(slotSearch()) ); | 1148 QObject::connect(finddlg, SIGNAL(search()), this, SLOT(slotSearch())); |
964 QObject::connect( repldlg, SIGNAL(find()), this, SLOT(slotFind()) ); | 1149 QObject::connect(repldlg, SIGNAL(find()), this, SLOT(slotFind())); |
965 QObject::connect( repldlg, SIGNAL(replace()), this, SLOT(slotReplace()) ); | 1150 QObject::connect(repldlg, SIGNAL(replace()), this, SLOT(slotReplace())); |
966 QObject::connect( repldlg, SIGNAL(replaceAll()), this, SLOT(slotReplaceAll()) ); | 1151 QObject::connect(repldlg, SIGNAL(replaceAll()), this, |
1152 SLOT(slotReplaceAll())); | |
967 | 1153 |
968 #ifdef FEAT_TOOLBAR | 1154 #ifdef FEAT_TOOLBAR |
969 connect(toolBar(), SIGNAL(clicked(int)), this, SLOT(menu_activated(int))); | 1155 connect(toolBar(), SIGNAL(clicked(int)), this, SLOT(menu_activated(int))); |
970 #endif | 1156 #endif |
971 #ifdef FEAT_CLIENTSERVER | 1157 #ifdef FEAT_CLIENTSERVER |
972 w->serverActivate(winId()); | 1158 w->serverActivate(winId()); |
973 | 1159 |
974 if (serverName!=NULL) | 1160 if (serverName != NULL) |
975 kapp->dcopClient()->registerAs(QCString((const char*)serverName),false); | 1161 kapp->dcopClient()->registerAs(QCString((const char*)serverName), |
976 else if (serverDelayedStartName!=NULL) | 1162 false); |
977 kapp->dcopClient()->registerAs(QCString((const char*)serverDelayedStartName),false); | 1163 else if (serverDelayedStartName != NULL) |
978 else if (argServerName!=NULL) | 1164 kapp->dcopClient()->registerAs( |
979 kapp->dcopClient()->registerAs(argServerName->utf8(),false); | 1165 QCString((const char*)serverDelayedStartName), false); |
1166 else if (argServerName != NULL) | |
1167 kapp->dcopClient()->registerAs(argServerName->utf8(), false); | |
980 #else | 1168 #else |
981 if (argServerName!=NULL) | 1169 if (argServerName != NULL) |
982 kapp->dcopClient()->registerAs(argServerName->utf8(),false); | 1170 kapp->dcopClient()->registerAs(argServerName->utf8(), false); |
983 #endif | 1171 #endif |
984 QXEmbed::initialize(); | 1172 QXEmbed::initialize(); |
985 | 1173 |
986 }//{{{ | 1174 }//{{{ |
987 | 1175 |
988 bool VimMainWindow::queryClose()//{{{ | 1176 bool |
1177 VimMainWindow::queryClose()//{{{ | |
989 { | 1178 { |
990 gui_shell_closed(); | 1179 gui_shell_closed(); |
991 return true; | 1180 return true; |
992 }//}}} | 1181 }//}}} |
993 | 1182 |
994 bool VimMainWindow::queryExit()//{{{ | 1183 bool |
1184 VimMainWindow::queryExit()//{{{ | |
995 { | 1185 { |
996 return true; | 1186 return true; |
997 }//}}} | 1187 }//}}} |
998 | 1188 |
999 void VimMainWindow::menu_activated(int dx)//{{{ | 1189 void |
1190 VimMainWindow::menu_activated(int dx)//{{{ | |
1000 { | 1191 { |
1001 #ifdef FEAT_MENU | 1192 #ifdef FEAT_MENU |
1002 if (!dx) { // tearoff | 1193 if (!dx) // tearoff |
1003 return; | 1194 return; |
1004 } | |
1005 gui_mch_set_foreground(); | 1195 gui_mch_set_foreground(); |
1006 gui_menu_cb((VimMenu *) dx); | 1196 gui_menu_cb((VimMenu *)dx); |
1007 #endif | 1197 #endif |
1008 }//}}} | 1198 }//}}} |
1009 | 1199 |
1010 | 1200 |
1011 void VimMainWindow::clipboard_selection_update(){//{{{ | 1201 void |
1202 VimMainWindow::clipboard_selection_update()//{{{ | |
1203 { | |
1012 if (kapp->clipboard()->ownsSelection()) | 1204 if (kapp->clipboard()->ownsSelection()) |
1013 clip_own_selection(&clip_star); | 1205 clip_own_selection(&clip_star); |
1014 else | 1206 else |
1015 clip_lose_selection(&clip_star); | 1207 clip_lose_selection(&clip_star); |
1016 }//}}} | 1208 }//}}} |
1017 | 1209 |
1018 void VimMainWindow::clipboard_data_update(){//{{{ | 1210 void |
1211 VimMainWindow::clipboard_data_update()//{{{ | |
1212 { | |
1019 #if QT_VERSION>=300 | 1213 #if QT_VERSION>=300 |
1020 if (kapp->clipboard()->ownsClipboard()) | 1214 if (kapp->clipboard()->ownsClipboard()) |
1021 clip_own_selection(&clip_plus); | 1215 clip_own_selection(&clip_plus); |
1022 else | 1216 else |
1023 clip_lose_selection(&clip_plus); | 1217 clip_lose_selection(&clip_plus); |
1027 else | 1221 else |
1028 clip_lose_selection(&clip_star); | 1222 clip_lose_selection(&clip_star); |
1029 #endif | 1223 #endif |
1030 }//}}} | 1224 }//}}} |
1031 | 1225 |
1032 void VimMainWindow::slotSearch()//{{{ | 1226 void |
1227 VimMainWindow::slotSearch()//{{{ | |
1033 { | 1228 { |
1034 QString find_text; | 1229 QString find_text; |
1035 bool direction_down = TRUE; | 1230 bool direction_down = TRUE; |
1036 bool casesensitive = TRUE; | 1231 bool casesensitive = TRUE; |
1037 int flags = FRD_FINDNEXT; | 1232 int flags = FRD_FINDNEXT; |
1039 find_text = finddlg->getText(); | 1234 find_text = finddlg->getText(); |
1040 direction_down = !(finddlg->get_direction()); | 1235 direction_down = !(finddlg->get_direction()); |
1041 casesensitive = finddlg->case_sensitive(); | 1236 casesensitive = finddlg->case_sensitive(); |
1042 // if (casesensitive) find_text = "\\C" + find_text; | 1237 // if (casesensitive) find_text = "\\C" + find_text; |
1043 // else find_text = "\\c" + find_text; | 1238 // else find_text = "\\c" + find_text; |
1044 if (casesensitive) flags|=FRD_MATCH_CASE; | 1239 if (casesensitive) |
1240 flags |= FRD_MATCH_CASE; | |
1045 QCString unistring = vmw->codec->fromUnicode(find_text); | 1241 QCString unistring = vmw->codec->fromUnicode(find_text); |
1046 gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL,(int)direction_down); | 1242 gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL, |
1047 }//}}} | 1243 (int)direction_down); |
1048 | 1244 }//}}} |
1049 void VimMainWindow::slotFind()//{{{ | 1245 |
1246 void | |
1247 VimMainWindow::slotFind()//{{{ | |
1050 { | 1248 { |
1051 QString find_text; | 1249 QString find_text; |
1052 bool direction_down=TRUE; | 1250 bool direction_down = TRUE; |
1053 bool casesensitive = TRUE; | 1251 bool casesensitive = TRUE; |
1054 int flags = FRD_R_FINDNEXT; | 1252 int flags = FRD_R_FINDNEXT; |
1055 | 1253 |
1056 find_text=repldlg->getText(); | 1254 find_text = repldlg->getText(); |
1057 direction_down = !(repldlg->get_direction()); | 1255 direction_down = !(repldlg->get_direction()); |
1058 casesensitive = repldlg->case_sensitive(); | 1256 casesensitive = repldlg->case_sensitive(); |
1059 // if (casesensitive) find_text = "\\C" + find_text; | 1257 // if (casesensitive) find_text = "\\C" + find_text; |
1060 // else find_text = "\\c" + find_text; | 1258 // else find_text = "\\c" + find_text; |
1061 if (casesensitive) flags|=FRD_MATCH_CASE; | 1259 if (casesensitive) flags |= FRD_MATCH_CASE; |
1062 | 1260 |
1063 QCString unistring = vmw->codec->fromUnicode(find_text); | 1261 QCString unistring = vmw->codec->fromUnicode(find_text); |
1064 gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL,(int)direction_down); | 1262 gui_do_findrepl(flags, (char_u *)(const char *)unistring, NULL, |
1065 }//}}} | 1263 (int)direction_down); |
1066 | 1264 }//}}} |
1067 void VimMainWindow::slotReplace()//{{{ | 1265 |
1266 void | |
1267 VimMainWindow::slotReplace()//{{{ | |
1068 { | 1268 { |
1069 QString find_text; | 1269 QString find_text; |
1070 QString repl_text; | 1270 QString repl_text; |
1071 bool direction_down=TRUE; | 1271 bool direction_down = TRUE; |
1072 bool casesensitive = TRUE; | 1272 bool casesensitive = TRUE; |
1073 int flags = FRD_REPLACE; | 1273 int flags = FRD_REPLACE; |
1074 | 1274 |
1075 find_text=repldlg->getText(); | 1275 find_text = repldlg->getText(); |
1076 repl_text=repldlg->getReplaceText(); | 1276 repl_text = repldlg->getReplaceText(); |
1077 direction_down = !(repldlg->get_direction()); | 1277 direction_down = !(repldlg->get_direction()); |
1078 //if (casesensitive) find_text = "\\C" + find_text; | 1278 //if (casesensitive) find_text = "\\C" + find_text; |
1079 //else find_text = "\\c" + find_text; | 1279 //else find_text = "\\c" + find_text; |
1080 if (casesensitive) flags|=FRD_MATCH_CASE; | 1280 if (casesensitive) flags |= FRD_MATCH_CASE; |
1081 | 1281 |
1082 QCString unistring = vmw->codec->fromUnicode(find_text); | 1282 QCString unistring = vmw->codec->fromUnicode(find_text); |
1083 QCString unistring2 = vmw->codec->fromUnicode(repl_text); | 1283 QCString unistring2 = vmw->codec->fromUnicode(repl_text); |
1084 gui_do_findrepl(flags, (char_u *)(const char *)unistring,(char_u *)(const char*)unistring2,(int)direction_down); | 1284 gui_do_findrepl(flags, (char_u *)(const char *)unistring, |
1085 }//}}} | 1285 (char_u *)(const char*)unistring2, (int)direction_down); |
1086 | 1286 }//}}} |
1087 void VimMainWindow::slotReplaceAll()//{{{ | 1287 |
1288 void | |
1289 VimMainWindow::slotReplaceAll()//{{{ | |
1088 { | 1290 { |
1089 QString find_text; | 1291 QString find_text; |
1090 QString repl_text; | 1292 QString repl_text; |
1091 bool direction_down=TRUE; | 1293 bool direction_down = TRUE; |
1092 bool casesensitive = TRUE; | 1294 bool casesensitive = TRUE; |
1093 int flags = FRD_REPLACEALL; | 1295 int flags = FRD_REPLACEALL; |
1094 | 1296 |
1095 find_text=repldlg->getText(); | 1297 find_text = repldlg->getText(); |
1096 repl_text=repldlg->getReplaceText(); | 1298 repl_text = repldlg->getReplaceText(); |
1097 direction_down = !(repldlg->get_direction()); | 1299 direction_down = !(repldlg->get_direction()); |
1098 casesensitive = repldlg->case_sensitive(); | 1300 casesensitive = repldlg->case_sensitive(); |
1099 // if (casesensitive) find_text = "\\C" + find_text; | 1301 // if (casesensitive) find_text = "\\C" + find_text; |
1100 // else find_text = "\\c" + find_text; | 1302 // else find_text = "\\c" + find_text; |
1101 if (casesensitive) flags|=FRD_MATCH_CASE; | 1303 if (casesensitive) |
1304 flags |= FRD_MATCH_CASE; | |
1102 QCString unistring = vmw->codec->fromUnicode(find_text); | 1305 QCString unistring = vmw->codec->fromUnicode(find_text); |
1103 QCString unistring2 = vmw->codec->fromUnicode(repl_text); | 1306 QCString unistring2 = vmw->codec->fromUnicode(repl_text); |
1104 gui_do_findrepl(flags, (char_u *)(const char *)unistring,(char_u *)(const char*)unistring2,(int)direction_down); | 1307 gui_do_findrepl(flags, (char_u *)(const char *)unistring, |
1105 }//}}} | 1308 (char_u *)(const char*)unistring2, (int)direction_down); |
1106 | 1309 }//}}} |
1107 void VimMainWindow::showAboutKDE() | 1310 |
1311 void | |
1312 VimMainWindow::showAboutKDE() | |
1108 { | 1313 { |
1109 KAboutKDE *kde = new KAboutKDE(this); | 1314 KAboutKDE *kde = new KAboutKDE(this); |
1110 kde->show(); | 1315 kde->show(); |
1111 } | 1316 } |
1112 | 1317 |
1113 void VimMainWindow::showAboutApplication()//{{{ | 1318 void |
1114 { | 1319 VimMainWindow::showAboutApplication()//{{{ |
1115 KAboutData *aboutData = new KAboutData ( | 1320 { |
1321 KAboutData *aboutData = new KAboutData( | |
1116 "kvim" | 1322 "kvim" |
1117 , I18N_NOOP("KVim") | 1323 , I18N_NOOP("KVim") |
1118 , VIM_VERSION_SHORT | 1324 , VIM_VERSION_SHORT |
1119 , I18N_NOOP("Vim in a KDE interface") | 1325 , I18N_NOOP("Vim in a KDE interface") |
1120 , 0 | 1326 , 0 |
1171 | 1377 |
1172 KAboutApplication *about = new KAboutApplication(aboutData); | 1378 KAboutApplication *about = new KAboutApplication(aboutData); |
1173 about->show(); | 1379 about->show(); |
1174 }//}}} | 1380 }//}}} |
1175 | 1381 |
1176 void VimMainWindow::showTipOfTheDay() | 1382 void |
1383 VimMainWindow::showTipOfTheDay() | |
1177 { | 1384 { |
1178 #if QT_VERSION>=300 | 1385 #if QT_VERSION>=300 |
1179 KTipDialog::showTip (vmw,QString::null,true); | 1386 KTipDialog::showTip(vmw, QString::null, true); |
1180 #endif | 1387 #endif |
1181 } | 1388 } |
1182 | 1389 |
1183 void VimMainWindow::buffersToolbar() | 1390 void |
1184 { | 1391 VimMainWindow::buffersToolbar() |
1185 | 1392 { |
1186 } | 1393 |
1187 | 1394 } |
1188 void VimMainWindow::showBugReport() | 1395 |
1189 { | 1396 void |
1190 KBugReport *bug= new KBugReport(this,true); | 1397 VimMainWindow::showBugReport() |
1398 { | |
1399 KBugReport *bug= new KBugReport(this, true); | |
1191 bug->show(); | 1400 bug->show(); |
1192 } | 1401 } |
1402 | |
1193 /* | 1403 /* |
1194 * Vim Dialog | 1404 * Vim Dialog |
1195 * | 1405 * |
1196 * Returns: | 1406 * Returns: |
1197 * 0: Cancel | 1407 * 0: Cancel |
1198 * 1- : nb of the pressed button | 1408 * 1- : nb of the pressed button |
1199 */ | 1409 */ |
1200 | 1410 |
1201 VimDialog::VimDialog (int type, /* type of dialog *///{{{ | 1411 VimDialog::VimDialog(int type, /* type of dialog *///{{{ |
1202 char_u * title, /* title of dialog */ | 1412 char_u * title, /* title of dialog */ |
1203 char_u * message, /* message text */ | 1413 char_u * message, /* message text */ |
1204 char_u * buttons, /* names of buttons */ | 1414 char_u * buttons, /* names of buttons */ |
1205 int def_but, /* default button */ | 1415 int def_but, /* default button */ |
1206 char_u *textfield ) /* input field */ | 1416 char_u *textfield) /* input field */ |
1207 :QDialog(vmw, "vim generic dialog", true), // true is for "modal" | 1417 :QDialog(vmw, "vim generic dialog", true), // true is for "modal" |
1208 mapper(this, "dialog signal mapper") | 1418 mapper(this, "dialog signal mapper") |
1209 { | 1419 { |
1210 /* | 1420 /* |
1211 * Create Icon | 1421 * Create Icon |
1212 */ | 1422 */ |
1229 icon_data = quest_xpm; | 1439 icon_data = quest_xpm; |
1230 break; | 1440 break; |
1231 default: | 1441 default: |
1232 icon_data = generic_xpm; | 1442 icon_data = generic_xpm; |
1233 }; | 1443 }; |
1234 QLabel * icon = new QLabel( this ); | 1444 QLabel * icon = new QLabel(this); |
1235 icon->setPixmap( QPixmap( (const char **) icon_data ) ); | 1445 icon->setPixmap(QPixmap((const char **) icon_data)); |
1236 icon->setFixedSize( icon->sizeHint() ); | 1446 icon->setFixedSize(icon->sizeHint()); |
1237 | 1447 |
1238 QLabel * text = new QLabel( (const char *)message, this ); | 1448 QLabel * text = new QLabel(QSTR(message), this); |
1239 text->setAlignment( AlignHCenter | AlignVCenter | ExpandTabs ); | 1449 text->setAlignment(AlignHCenter | AlignVCenter | ExpandTabs); |
1240 | 1450 |
1241 QStringList buttonText = QStringList::split( DLG_BUTTON_SEP, (char *) buttons); | 1451 QStringList buttonText = QStringList::split(DLG_BUTTON_SEP, QSTR(buttons)); |
1242 int butNb = buttonText.count(); | 1452 int butNb = buttonText.count(); |
1243 | 1453 |
1244 /* | 1454 /* |
1245 * Layout | 1455 * Layout |
1246 */ | 1456 */ |
1247 | 1457 |
1248 QVBoxLayout * vly = new QVBoxLayout( this, 5, 5 ); | 1458 QVBoxLayout * vly = new QVBoxLayout(this, 5, 5); |
1249 QHBoxLayout * hly1 = new QHBoxLayout( vly, 5); | 1459 QHBoxLayout * hly1 = new QHBoxLayout(vly, 5); |
1250 hly1->addWidget( icon ); | 1460 hly1->addWidget(icon); |
1251 hly1->addWidget( text ); | 1461 hly1->addWidget(text); |
1252 QHBoxLayout * hly3 = new QHBoxLayout ( vly , 5); | 1462 QHBoxLayout * hly3 = new QHBoxLayout(vly , 5); |
1253 if (textfield!=NULL) | 1463 if (textfield != NULL) |
1254 { | 1464 { |
1255 entry = new QLineEdit((const char *)textfield,this); | 1465 entry = new QLineEdit(QSTR(textfield), this); |
1256 entry->setText((const char *)textfield); | 1466 entry->setText(QSTR(textfield)); |
1257 hly3->addWidget( entry ); | 1467 hly3->addWidget(entry); |
1258 ret=textfield; | 1468 ret = textfield; |
1259 } | 1469 } |
1260 else | 1470 else |
1261 entry=NULL; | 1471 entry = NULL; |
1262 | 1472 |
1263 QHBoxLayout * hly2 = new QHBoxLayout( vly, 15); | 1473 QHBoxLayout * hly2 = new QHBoxLayout(vly, 15); |
1264 QString s; | 1474 QString s; |
1265 QPushButton * pushButton = 0L; | 1475 QPushButton * pushButton = 0L; |
1266 for (int i=0; i<butNb; i++) | 1476 for (int i = 0; i<butNb; i++) |
1267 { | 1477 { |
1268 s = buttonText[i]; | 1478 s = buttonText[i]; |
1269 pushButton = new QPushButton(s, this ); | 1479 pushButton = new QPushButton(s, this); |
1270 if (s.find('&') != -1) | 1480 if (s.find('&') != -1) |
1271 pushButton->setAccel(s.at(s.find('&')+1).latin1()); | 1481 pushButton->setAccel(s.at(s.find('&') + 1).latin1()); |
1272 | 1482 |
1273 hly2->addWidget( pushButton ); | 1483 hly2->addWidget(pushButton); |
1274 if (i == def_but-1) | 1484 if (i == def_but - 1) |
1275 { | 1485 { |
1276 pushButton->setDefault( true ); | 1486 pushButton->setDefault(true); |
1277 pushButton->setAutoDefault( true ); | 1487 pushButton->setAutoDefault(true); |
1278 setResult( i+1 ); | 1488 setResult(i + 1); |
1279 } | 1489 } |
1280 connect(pushButton, SIGNAL(clicked()), &mapper, SLOT(map())); | 1490 connect(pushButton, SIGNAL(clicked()), &mapper, SLOT(map())); |
1281 mapper.setMapping(pushButton, i+1); | 1491 mapper.setMapping(pushButton, i + 1); |
1282 } | 1492 } |
1283 connect( &mapper, SIGNAL(mapped(int)), this, SLOT(done(int))); | 1493 connect(&mapper, SIGNAL(mapped(int)), this, SLOT(done(int))); |
1284 | 1494 |
1285 setCaption((const char *) title); | 1495 setCaption(QSTR(title)); |
1286 | 1496 |
1287 vly->activate(); | 1497 vly->activate(); |
1288 }//}}} | 1498 }//}}} |
1289 | 1499 |
1290 void VimDialog::done(int r) | 1500 void |
1291 { | 1501 VimDialog::done(int r) |
1292 if (entry!=NULL) | 1502 { |
1293 { | 1503 if (entry != NULL) |
1294 if (r) | 1504 { |
1505 if (r) | |
1295 { | 1506 { |
1296 QCString unistring=vmw->codec->fromUnicode(entry->text()); | 1507 QCString unistring = vmw->codec->fromUnicode(entry->text()); |
1297 STRCPY(ret,(const char*)unistring); | 1508 STRCPY(ret, (const char*)unistring); |
1298 } | 1509 } |
1299 else | 1510 else |
1300 *ret=NUL; | 1511 *ret = NUL; |
1301 } | 1512 } |
1302 QDialog::done(r); | 1513 QDialog::done(r); |
1303 } | 1514 } |
1304 | 1515 |
1305 /* | 1516 /* |
1310 { | 1521 { |
1311 connect(&mapper, SIGNAL(mapped(int)), this, SLOT(sbUsed(int))); | 1522 connect(&mapper, SIGNAL(mapped(int)), this, SLOT(sbUsed(int))); |
1312 }//}}} | 1523 }//}}} |
1313 | 1524 |
1314 | 1525 |
1315 void SBPool::create(GuiScrollbar * sb, int orient)//{{{ | 1526 void |
1527 SBPool::create(GuiScrollbar * sb, int orient)//{{{ | |
1316 { | 1528 { |
1317 switch(orient) | 1529 switch(orient) |
1318 { | 1530 { |
1319 case SBAR_HORIZ: | 1531 case SBAR_HORIZ: |
1320 sb->w = new QScrollBar(QScrollBar::Horizontal, vmw); | 1532 sb->w = new QScrollBar(QScrollBar::Horizontal, vmw); |
1330 connect(sb->w, SIGNAL(valueChanged(int)), &mapper, SLOT(map())); | 1542 connect(sb->w, SIGNAL(valueChanged(int)), &mapper, SLOT(map())); |
1331 mapper.setMapping(sb->w, (int)sb); | 1543 mapper.setMapping(sb->w, (int)sb); |
1332 }//}}} | 1544 }//}}} |
1333 | 1545 |
1334 | 1546 |
1335 void SBPool::sbUsed(int who)//{{{ | 1547 void |
1548 SBPool::sbUsed(int who)//{{{ | |
1336 { | 1549 { |
1337 GuiScrollbar *sb = (GuiScrollbar*)who; | 1550 GuiScrollbar *sb = (GuiScrollbar*)who; |
1338 gui_drag_scrollbar( sb, sb->w->value(), FALSE); | 1551 gui_drag_scrollbar(sb, sb->w->value(), FALSE); |
1339 }//}}} | 1552 }//}}} |
1340 | 1553 |
1341 | 1554 |
1342 void SBPool::destroy(GuiScrollbar * sb)//{{{ | 1555 void |
1343 { | 1556 SBPool::destroy(GuiScrollbar *sb)//{{{ |
1344 if (!sb->w) return; | 1557 { |
1558 if (!sb->w) | |
1559 return; | |
1345 | 1560 |
1346 delete sb->w; | 1561 delete sb->w; |
1347 sb->w = 0; | 1562 sb->w = 0; |
1348 }//}}} | 1563 }//}}} |
1349 | 1564 |
1350 #ifdef FEAT_CLIENTSERVER | 1565 #ifdef FEAT_CLIENTSERVER |
1351 static int kvim_x11_event_filter( XEvent* e)//{{{ | 1566 static int |
1567 kvim_x11_event_filter(XEvent* e)//{{{ | |
1352 { | 1568 { |
1353 if (e->xproperty.type == PropertyNotify | 1569 if (e->xproperty.type == PropertyNotify |
1354 && e->xproperty.atom == commProperty | 1570 && e->xproperty.atom == commProperty |
1355 && e->xproperty.window == commWindow | 1571 && e->xproperty.window == commWindow |
1356 && e->xproperty.state == PropertyNewValue) | 1572 && e->xproperty.state == PropertyNewValue) |
1357 serverEventProc(qt_xdisplay(), e); | 1573 serverEventProc(qt_xdisplay(), e); |
1358 | 1574 |
1359 if (oldFilter) return oldFilter( e ); | 1575 if (oldFilter) |
1576 return oldFilter( e ); | |
1360 return FALSE; | 1577 return FALSE; |
1361 }//}}} | 1578 }//}}} |
1362 #endif | 1579 #endif |
1363 | 1580 |
1364 //add some QT 3 fonts usefull functions | 1581 //add some QT 3 fonts usefull functions |
1365 #if QT_VERSION<300 | 1582 #if QT_VERSION<300 |
1366 QString KVimUtils::toString(QFont *f) | 1583 QString |
1584 KVimUtils::toString(QFont *f) | |
1367 { | 1585 { |
1368 QStringList l; | 1586 QStringList l; |
1369 l.append(f->family()); | 1587 l.append(f->family()); |
1370 l.append(QString::number(f->pointSize())); | 1588 l.append(QString::number(f->pointSize())); |
1371 l.append(QString::number(f->pixelSize())); | 1589 l.append(QString::number(f->pixelSize())); |
1377 l.append(QString::number((int)f->fixedPitch())); | 1595 l.append(QString::number((int)f->fixedPitch())); |
1378 l.append(QString::number((int)f->rawMode())); | 1596 l.append(QString::number((int)f->rawMode())); |
1379 return l.join(","); | 1597 return l.join(","); |
1380 } | 1598 } |
1381 | 1599 |
1382 bool KVimUtils::fromString(QFont *f, QString descrip) | 1600 bool |
1601 KVimUtils::fromString(QFont *f, QString descrip) | |
1383 { | 1602 { |
1384 QStringList l(QStringList::split(',', descrip)); | 1603 QStringList l(QStringList::split(',', descrip)); |
1385 | 1604 |
1386 int count = l.count(); | 1605 int count = l.count(); |
1387 if (count != 10 && count != 9) | 1606 if (count != 10 && count != 9) |
1388 return FALSE; | 1607 return FALSE; |
1389 | 1608 |
1390 f->setFamily(l[0]); | 1609 f->setFamily(l[0]); |
1391 f->setPointSize(l[1].toInt()); | 1610 f->setPointSize(l[1].toInt()); |
1392 if ( count == 9 ) | 1611 if (count == 9) |
1393 { | 1612 { |
1394 f->setStyleHint((QFont::StyleHint) l[2].toInt()); | 1613 f->setStyleHint((QFont::StyleHint) l[2].toInt()); |
1395 f->setWeight(l[3].toInt()); | 1614 f->setWeight(l[3].toInt()); |
1396 f->setItalic(l[4].toInt()); | 1615 f->setItalic(l[4].toInt()); |
1397 f->setUnderline(l[5].toInt()); | 1616 f->setUnderline(l[5].toInt()); |
1412 } | 1631 } |
1413 return TRUE; | 1632 return TRUE; |
1414 } | 1633 } |
1415 #endif | 1634 #endif |
1416 | 1635 |
1417 QString KVimUtils::convertEncodingName(QString name) | 1636 QString |
1418 { | 1637 KVimUtils::convertEncodingName(QString name) |
1419 if (name.startsWith("ucs") || name.startsWith("utf-16")) return QString("utf16"); | 1638 { |
1420 if (name=="cp950") return QString("Big5"); | 1639 if (name.startsWith("ucs") || name.startsWith("utf-16")) |
1640 return QString("utf16"); | |
1641 if (name == "cp950") | |
1642 return QString("Big5"); | |
1421 return QString(); | 1643 return QString(); |
1422 } | 1644 } |