blob: 1ac8db990e402a8f250f566afb8f87994ed8d2a1 [file] [log] [blame]
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +00001/* vi:set ts=8 sts=4 sw=4:
Bram Moolenaar843ee412004-06-30 16:16:41 +00002 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 */
8
9/*
10 * Porting to KDE(2) was done by
11 *
12 * (C) 2000 by Thomas Capricelli <orzel@freehackers.org>
13 *
14 * Please visit http://freehackers.org/kvim for other vim- or
15 * kde-related coding.
16 *
17 * $Id$
18 *
19 */
20#include <assert.h>
21#include <errno.h>
22#include <string.h>
23#include <kmenubar.h>
24#include <kfiledialog.h>
25#include <kiconloader.h>
26
27#include <qscrollbar.h>
28#include <qcursor.h>
29#include <qmessagebox.h>
30#include <qiconset.h>
31#include <qtextcodec.h>
Bram Moolenaar5eb86f92004-07-26 12:53:41 +000032#include "gui_kde_wid.h"
Bram Moolenaar843ee412004-06-30 16:16:41 +000033
34extern "C" {
35#include "vim.h"
36}
37
38#undef dbf
39#undef db
40#undef mputs
41
42#if 1
Bram Moolenaar1cd871b2004-12-19 22:46:22 +000043#define dbf(format, args...) { printf("%s" " : " format "\n" , __FUNCTION__ , ## args ); fflush(stdout); }
44#define db() { printf("%s\n", __FUNCTION__ );fflush(stdout); }
Bram Moolenaar843ee412004-06-30 16:16:41 +000045#else
46#define dbf(format, args... )
47#define db()
48#endif
49
50
51#ifdef FEAT_TOOLBAR
52#ifndef FEAT_KDETOOLBAR
53/*
54 * Icons used by the toolbar code.
55 *///{{{
56#include "../pixmaps/tb_new.xpm"
57#include "../pixmaps/tb_open.xpm"
58#include "../pixmaps/tb_close.xpm"
59#include "../pixmaps/tb_save.xpm"
60#include "../pixmaps/tb_print.xpm"
61#include "../pixmaps/tb_cut.xpm"
62#include "../pixmaps/tb_copy.xpm"
63#include "../pixmaps/tb_paste.xpm"
64#include "../pixmaps/tb_find.xpm"
65#include "../pixmaps/tb_find_next.xpm"
66#include "../pixmaps/tb_find_prev.xpm"
67#include "../pixmaps/tb_find_help.xpm"
68#include "../pixmaps/tb_exit.xpm"
69#include "../pixmaps/tb_undo.xpm"
70#include "../pixmaps/tb_redo.xpm"
71#include "../pixmaps/tb_help.xpm"
72#include "../pixmaps/tb_macro.xpm"
73#include "../pixmaps/tb_make.xpm"
74#include "../pixmaps/tb_save_all.xpm"
75#include "../pixmaps/tb_jump.xpm"
76#include "../pixmaps/tb_ctags.xpm"
77#include "../pixmaps/tb_load_session.xpm"
78#include "../pixmaps/tb_save_session.xpm"
79#include "../pixmaps/tb_new_session.xpm"
80#include "../pixmaps/tb_blank.xpm"
81#include "../pixmaps/tb_maximize.xpm"
82#include "../pixmaps/tb_split.xpm"
83#include "../pixmaps/tb_minimize.xpm"
84#include "../pixmaps/tb_shell.xpm"
85#include "../pixmaps/tb_replace.xpm"
86#include "../pixmaps/tb_vsplit.xpm"
87#include "../pixmaps/tb_maxwidth.xpm"
88#include "../pixmaps/tb_minwidth.xpm"
89//}}}
90/*
91 * These are the pixmaps used for the default buttons.
92 * Order must exactly match toolbar_names[] in menu.c!
93 *///{{{
94static char **(built_in_pixmaps[]) =
95{
96 tb_new_xpm,
97 tb_open_xpm,
98 tb_save_xpm,
99 tb_undo_xpm,
100 tb_redo_xpm,
101 tb_cut_xpm,
102 tb_copy_xpm,
103 tb_paste_xpm,
104 tb_print_xpm,
105 tb_help_xpm,
106 tb_find_xpm,
107 tb_save_all_xpm,
108 tb_save_session_xpm,
109 tb_new_session_xpm,
110 tb_load_session_xpm,
111 tb_macro_xpm,
112 tb_replace_xpm,
113 tb_close_xpm,
114 tb_maximize_xpm,
115 tb_minimize_xpm,
116 tb_split_xpm,
117 tb_shell_xpm,
118 tb_find_prev_xpm,
119 tb_find_next_xpm,
120 tb_find_help_xpm,
121 tb_make_xpm,
122 tb_jump_xpm,
123 tb_ctags_xpm,
124 tb_vsplit_xpm,
125 tb_maxwidth_xpm,
126 tb_minwidth_xpm,
127 tb_exit_xpm
128};//}}}
129#else
130const char *kdeicons[] = {
131 "filenew",
132 "fileopen",
133 "filesave",
134 "undo",
135 "redo",
136 "editcut",
137 "editcopy",
138 "editpaste",
139 "fileprint",
140 "contents2",
141 "filefind",
142 "save_all",
143 "fileexport",
144 "filenew",
145 "fileimport",
146 "run",
147 "edit",
148 "fileclose",
149 "",
150 "",
151 "split",
152 "openterm",
153 "previous",
154 "next",
155 "help",
156 "make",
157 "goto",
158 "run",
159 "vsplit",
160 "maxwidth",
161 "minwidth",
162 "quit"
163};
164#endif
165/*
166 * creates a blank pixmap using tb_blank
167 */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000168 QPixmap
Bram Moolenaar843ee412004-06-30 16:16:41 +0000169pixmap_create_from_xpm(char **xpm)//{{{
170{
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000171 return (QPixmap((const char **)xpm));
Bram Moolenaar843ee412004-06-30 16:16:41 +0000172}//}}}
173
174/*
175 * creates a pixmap by using a built-in number
176 */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000177 QPixmap
Bram Moolenaar843ee412004-06-30 16:16:41 +0000178pixmap_create_by_num(int pixmap_num)//{{{
179{
180#ifdef FEAT_KDETOOLBAR
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000181 if (pixmap_num >= 0 && (unsigned)pixmap_num < (sizeof(kdeicons)
182 / sizeof(kdeicons[0])) - 1)
183 {
Bram Moolenaar843ee412004-06-30 16:16:41 +0000184
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000185 KIconLoader *il = kapp->iconLoader(); //new KIconLoader();
186 QString icon;
187 icon = QString(kdeicons[pixmap_num]);
188 return il->loadIcon(icon, KIcon::MainToolbar);
189 }
190 return QPixmap();
Bram Moolenaar843ee412004-06-30 16:16:41 +0000191#else
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000192 if (pixmap_num >= 0 && (unsigned)pixmap_num < (sizeof(built_in_pixmaps)
193 / sizeof(built_in_pixmaps[0])) - 1)
194 return pixmap_create_from_xpm(built_in_pixmaps[pixmap_num]);
195 else
196 return QPixmap();
Bram Moolenaar843ee412004-06-30 16:16:41 +0000197#endif
198}//}}}
199
200/*
201 * Creates a pixmap by using the pixmap "name" found in 'runtimepath'/bitmaps/
202 */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000203 QPixmap
Bram Moolenaar843ee412004-06-30 16:16:41 +0000204pixmap_create_by_dir(char_u *name)//{{{
205{
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000206 char_u full_pathname[MAXPATHL + 1];
Bram Moolenaar843ee412004-06-30 16:16:41 +0000207
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000208 if (gui_find_bitmap(name, full_pathname, "xpm") == OK)
209 {
210 return QPixmap((const char *)full_pathname);
211 }
212 else
213 return QPixmap();
Bram Moolenaar843ee412004-06-30 16:16:41 +0000214}//}}}
215
216
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000217 QPixmap
Bram Moolenaar843ee412004-06-30 16:16:41 +0000218pixmap_create_from_file(char_u *file)
219{
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000220 return QPixmap((const char *)file);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000221}
222#endif
223
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000224 void
Bram Moolenaar843ee412004-06-30 16:16:41 +0000225gui_mch_add_menu(vimmenu_T * menu, int idx)//{{{
226{
227#ifdef FEAT_MENU
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000228 QPopupMenu *me;
229 vimmenu_T *parent = menu->parent;
Bram Moolenaar843ee412004-06-30 16:16:41 +0000230
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000231 if (menu_is_popup(menu->name))
232 {
233 menu->widget = new QPopupMenu(vmw , (const char *)menu->name);
234 QObject::connect(menu->widget, SIGNAL(activated(int)), vmw,
235 SLOT(menu_activated(int)));
236 return;
237 }
Bram Moolenaar843ee412004-06-30 16:16:41 +0000238
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000239 if (!menu_is_menubar(menu->name))
240 return;
Bram Moolenaar843ee412004-06-30 16:16:41 +0000241
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000242 if (parent)
243 {
244 idx++; // for tearoffs to be first in menus
245 me = new QPopupMenu(parent->widget, (const char *)menu->name);
246 parent->widget->insertItem(QString((const char *)menu->name), me,
247 (int)me, idx);
248 }
249 else
250 {
251 me = new QPopupMenu(vmw->menuBar() , (const char *)menu->name);
252 vmw->menuBar()->insertItem(QString((const char *)menu->name), me,
253 (int)me, idx);
254 }
Bram Moolenaar843ee412004-06-30 16:16:41 +0000255
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000256 me->setCaption((const char *)(menu->dname));
257 if (vmw->have_tearoff)
258 me->insertTearOffHandle(0, 0);
259 QObject::connect(me, SIGNAL(activated(int)), vmw,
260 SLOT(menu_activated(int)));
261 menu->widget = me;
Bram Moolenaar843ee412004-06-30 16:16:41 +0000262#endif
263}//}}}
264
265
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000266 void
Bram Moolenaar843ee412004-06-30 16:16:41 +0000267gui_mch_add_menu_item(vimmenu_T * menu, int idx)//{{{
268{
269#ifdef FEAT_MENU
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000270 vimmenu_T *parent = menu->parent;
Bram Moolenaar843ee412004-06-30 16:16:41 +0000271#ifdef FEAT_TOOLBAR
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000272 if (menu_is_toolbar(parent->name))
273 {
274 QPixmap pix;
275
276 if (menu_is_separator(menu->name))
277 {
278 vmw->toolBar()->insertSeparator();
279 return;
Bram Moolenaar843ee412004-06-30 16:16:41 +0000280 }
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000281 if (menu->iconfile != NULL)
282 {
283 pix = pixmap_create_from_file(menu->iconfile);
284 }
285 if (!menu->icon_builtin)
286 {
287 pix = pixmap_create_by_dir(menu->name);
288 }
289 if (pix.isNull() && menu->iconidx >= 0)
290 {
291 pix = pixmap_create_by_num(menu->iconidx);
292 }
293#ifndef FEAT_KDETOOLBAR
294 if (pix.isNull())
295 {
296 pix = pixmap_create_from_xpm(tb_blank_xpm);
297 }
298#endif
299 if (pix.isNull())
300 return; // failed
301 vmw->toolBar()->insertButton(
302 pix,
303 (int)menu, // id
304 true,
305 (char *)(menu->strings[MENU_INDEX_TIP]), // tooltip or text
306 idx);
307 menu->parent=parent;
308 return;
309 }
Bram Moolenaar843ee412004-06-30 16:16:41 +0000310#endif // FEAT_TOOLBAR
311
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000312 idx++;
313 if (menu_is_separator(menu->name))
314 {
315 parent->widget->insertSeparator();
316 return;
317 }
318 parent->widget->insertItem(QString((const char *)menu->name), (int)menu, idx);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000319#endif
320}//}}}
321
322
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000323 void
Bram Moolenaar843ee412004-06-30 16:16:41 +0000324gui_mch_set_text_area_pos(int x, int y, int w, int h)//{{{
325{
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000326 int X = 0;
327 int Y = 0;
Bram Moolenaar843ee412004-06-30 16:16:41 +0000328
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000329 if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
330#if QT_VERSION>=300
331 && !vmw->menuBar()->isTopLevelMenu()
332#endif
333 )
334 Y += vmw->menuBar()->height();
335#ifdef FEAT_TOOLBAR
336 if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
337 && vmw->toolBar()->barPos()==KToolBar::Top)
338 Y += vmw->toolBar()->height();
339
340 if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
341 && vmw->toolBar()->barPos()==KToolBar::Left)
342 X += vmw->toolBar()->width();
Bram Moolenaar843ee412004-06-30 16:16:41 +0000343#endif // FEAT_TOOLBAR
344
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000345 gui.w->setGeometry(x + X, y + Y, w, h);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000346}//}}}
347
348
349#if defined(FEAT_MENU) || defined(PROTO)
350/*
351 * Enable or disable mnemonics for the toplevel menus.
352 */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000353 void
Bram Moolenaar843ee412004-06-30 16:16:41 +0000354gui_gtk_set_mnemonics(int enable)//{{{ // TO BE REMOVED
355{
356}//}}}
357
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000358 void
Bram Moolenaar843ee412004-06-30 16:16:41 +0000359toggle_tearoffs(vimmenu_T *menu, int enable)//{{{
360{
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000361 while (menu != NULL)
362 {
363 if (!menu_is_popup(menu->name))
364 {
365 if (menu->widget != 0)
366 {
367 if (enable)
368 menu->widget->insertTearOffHandle(0,0);
369 else
370 menu->widget->removeItem(0);
371 }
372 toggle_tearoffs(menu->children, enable);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000373 }
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000374 menu = menu->next;
375 }
Bram Moolenaar843ee412004-06-30 16:16:41 +0000376}//}}}
377
378 void
379gui_mch_toggle_tearoffs(int enable)//{{{
380{
381 vmw->have_tearoff=enable;
382 toggle_tearoffs(root_menu, enable);
383}//}}}
384#endif
385
386
387#if defined(FEAT_MENU) || defined(PROTO)
388/*
389 * Destroy the machine specific menu widget.
390 */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000391 void
Bram Moolenaar843ee412004-06-30 16:16:41 +0000392gui_mch_destroy_menu(vimmenu_T * menu)//{{{
393{
394#ifdef FEAT_TOOLBAR
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000395 if (menu->parent && menu_is_toolbar(menu->parent->name))
396 {
397 vmw->toolBar()->removeItem((int)menu);
398 return;
399 }
Bram Moolenaar843ee412004-06-30 16:16:41 +0000400#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000401 if (menu->parent)
402 menu->parent->widget->removeItem((int)menu);
403 if (menu->widget)
404 delete menu->widget;
405 menu->widget = 0;
Bram Moolenaar843ee412004-06-30 16:16:41 +0000406}//}}}
407#endif /* FEAT_MENU */
408
409
410/*
411 * Scrollbar stuff.
412 */
413
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000414 void
415gui_mch_set_scrollbar_thumb(scrollbar_T *sb, long val, long size, long max)//{{{
Bram Moolenaar843ee412004-06-30 16:16:41 +0000416{
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000417 if (!sb->w)
418 return;
Bram Moolenaar843ee412004-06-30 16:16:41 +0000419
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000420 sb->w->setRange(0, max + 1 - size);
421 sb->w->setValue(val);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000422
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000423 sb->w->setLineStep(1);
424 sb->w->setPageStep(size);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000425}//}}}
426
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000427 void
428gui_mch_set_scrollbar_pos(scrollbar_T *sb, int x, int y, int w, int h)//{{{
Bram Moolenaar843ee412004-06-30 16:16:41 +0000429{
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000430 if (!sb->w)
431 return;
432 //we add the menubar and toolbar height/width
433 int X = 0;
434 int Y = 0;
Bram Moolenaar843ee412004-06-30 16:16:41 +0000435
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000436 if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
Bram Moolenaar843ee412004-06-30 16:16:41 +0000437#if QT_VERSION>=300
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000438 && !vmw->menuBar()->isTopLevelMenu()
Bram Moolenaar843ee412004-06-30 16:16:41 +0000439#endif
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000440 )
441 Y += vmw->menuBar()->height();
Bram Moolenaar843ee412004-06-30 16:16:41 +0000442#ifdef FEAT_TOOLBAR
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000443 if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
444 && vmw->toolBar()->barPos()==KToolBar::Top)
445 Y += vmw->toolBar()->height();
Bram Moolenaar843ee412004-06-30 16:16:41 +0000446
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000447 if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
448 && vmw->toolBar()->barPos()==KToolBar::Left)
449 X += vmw->toolBar()->width();
Bram Moolenaar843ee412004-06-30 16:16:41 +0000450#endif //FEAT_TOOLBAR
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000451 if (sb->w->orientation() == Qt::Vertical)
452 {
453 bool leftscroll=gui.which_scrollbars[SBAR_LEFT];
454 bool rightscroll=gui.which_scrollbars[SBAR_RIGHT];
455
456 if (x < 20)
457 leftscroll = true;
458 else
459 rightscroll = true;
460 if (x < 20)
461 sb->w->setGeometry(X, y+Y, w, h);
462 else
463 sb->w->setGeometry(vmw->width() - w - 1 + X, y + Y, w, h);
464 }
465 else
466 {
467 sb->w->setGeometry(x + X, y + Y, w, h);
468 }
Bram Moolenaar843ee412004-06-30 16:16:41 +0000469}//}}}
470
471/* SBAR_VERT or SBAR_HORIZ */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000472 void
473gui_mch_create_scrollbar(scrollbar_T *sb, int orient)//{{{
Bram Moolenaar843ee412004-06-30 16:16:41 +0000474{
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000475 sbpool->create(sb,orient);
476 if (orient == SBAR_VERT)
477 gui.scrollbar_width = sb->w->sizeHint().width();
478 else
479 gui.scrollbar_height = sb->w->sizeHint().height();
Bram Moolenaar843ee412004-06-30 16:16:41 +0000480}//}}}
481
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000482 void
Bram Moolenaar843ee412004-06-30 16:16:41 +0000483gui_mch_destroy_scrollbar(scrollbar_T * sb)//{{{
484{
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000485 sbpool->destroy(sb);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000486}//}}}
487
488#if defined(FEAT_BROWSE) || defined(PROTO)
489/*
490 * Implementation of the file selector related stuff
491 */
492
493/*
494 * Put up a file requester.
495 * Returns the selected name in allocated memory, or NULL for Cancel.
496 * saving, select file to write
497 * title title for the window
498 * dflt default name
499 * ext not used (extension added)
500 * initdir initial directory, NULL for current dir
501 * filter not used (file name filter)
502 */
503/*ARGSUSED*/
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000504 char_u *
Bram Moolenaar843ee412004-06-30 16:16:41 +0000505gui_mch_browse(int saving,//{{{
506 char_u * title,
507 char_u * dflt,
508 char_u * ext,
509 char_u * initdir,
510 char_u * filter)
511{
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000512 char *filt_glob;
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000513
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000514 if (filter != (char_u *)0x0)
515 {
516 filter = vim_strsave(filter);
517 strtok((char *)filter, "(");
518 filt_glob = strtok(0L, ")");
519 }
520 else
521 filt_glob = (char *)filter;
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000522
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000523 gui_mch_mousehide(FALSE);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000524
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000525 QString s;
526 if (!saving)
527 s = KFileDialog::getOpenFileName((char *)initdir, (char *)filt_glob,
528 vmw, (char *)title);
529 else
530 s = KFileDialog::getSaveFileName();
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000531
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000532 if (filter)
533 vim_free(filter);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000534
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000535 if (s.isNull())
536 return NULL;
537 QCString unistring = vmw->codec->fromUnicode(s);
538 char_u *s2 = (char_u *)(const char *)unistring;
539 if (s2)
540 s2 = vim_strsave(s2);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000541
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000542 return s2;
Bram Moolenaar843ee412004-06-30 16:16:41 +0000543}//}}}
544
545#endif /* FEAT_BROWSE */
546
547#ifdef FEAT_GUI_DIALOG
548
549/* ARGSUSED */
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000550 int
Bram Moolenaar843ee412004-06-30 16:16:41 +0000551gui_mch_dialog(int type, /* type of dialog *///{{{
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000552 char_u *title, /* title of dialog */
553 char_u *message, /* message text */
554 char_u *buttons, /* names of buttons */
Bram Moolenaar843ee412004-06-30 16:16:41 +0000555 int def_but, /* default button */
556 char_u *textfield)
557{
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000558 gui_mch_mousehide(FALSE);
559 VimDialog vd(type, title, message, buttons, def_but,textfield);
560 int ret = vd.exec();
561 return ret;
Bram Moolenaar843ee412004-06-30 16:16:41 +0000562}//}}}
563
564
565#endif /* FEAT_GUI_DIALOG */
566
567#if defined(FEAT_MENU) || defined(PROTO)
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000568 void
Bram Moolenaar843ee412004-06-30 16:16:41 +0000569gui_mch_show_popupmenu(vimmenu_T * menu)//{{{
570{
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000571 menu->widget->popup(QCursor::pos());
Bram Moolenaar843ee412004-06-30 16:16:41 +0000572}//}}}
573
574void
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000575gui_make_popup (char_u *pathname)//{{{
576{
577 vimmenu_T *menu = gui_find_menu(pathname);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000578
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000579 if (menu != NULL)
580 menu->widget->popup(QCursor::pos());
Bram Moolenaar843ee412004-06-30 16:16:41 +0000581}//}}}
582#endif
583
584
585
586/* Find and Replace implementations */
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000587 void
588gui_mch_find_dialog(exarg_T *eap)//{{{
Bram Moolenaar843ee412004-06-30 16:16:41 +0000589{
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000590 // char_u* entry_text;
591 //int exact_word=FALSE;
592 // entry_text = get_find_dialog_text(eap->arg,&exact_word);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000593
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000594 vmw->finddlg->setCaseSensitive(true);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000595
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000596 /* if (entry_text!=NULL)
597 * {
598 vmw->finddlg->setText(QString((char *)entry_text));
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000599 // exact match should go there, hopefully KDE old KEdFind/KEdReplace will be replaced in KDE 4 as pple wanted KDE 3's Find/Replace to be kept
600 }*/ // Don't use it, KDE keeps old search in memory and vim give \\Csearch, which is difficult to handle
601 // vim_free(entry_text);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000602
Bram Moolenaar15d0a8c2004-09-06 17:44:46 +0000603 vmw->finddlg->show();
Bram Moolenaar843ee412004-06-30 16:16:41 +0000604}//}}}
605
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000606 void
607gui_mch_replace_dialog(exarg_T *eap)//{{{
Bram Moolenaar843ee412004-06-30 16:16:41 +0000608{
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000609 // char_u* entry_text;
610 //int exact_word=FALSE;
Bram Moolenaar843ee412004-06-30 16:16:41 +0000611
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000612 // entry_text = get_find_dialog_text(eap->arg,&exact_word);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000613
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000614 /* if (entry_text!=NULL)
615 * {
616 vmw->repldlg->setText(QString((char *)entry_text));
617 // exact match should go there, hopefully KDE old KEdFind/KEdReplace will be replaced in KDE 4 as pple wanted KDE 3's Find/Replace to be kept
618 }*/
619 //vim_free(entry_text);
Bram Moolenaar843ee412004-06-30 16:16:41 +0000620
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000621 vmw->repldlg->show();
Bram Moolenaar843ee412004-06-30 16:16:41 +0000622}//}}}
623
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000624 void
Bram Moolenaar843ee412004-06-30 16:16:41 +0000625ex_helpfind(exarg_T *eap)//{{{
626{
Bram Moolenaar1cd871b2004-12-19 22:46:22 +0000627 do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp");
Bram Moolenaar843ee412004-06-30 16:16:41 +0000628}//}}}